mkimage用法

平时我们经常使用mkimage做出可以被uboot引导的镜像文件。看看它的用法:

实例:

mkimage -A arm -O linux -T kernel -C none -a 0x40000000 -e 0x40000000 -n jqh -d out/default.zircon/s5p6818-boot-shim.bin uImage;

具体参数的解释可以参考如下描述,

Usage: mkimage -l image
          -l ==> list image header information
       mkimage [-x] -A arch -O os -T type -C comp -a addr -e ep -n name -d data_file[:data_file...] image
          -A ==> set architecture to 'arch'
          -O ==> set operating system to 'os'
          -T ==> set image type to 'type'
          -C ==> set compression type 'comp'
          -a ==> set load address to 'addr' (hex)
          -e ==> set entry point to 'ep' (hex)
          -n ==> set image name to 'name'
          -d ==> use image data from 'datafile'
          -x ==> set XIP (execute in place)
       mkimage [-D dtc_options] [-f fit-image.its|-f auto|-F] [-b [-b ]] [-i ] fit-image
           file is used with -f auto, it may occur multiple times.
          -D => set all options for device tree compiler
          -f => input filename for FIT source
          -i => input filename for ramdisk file
Signing / verified boot options: [-E] [-k keydir] [-K dtb] [ -c ] [-p addr] [-r] [-N engine]
          -E => place data outside of the FIT structure
          -k => set directory containing private keys
          -K => write public keys to this .dtb file
          -c => add comment in signature node
          -F => re-sign existing FIT image
          -p => place external data at a static position
          -r => mark keys used as 'required' in dtb
          -N => engine to use for signing (pkcs11)
       mkimage -V ==> print version information and exit
Use '-T list' to see a list of available image types

其它参数不做过多关心,我们这里主要理解一下这两个参数:

          -a ==> set load address to 'addr' (hex)  ——  镜像的加载地址
          -e ==> set entry point to 'ep' (hex)  ——  镜像的运行地址

首先要知道mkimage做出来的文件,会有64字节的描述信息在文件头部。而Uboot会将镜像文件加载到-a指定的地址,并跳到-e地址运行。

这里有几种情况:

1、tftp下载到内存的地址,和-a指定的地址相同,uboot不会对镜像做内存搬移。

2、tftp下载到内存的地址,和-a指定的地址不同,uboot会将下载地址的镜像文件(去掉64字节头部信息)搬移到-a指定的地址。

3、-a和-e参数地址相同时,理论上,需要tftp下载地址和-a地址不同,镜像做过搬移后,到-e地址运行是正常的。

4、-a和-e参数地址不同,固定为-a+0x40=-e,镜像不会搬移(头部64字节信息不会去掉),到-e地址运行才会正常。

你可能感兴趣的:(学习,uboot,mkimage)