OpenWRT Could not open mtd device: FIP

OpenWRT Could not open mtd device: FIP 今天给设备刷机的时候想更新uboot固件一直出现 Could not open mtd device: FIP 错误。解决方案使用kmod-mtd-rw组件这也是网上大家推荐的方案但都是直接让你去opkg install但是很多编译好的固件并没有这个包可以使用官方的预编译好的包进行安装。首先找到自己设备的版本号比如我的是23.05.2然后进入 https://archive.openwrt.org/releases/ 找到对应的版本号然后根据设备的target和subtarget进入响应的目录比如我的是mediatek/filogic最后的网址即https://archive.openwrt.org/releases/23.05.2/targets/mediatek/filogic/packages/在其中找到kmod-mtd-rw包下载安装即可但是由于固件和官方的kernel版本不一致会爆如下错rootImmortalWrt:~# opkg install kmod-mtd-rw_5.15.137git-20160214-2_aarch64_cortex-a53.ipkUnknown packagekmod-mtd-rw.Collected errors: * pkg_hash_check_unresolved: cannotfinddependency kernel(5.15.137-1-29c7378c7e1adfd339581af2c1ddc93a)forkmod-mtd-rw * pkg_hash_fetch_best_installation_candidate: Packagesforkmod-mtd-rw found, but incompatible with the architectures configured * opkg_install_cmd: Cannotinstallpackage kmod-mtd-rw.这时候需要先在package中找到kernel先安装kernel如果提示降级那我们就强制降级即可。命令为opkginstall--force-downgrade kernel_5.15.137-1-29c7378c7e1adfd339581af2c1ddc93a_aarch64_cortex-a53.ipk效果如下rootImmortalWrt:~# opkg install kernel_5.15.137-1-29c7378c7e1adfd339581af2c1ddc93a_aarch64_cortex-a53.ipkNot downgrading package kernel on root from5.15.150-1-ca8427c0778a4b33dfc0a166a18171d7 to5.15.137-1-29c7378c7e1adfd339581af2c1ddc93a. rootImmortalWrt:~# opkg install --force-downgrade kernel_5.15.137-1-29c7378c7e1adfd339581af2c1ddc93a_aarch64_cortex-a53.ipkDowngrading kernel on root from5.15.150-1-ca8427c0778a4b33dfc0a166a18171d7 to5.15.137-1-29c7378c7e1adfd339581af2c1ddc93a... Configuring kernel.然后再安装即可安装成功其他包也是相同的道理rootImmortalWrt:~# opkg install kmod-mtd-rw_5.15.137git-20160214-2_aarch64_cortex-a53.ipkInstalling kmod-mtd-rw(5.15.137git-20160214-2)to root... Configuring kmod-mtd-rw.之后加载mtd-rw这个mod注意这里网上给出的命令为insmod /lib/modules/$(uname -r)/mtd-rw.ko i_want_a_brick1但是因为我们前面重新安装过kerneluname -r获取的版本号会和安装的路径不一样需要手动查找一下。rootImmortalWrt:~# find / -name mtd-rw.ko/lib/modules/5.15.137/mtd-rw.ko /overlay/upper/lib/modules/5.15.137/mtd-rw.ko rootImmortalWrt:~# insmod /lib/modules/5.15.137/mtd-rw.ko i_want_a_brick1之后再写入FIP分区即可这里如果报错了 fip 大小写均可尝试一下rootImmortalWrt:~# mtd write jcgq30-uboot.bin fipUnlocking fip... Writing from jcgq30-uboot.bin to fip...