如何直接修改image.ub |
您所在的位置:网站首页 › dtb反编译 › 如何直接修改image.ub |
文章目录
前言一、如何分解image.ub?1.查看原有image.ub里内容2.提取image.ub里的镜像
二、修改image.ub里内容1.修改设备树
三、合成image.ub总结
前言
笔者以帮客户解决问题为生,各种奇怪的案子都会接,有一天一个客户说zynqMP下使用博通phy有个奇怪的问题,不跑系统SDK测试正常、uboot下测试正常、Linux系统下不能收包,让我解决,但是不提供vivado工程,hdf也不行,只提供image.ub文件,不能再多了,好吧,硬着头皮接下这个案子 一、如何分解image.ub?image.ub是通过mkimage这个工具合成的,那么分解还是使用这个工具分解,mkimage是uboot里带的工具,编译完uboot可以找到这个工具,ubuntu下也可以通过apt安装 sudo apt-get install u-boot-tools -y 1.查看原有image.ub里内容通过运行命令mkimage -l 命令查询原image.ub包含了哪些内容 mkimage -l image.ub拿一个petalinux工程举例: server@server:~/$ mkimage -l image.ub FIT description: U-Boot fitImage for PetaLinux/4.14-xilinx-v2018.3+gitAUTOINC+eeab73d120/plnx-zynqmp Created: Fri May 28 15:26:34 2021 Image 0 (kernel@1) Description: Linux kernel Created: Fri May 28 15:26:34 2021 Type: Kernel Image Compression: gzip compressed Data Size: 7084583 Bytes = 6918.54 KiB = 6.76 MiB Architecture: AArch64 OS: Linux Load Address: 0x00080000 Entry Point: 0x00080000 Hash algo: sha1 Hash value: 821993b54a17d7278e01ecdd32d7af20941371fb Image 1 ([email protected]) Description: Flattened Device Tree blob Created: Fri May 28 15:26:34 2021 Type: Flat Device Tree Compression: uncompressed Data Size: 31746 Bytes = 31.00 KiB = 0.03 MiB Architecture: AArch64 Hash algo: sha1 Hash value: 741e90a6b586ae1848944393c5f07656f00dca9c Image 2 (ramdisk@1) Description: petalinux-user-image Created: Fri May 28 15:26:34 2021 Type: RAMDisk Image Compression: gzip compressed Data Size: 6506366 Bytes = 6353.87 KiB = 6.20 MiB Architecture: AArch64 OS: Linux Load Address: unavailable Entry Point: unavailable Hash algo: sha1 Hash value: 8e0f78ca2e6cd3d13cf3b554c164b72de6ab5fdd Default Configuration: '[email protected]' Configuration 0 ([email protected]) Description: 1 Linux kernel, FDT blob, ramdisk Kernel: kernel@1 Init Ramdisk: ramdisk@1 FDT: [email protected] Hash algo: sha1 Hash value: unavailable例子用可以看到image.ub里有三个镜像,分别是 Image 0 (kernel@1) 就是Linux内核 Image 1 ([email protected]) 就是设备树 Image 2 (ramdisk@1)就是根文件系统 2.提取image.ub里的镜像运行命令,提取Linux内核,-p 0 指第1个镜像 dumpimage -T flat_dt -p 0 image.ub -o Image运行命令,提取设备树,-p 1 指第2个镜像 dumpimage -T flat_dt -p 1 image.ub -o system.dtb同样的方法提取根文件系统 二、修改image.ub里内容 1.修改设备树可以反编译设备树文件,修改完成再编译回去 dtc -I dtb -O dts -o system.dts system.dtb 三、合成image.ub合成image.ub需要一个配置文件its,这个配置文件在petalinux编译时会生成,笔者从petalinux提取并修改了一个 /dts-v1/; / { description = "U-Boot fitImage for PetaLinux"; #address-cells = ; images { kernel@1 { description = "Linux kernel"; data = /incbin/("Image"); type = "kernel"; arch = "arm64"; os = "linux"; compression = "none"; load = ; entry = ; hash@1 { algo = "sha1"; }; }; [email protected] { description = "Flattened Device Tree blob"; data = /incbin/("system-top.dtb"); type = "flat_dt"; arch = "arm64"; compression = "none"; hash@1 { algo = "sha1"; }; }; ramdisk@1 { description = "petalinux-user-image"; data = /incbin/("rootfs.cpio.gz"); type = "ramdisk"; arch = "arm64"; os = "linux"; compression = "gzip"; hash@1 { algo = "sha1"; }; }; }; configurations { default = "[email protected]"; [email protected] { description = "1 Linux kernel, FDT blob, ramdisk"; kernel = "kernel@1"; fdt = "[email protected]"; ramdisk = "ramdisk@1"; hash@1 { algo = "sha1"; }; }; }; };通过下面命令合成: mkimage -f fitimage.its image.ub 总结通过直接修改image.ub免驱了再次编译petalinux的麻烦,特别是没有hdf或xsa的情况下。 **本人擅长解决FPGA、ZYNQ、ZYNQMP中各种疑难杂症,欢迎交流!** |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |