最近公司产品使用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修改成自己的升级固件的头四字节(注意:十六进制的),重新编译内核,校验通过。