openwrt编译时未生成squashfs-sysupgrade.bin的解决办法

最近在编译timecloud固件时发现只生成了initramfs的bin,刷机后没有overlay分区,设置不能保存,查询发现是因为这个bin的问题,正常刷机需要squashfs-sysupgrade.bin。于是查看编译输出,发现在合成时有个错误提示:squashfs-sysupgrade.bin is too big

WARNING: Image file /mnt/disk/lean_lede/lede/build_dir/target-mipsel_24kc_musl/linux-ramips_mt7621/tmp/openwrt-ramips-mt7621-timecloud-squashfs-sysupgrade.bin is too big
cp /mnt/disk/lean_lede/lede/build_dir/target-mipsel_24kc_musl/linux-ramips_mt7621/tmp/openwrt-ramips-mt7621-timecloud-squashfs-sysupgrade.bin /mnt/disk/lean_lede/lede/bin/targets/ramips/mt7621/openwrt-ramips-mt7621-timecloud-squashfs-sysupgrade.bin
cp: cannot stat '/mnt/disk/lean_lede/lede/build_dir/target-mipsel_24kc_musl/linux-ramips_mt7621/tmp/openwrt-ramips-mt7621-timecloud-squashfs-sysupgrade.bin': No such file or directory
make[5]: [/mnt/disk/lean_lede/lede/bin/targets/ramips/mt7621/openwrt-ramips-mt7621-timecloud-squashfs-sysupgrade.bin] Error 1 (ignored)

tinmecloud(迅雷下载宝)rom是16M,查看dts配置OK:

vim target/linux/ramips/dts/Timecloud.dts:

&spi0 {
        status = "okay";

        m25p80@0 {
                #address-cells = <1>;
                #size-cells = <1>;
                compatible = "jedec,spi-nor";
                reg = <0>;
                spi-max-frequency = <10000000>;
                m25p,chunked-io = <32>;

                partition@0 {
                        label = "u-boot";
                        reg = <0x0 0x30000>;
                        read-only;
                };

                partition@30000 {
                        label = "u-boot-env";
                        reg = <0x30000 0x10000>;
                        read-only;
                };

                factory: partition@40000 {
                        label = "factory";
                        reg = <0x40000 0x10000>;
                        read-only;
                };

                partition@50000 {
                        label = "firmware";
                        reg = <0x50000 0xfb0000>;
                };
        };
};

查看Makefile里,配置相比其他设备,似乎少配了个存储大小,难道是按默认的4M?8M??

define Device/timecloud
  DTS := Timecloud
  DEVICE_TITLE := Thunder Timecloud
  DEVICE_PACKAGES := kmod-usb3
endef
TARGET_DEVICES += timecloud

加上一行:IMAGE_SIZE := 16064k。再次编译,发现已经正常生成squashfs-sysupgrade.bin了,也没报错了。如下:

diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk
index 8ba65a1..ee3c6dd 100644
--- a/target/linux/ramips/image/mt7621.mk
+++ b/target/linux/ramips/image/mt7621.mk
@@ -229,6 +229,7 @@ TARGET_DEVICES += sk-wb8
 
 define Device/timecloud
   DTS := Timecloud
+  IMAGE_SIZE := 16064k
   DEVICE_TITLE := Thunder Timecloud
   DEVICE_PACKAGES := kmod-usb3
 endef
image.png

推荐阅读更多精彩内容