openwrt下web方式升级固件提示文件格式错误

最近公司产品使用openwrt,其中在使用openwrt的web方式升级内核和文件系统时(即sysupgrade固件)时,发现校验文件时提示The uploaded image file does not contain a supported format. Make sure that you choose the generic image format for your platform.于是在网上找了些资料,总结如下:
###网上提供的解决方法:
1.在openwrt-ar71xx-generic-db120-squashfs-sysupgrade.bin的起始位置增加32字节,但是尝试后无果。参考OpenWrt image conversion
2.跟踪调用过程,分析原因,写的不是很清楚,不过给我提供了思路。参考openwrt Web刷写新的固件提示文件格式问题
###自己的解决思路:
1.使用wscp软件将openwrt-ar71xx-generic-db120-squashfs-sysupgrade.bin文件上传至路由器文件系统中。
2.使用sysupgrade命令升级openwrt-ar71xx-generic-db120-squashfs-sysupgrade.bin,命令如下:

openwrt-ar71xx-generic-db120-squashfs-sysupgrade.bin

3.根据步骤2中提示的错误信息,定位具体shell脚本,我的板子提示如下信息:

Invalid image type.
	Image check 'platform_check_image' failed.

4.根据提示错误信息在板子上定位具体文件,find / -type f|xargs grep “platform_check_image”,我最终定位在/lib/upgrade/platform.sh脚本中。
5.在/lib/upgrade/platform.sh的platform_check_image函数中增加打印信息:echo $magic_long,其中magic_long为openwrt-ar71xx-generic-db120-squashfs-sysupgrade.bin的头4字节,我的对不上,于是在openwrt根目录下修改 vim ./linux/ar71xx/base-files/lib/upgrade/platform.sh中将magic_long修改成自己的升级固件的头四字节(注意:十六进制的),重新编译内核,校验通过。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值