美文网首页
解包fenix生成的烧录包

解包fenix生成的烧录包

作者: 叶迎宪 | 来源:发表于2024-09-04 17:56 被阅读0次

直接用 linux-amlogic-toolkit 解包会报错

Converting system.PARTITION to system.img...
Cannot open input file output/image/system.PARTITION
Mounting system image...
mount: /home/test/linux-amlogic-toolkit-master/output/system: wrong fs type, bad option, bad superblock 
on /dev/loop0, missing codepage or helper program, or other error.

Unpacking boot...
cp: cannot stat 'output/image/boot.PARTITION': No such file or directory
boot.img: No such file or directory

解不开boot分区和根文件系统。对比一下 fenix 和 buildroot 在执行 aml_image_v2_packer 时的conf文件有什么不同。下面是fenix的

[LIST_NORMAL]
# Images don't need verfiy
file="u-boot.bin"               main_type="USB"         sub_type="DDR"
file="u-boot.bin"               main_type="USB"         sub_type="UBOOT"
file="u-boot.bin.sd.bin"    main_type="UBOOT"       sub_type="aml_sdc_burn"
file="platform.conf"        main_type="conf"        sub_type="platform"
file="aml_sdc_burn.ini"     main_type="ini"         sub_type="aml_sdc_burn"
file="kvim.dtb"             main_type="dtb"         sub_type="meson1"

[LIST_VERIFY]
# Images need verify
file="logo.img"            main_type="PARTITION"    sub_type="logo"
#file="ramdisk.img"         main_type="PARTITION"    sub_type="ramdisk"
file="rootfs.img"          main_type="PARTITION"    sub_type="rootfs"
file="u-boot.bin"          main_type="PARTITION"    sub_type="bootloader"
file="kvim.dtb"            main_type="PARTITION"    sub_type="_aml_dtb"

这是buildroot的

[LIST_NORMAL]
#partition images, don't need verfiy
file="u-boot.bin"   main_type= "USB"            sub_type="DDR"
file="u-boot.bin"   main_type= "USB"            sub_type="UBOOT"
file="u-boot.bin.sd.bin"    main_type="UBOOT"           sub_type="aml_sdc_burn"
file="platform.conf"        main_type= "conf"           sub_type="platform"
file="aml_sdc_burn.ini"     main_type="ini"             sub_type="aml_sdc_burn"
file="dtb.img"              main_type="dtb"             sub_type="meson1"

[LIST_VERIFY]
#partition images with verify
file="boot.img"             main_type="PARTITION"       sub_type="boot"
file="recovery.img"         main_type="PARTITION"       sub_type="recovery"
file="rootfs.ext2.img2simg"           main_type="PARTITION"       sub_type="system"
file="u-boot.bin"           main_type="PARTITION"       sub_type="bootloader"
file="dtb.img"              main_type="PARTITION"       sub_type="_aml_dtb"
file="logo.img"             main_type="PARTITION"       sub_type="logo"

再看一下 linux-amlogic-toolkit 的unpack脚本

            echo "Unpacking image $1..."
            bin/aml_image_v2_packer -d $1 output/image
       
            echo "Converting system.PARTITION to system.img..."
            bin/simg2img output/image/system.PARTITION output/image/system.img

            echo "Mounting system image..."
            sudo mount -t ext4 -o loop,rw output/image/system.img output/system

            echo "Unpacking logo..."
            bin/logo_img_packer -d output/image/logo.PARTITION output/logo
                          
            echo "Unpacking boot..."
            cp output/image/boot.PARTITION output/boot/boot.img
            cd output/boot
            ../../bin/abootimg -x boot.img
            cd ../..
            rm -f output/boot/boot.img

由于fenix镜像中没有system分区,因此simg2img那一步就出错了。而直接使用simg2img解rootfs.PARTITION也会报错 Invalid sparse file format at header magi。看了一下fenix的代码,生成 rootfs.img 位于 config/functions/build-rootfs

    if [ "$INSTALL_TYPE" == "EMMC" ]; then
        info_msg "Creating eMMC rootfs image..."
        rm -rf ${BUILD_IMAGES}/rootfs.img
        dd if=/dev/zero of=$BUILD_IMAGES/rootfs.img bs=1M count=0 seek=$rootfs_image_size
        mkfs.ext4 $EXT4_MKOPTS $BUILD_IMAGES/rootfs.img
        rm -rf $ROOTFS && install -d $ROOTFS
        mount -o loop $BUILD_IMAGES/rootfs.img $ROOTFS
        local rootfs_uuid="UUID=$(blkid -s UUID -o value $BUILD_IMAGES/rootfs.img)"

直接是ext4 image。而 buildroot 的生成脚本在 host-aml_img_packer_new-201602/aml_upgrade_pkg_gen.sh,调用img2simg,将 ext4 image 转成 sparse image,然后再调用 aml_image_v2_packer_new 打包的。所以,在 aml_image_v2_packer 解包后,直接挂载 rootfs.PARTITION 就行 mount -v -o loop,rw output/image/rootfs.PARTITION output/system/

而重新打包,先调用 sync,确保挂载的 output/system/ 目录下数据已写回硬盘,然后使用打包命令
./bin/aml_image_v2_packer -r output/image/image.cfg output/image out.img

相关文章

网友评论

      本文标题:解包fenix生成的烧录包

      本文链接:https://www.haomeiwen.com/subject/yrflljtx.html