mkimage与dumpimage使用
作者:互联网
0、说明
mkimage工具最常用在
- 打包linux内核,增加头部信息,制作uImage
- 基于its创建itb启动文件(即FIT image)
dumpimage用在
- 解析itb,抽取内部文件
1、mkimage制作uImage
2、mkimage制作itb文件
在使用petalinux制作ZYNQ嵌入式系统时,最终产生了如下文件
yangf@ubuntu:~/src/xilinx/zcu104/xilinx-zcu104-2021.1/images/linux$ ls
bl31.bin config pxelinux.cfg ramdisk.tar.gz rootfs.ext4 system.bit u-boot-dtb.elf zynqmp-qemu-arm.dtb
bl31.elf Image ramdisk.cpio.gz rootfs.cpio rootfs.jffs2 system.dtb u-boot.elf zynqmp-qemu-multiarch-arm.dtb
BOOT.BIN image.ub ramdisk.cpio.gz.u-boot rootfs.cpio.gz rootfs.manifest u-boot.bin vmlinux zynqmp-qemu-multiarch-pmu.dtb
boot.scr pmufw.elf ramdisk.manifest rootfs.cpio.gz.u-boot rootfs.tar.gz u-boot-dtb.bin zynqmp_fsbl.elf
yangf@ubuntu:~/src/xilinx/zcu104/xilinx-zcu104-2021.1/images/linux$
其中image.ub是用于启动的内核,他是怎么来的呢?就是使用mkimage通过一个its配置文件制作而成,命令如下:
mkimage -f o.its image.ub
其中o.its文件,本设计的内容如下:
/dts-v1/;
/ {
description = "U-Boot fitImage for PetaLinux yangf";
#address-cells = <1>;
images {
kernel-1 {
description = "Linux kernel";
data = /incbin/("image");
type = "kernel";
arch = "arm64";
os = "linux";
compression = "none";
load = <0x00080000>;
entry = <0x00080000>;
hash@1 {
algo = "sha256";
};
};
fdt-system-top.dtb {
description = "Flattened Device Tree blob";
data = /incbin/("fdt-system-top.dtb");
type = "flat_dt";
arch = "arm64";
compression = "none";
hash@1 {
algo = "sha256";
};
};
ramdisk-1 {
description = "petalinux-initramfs-image";
data = /incbin/("petalinux-initramfs-image");
type = "ramdisk";
arch = "arm64";
os = "linux";
compression = "none";
hash@1 {
algo = "sha256";
};
};
};
configurations {
default = "conf-system-top.dtb";
conf-system-top.dtb {
description = "1 Linux kernel, FDT blob, ramdisk";
kernel = "kernel-1";
fdt = "fdt-system-top.dtb";
ramdisk = "ramdisk-1";
hash@1 {
algo = "sha256";
};
};
};
};
其中its文件里面描述了用于打包itb文件的信息,包括文件类型,路径,压缩方式等。
执行打包后,输出的信息如下:
yangf@ubuntu:~/src/xilinx/kernel/output$ mkimage -f o.its image.ub
FIT description: U-Boot fitImage for PetaLinux yangf
Created: Sun Jul 18 05:51:34 2021
Image 0 (kernel-1)
Description: Linux kernel
Created: Sun Jul 18 05:51:34 2021
Type: Kernel Image
Compression: uncompressed
Data Size: 19827200 Bytes = 19362.50 KiB = 18.91 MiB
Architecture: AArch64
OS: Linux
Load Address: 0x00080000
Entry Point: 0x00080000
Hash algo: sha256
Hash value: 23c8dcec9b5989bed2ccb9baa15cfb8d8eae493173e227017d962ca035bec9a4
Image 1 (fdt-system-top.dtb)
Description: Flattened Device Tree blob
Created: Sun Jul 18 05:51:34 2021
Type: Flat Device Tree
Compression: uncompressed
Data Size: 30783 Bytes = 30.06 KiB = 0.03 MiB
Architecture: AArch64
Hash algo: sha256
Hash value: 4be503e20bab2f9485077eb2c2c88ac562aceb0b83adc44c14e22ee7f008a066
Image 2 (ramdisk-1)
Description: petalinux-initramfs-image
Created: Sun Jul 18 05:51:34 2021
Type: RAMDisk Image
Compression: uncompressed
Data Size: 5120964 Bytes = 5000.94 KiB = 4.88 MiB
Architecture: AArch64
OS: Linux
Load Address: unavailable
Entry Point: unavailable
Hash algo: sha256
Hash value: cc95b21f470fd79ff31a6c154bcfbab23f817bcdc6cda9633554b995d1dfde45
Default Configuration: 'conf-system-top.dtb'
Configuration 0 (conf-system-top.dtb)
Description: 1 Linux kernel, FDT blob, ramdisk
Kernel: kernel-1
Init Ramdisk: ramdisk-1
FDT: fdt-system-top.dtb
Hash algo: sha256
Hash value: unavailable
yangf@ubuntu:~/src/xilinx/kernel/output$
3、dumpimage使用
通过mkimage -f o.its image.ub打包了image.ub文件,同样可以将image.ub解压,抽取里面的独立文件。如抽取第2单元内容 Image 2 (ramdisk-1)
dumpimage -i ./image.ub -T flat_dt -p 2 petalinux-initramfs-image
标签:dumpimage,ramdisk,kernel,dtb,image,mkimage,system,使用,top 来源: https://blog.csdn.net/fengyuwuzu0519/article/details/118882821