mkimage使用与解包 |
您所在的位置:网站首页 › 海思固件解包制作工具 › mkimage使用与解包 |
在最初学习阶段,我们经常使用mkimage来制作uImage和ramdisk,实质是在被处理的文件前面加上64字节的头部。在到后来,我们可以将多个内核+多个设备树文件+ramdisk打包成一个 linux.itb 文件,用于一个镜像文件支持多平台启动,同样是使用 mkimage 工具来制作,不难猜测,它也是将这多个文件按照一定的方式进行组合,然后再在文件的开头加上64字节的头部。 有时候难免悲剧发生,发现自己ramdisk.img的源码找不到了,又懒重新制作,但是又需要对镜像进行修改,无奈之下我们需要解包(或者你想窥探一下别人镜像里的秘密),如何解包是本文的重点,mkimage工具的使用方法,一带而过。 mkimage 制作 uImage mkimage -A arm -O linux -T kernel -C none -a 30008000 -e 30008040 -n linux-3.0 -d zImage uImagemkimage 制作 ramdisk.img dd if=/dev/zero of=ramdisk.ext4 bs=1M count=0 seek=32 mkfs.ext4 -F -i 4096 ramdisk.ext4 -d ramdisk gzip --best -c ramdisk.ext4 > ramdisk.ext4.gz mkimage -n "ramdisk" -A arm -O linux -T ramdisk -C gzip -d ramdisk.ext4.gz ramdisk.imgmkimage 制作 itb 文件,它使用一个its文件来描述itb内部构造 mkimage -f linux_arm32.its linux.itb制作好linux.itb文件之后,在uboot阶段将其加载到内存中,使用bootm命令进行启动,例如: bootm 0x4a000000#ls1012afrwy;its 文件示例如下: /dts-v1/; / { description = "Image file for the QorIQ ARM 32b Linux Kernel"; #address-cells = ; images { kernel-v7 { description = "ARM32 Linux kernel"; data = /incbin/("../../build/linux/kernel/arm32/zImage.v7"); type = "kernel"; arch = "arm"; os = "linux"; compression = "none"; load = ; entry = ; }; kernel-v8 { description = "ARM32 Linux kernel"; data = /incbin/("../../build/linux/kernel/arm32/zImage.v8"); type = "kernel"; arch = "arm"; os = "linux"; compression = "none"; load = ; entry = ; }; initrd { description = "initrd for arm32"; data = /incbin/("../../packages/rfs/ramdiskrfs/ramdisk_rootfs_arm32.ext4.gz"); type = "ramdisk"; arch = "arm"; os = "linux"; compression = "none"; }; ls1021atwr-dtb { description = "Flattened Device Tree blob"; data = /incbin/("../../build/linux/kernel/arm32/ls1021a-twr.dtb"); type = "flat_dt"; arch = "arm"; compression = "none"; load = ; }; ls1043ardb-dtb { description = "Flattened Device Tree blob"; data = /incbin/("../../build/linux/kernel/arm32/fsl-ls1043a-rdb-sdk.dtb"); type = "flat_dt"; arch = "arm"; compression = "none"; load = ; }; }; configurations { ls1021atwr { description = "Boot Linux kernel"; kernel = "kernel-v7"; fdt = "ls1021atwr-dtb"; ramdisk = "initrd"; }; ls1043ardb { description = "Boot Linux kernel"; kernel = "kernel-v8"; fdt = "ls1043ardb-dtb"; ramdisk = "initrd"; }; }; };本文重点mkimage 解包 uImage ramdisk.img 只需要除去64字节头部,即可得到原始文件。 例如:dd if=ramdisk.img of=ramdisk.img.gz skip=64 bs=1 对于itb文件,由于它是多个文件,因此我们只去除头部是不够的,还需要进一步处理,不过呢,我们可以借助uboot中一个另外一个工具:dumpimage (2015之后的版本才有,位于tools目录) Usage: /tmp/dumpimage -l image -l ==> list image header information /tmp/dumpimage -i image -T type [-p position] [-o outfile] data_file -i ==> extract from the 'image' a specific 'data_file' -T ==> set image type to 'type' -p ==> 'position' (starting at 0) of the 'data_file' inside the 'image' /tmp/dumpimage -V ==> print version information and exit-T 这里始终指定为 flat_dt 即可。 -p 指的是its文件中的images索引,例如 kernel-v7 为0,kernel-v8 为1 例如,想解压出linux.itb中的 kernel-v7 dumpimage -i ./linux.itb -T flat_dt -p 0 zImage.v7
|
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |