Openwrt編譯:root.squashfs-64k is too big (Max=6488064 , Current=xxxx)

搞了一段時間openwrt編譯,由於之前沒有路由器的經驗,很蛋疼,各種問題。

Question

折騰好幾天,終於把環境配好了,包括軟件源、依賴庫、版本,以及make menuconfig選擇打到固件裏面的package。最後編譯的時候,卻出現了root.squashfs-64k is too big的問題。心中萬馬奔騰,頓時崩潰了!

部分日誌摘抄如下:

......此處省略很長很長日誌......

LZMA 4.65 : Igor Pavlov : Public domain : 2009-02-03
mkimage -A mips -O linux -T multi -a 0x80060000 -C lzma  -e 0x80060000 -n 'MIPS OpenWrt Linux-3.3.8' -d /home/huqian/qca/qsdk/build_dir/linux-ar71xx_generic/tmp/vmlinux-ap136.bin.lzma /home/huqian/qca/qsdk/build_dir/linux-ar71xx_generic/tmp/vmlinux-ap136.uImage
Image Name:   MIPS OpenWrt Linux-3.3.8
Created:      Tue Jan  5 23:21:28 2016
Image Type:   MIPS Linux Multi-File Image (lzma compressed)
Data Size:    1071725 Bytes = 1046.61 kB = 1.02 MB
Load Address: 80060000
Entry Point:  80060000
Contents:
   Image 0: 1071717 Bytes = 1046.60 kB = 1.02 MB
if [ `stat -c%s "/home/huqian/qca/qsdk/build_dir/linux-ar71xx_generic/root.squashfs-64k"` -gt 6488064 ]; then echo "Error: /home/huqian/qca/qsdk/build_dir/linux-ar71xx_generic/root.squashfs-64k is too big (Max=6488064 Current=`stat -c%s "/home/huqian/qca/qsdk/build_dir/linux-ar71xx_generic/root.squashfs-64k"`)"; exit 1; else if [ `stat -c%s /home/huqian/qca/qsdk/build_dir/linux-ar71xx_generic/tmp/vmlinux-ap136.uImage` -gt 1507328 ]; then echo "Error: /home/huqian/qca/qsdk/build_dir/linux-ar71xx_generic/tmp/vmlinux-ap136.uImage is too big (Max=1507328 Current=`stat -c%s "/home/huqian/qca/qsdk/build_dir/linux-ar71xx_generic/tmp/vmlinux-ap136.uImage"`)"; exit 1; else ( dd if=/home/huqian/qca/qsdk/build_dir/linux-ar71xx_generic/root.squashfs-64k bs=6488064 conv=sync; dd if=/home/huqian/qca/qsdk/build_dir/linux-ar71xx_generic/tmp/vmlinux-ap136.uImage ) > /home/huqian/qca/qsdk/bin/ar71xx/openwrt-ar71xx-generic-ap136-squashfs-sysupgrade.bin; fi; fi
Error: /home/huqian/qca/qsdk/build_dir/linux-ar71xx_generic/root.squashfs-64k is too big (Max=6488064 Current=8257540)
make[5]: *** [install] Error 1
make[5]: Leaving directory `/home/huqian/qca/qsdk/target/linux/ar71xx/image'
make[4]: *** [install] Error 2
make[4]: Leaving directory `/home/huqian/qca/qsdk/target/linux/ar71xx'
make[3]: *** [install] Error 2
make[3]: Leaving directory `/home/huqian/qca/qsdk/target/linux'
make[2]: *** [target/linux/install] Error 2
make[2]: Leaving directory `/home/huqian/qca/qsdk'
make[1]: *** [/home/huqian/qca/qsdk/staging_dir/target-mips_r2_uClibc-0.9.33.2/stamp/.target_install] Error 2
make[1]: Leaving directory `/home/huqian/qca/qsdk'
make: *** [world] Error 2

Solution

然而問題終究還是要解決的。又經過一段累得吐血的折騰,大概摸索出了一些思路。

上面的日誌中,注意第14行的Error提示信息:

Error: /home/huqian/qca/qsdk/build_dir/linux-ar71xx_generic/root.squashfs-64k is too big (Max=6488064 Current=8257540)

意思是說,root.squashfs-64k最大爲6488064,但是當前已經達到了8257540B。

另外,第13行,打印出了產生Error的命令,可以從中分析出Error發生的場景,例如在生成哪個硬件型號的固件時出現問題。

文件大小限制(Max=6488064)是在target/linux/ar71xx/image/Makefile中,下面是一部分配置:

#$(eval $(call SingleProfile,AthLzma,$(fs_64k),AP135,ap135,AP135,ttyS0,115200,$$(ap135_mtdlayout),1507328,14876672,RKuImage))
#$(eval $(call SingleProfile,AthLzma,$(fs_64k),AP135DUAL,ap135-dual,AP135-DUAL,ttyS0,115200,$$(ap135dual_mtdlayout),1507328,14876672,RKuImage))
#$(eval $(call SingleProfile,AthLzma,$(fs_128k),AP135NAND,ap135-nand,AP135-DUAL,ttyS0,115200,$$(ap135nand_mtdlayout),12582912,31457280,RKuImage))
#$(eval $(call SingleProfile,AthLzma,$(fs_64k),AP136,ap136,AP136,ttyS0,115200,$$(ap136_mtdlayout),1507328,6488064,RKuImage))
#$(eval $(call SingleProfile,AthLzma,$(fs_64k),AP143_8M,ap143-8M,AP143,ttyS0,115200,$$(ap143_mtdlayout_8M),1441792,6488064,RKuImage))
$(eval $(call SingleProfile,AthLzma,$(fs_64k),AP143_16M,ap143-16M,AP143,ttyS0,115200,$$(ap143_mtdlayout_16M),1507328,14876672,RKuImage))
#$(eval $(call SingleProfile,AthLzma,$(fs_64k),AP147_8M,ap147-8M,AP147,ttyS0,115200,$$(ap147_mtdlayout_8M),1441792,6488064,RKuImage))
$(eval $(call SingleProfile,AthLzma,$(fs_64k),AP147_16M,ap147-16M,AP147,ttyS0,115200,$$(ap147_mtdlayout_16M),1507328,14876672,RKuImage))
#$(eval $(call SingleProfile,AthLzma,$(fs_64k),AP151_8M,ap151-8M,AP151,ttyS0,115200,$$(ap151_mtdlayout_8M),1507328,6488064,RKuImage))
#$(eval $(call SingleProfile,AthLzma,$(fs_64k),AP151_16M,ap151-16M,AP151,ttyS0,115200,$$(ap151_mtdlayout_16M),1507328,14876672,RKuImage))
#$(eval $(call SingleProfile,AthLzma,$(fs_64k),AP152_8M,ap152-8M,AP152,ttyS0,115200,$$(ap152_mtdlayout_8M),1507328,6488064,RKuImage))
#$(eval $(call SingleProfile,AthLzma,$(fs_64k),AP152_16M,ap152-16M,AP152,ttyS0,115200,$$(ap152_mtdlayout_16M),1507328,14876672,RKuImage))
#$(eval $(call SingleProfile,AthLzma,$(fs_64k),RUBBERDUCK,rubberduck,RUBBERDUCK,ttyS0,115200,$$(rubberduck_mtdlayout),1507328,14876672,RKuImage))
#$(eval $(call SingleProfile,AthLzma,$(fs_64k),CAP4200AG,cap4200ag,CAP4200AG,ttyS0,115200,$$(cap4200ag_mtdlayout),1572864,12386304,KRuImage))

解決辦法迴歸到了Makefile文件,需要修改編譯選項。

有兩個地方需要變動:

  • Makefile當中的類似配置條目非常多,這主要是針對不同硬件型號的板子,編譯出不同的固件。爲了減少編譯固件中的各類問題,建議把除了目標板子外的其他條目全部註釋掉。例如,我需要的ap143和ap147的文件,因而,只保留了ap143-16M和ap147-16M這兩條(第6行和第8行,其他均註釋掉)。

  • Max=6488064即出自於該文件,其中的限制6488064即是某個條目的配置。搜索該數字,或者直接找你的硬件對應的型號,去修改該參數。即可解決root.squashfs-64k is too big的問題,當然,繼續編譯的時候,你可能還會發現其他各種文件too big的問題。類似方法解決。

Final

編譯openwrt其實並不麻煩,但如果你對系統定製程度較高,需要安裝較多的軟件,則相當棘手。

至此,也僅僅是解決了固件的問題。

接下來,需要編譯鏡像,添加自己的各種程序,然後讓它們work!

這纔是更令人崩潰的!

任重道遠!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章