1 mkimage
1.1 制作 uImage
Usage: ./mkimage [-T type] -l image
-l ==> list image header information
-T ==> parse image file as 'type'
-q ==> quiet
./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'
-R ==> set second image name to 'name'
-d ==> use image data from 'datafile'
-x ==> set XIP (execute in place)
-s ==> create an image with no data
-v ==> verbose
./mkimage [-D dtc_options] [-f fit-image.its|-f auto|-F] [-b <dtb> [-b <dtb>]] [-E] [-B size] [-i <ramdisk.cpio.gz>] fit-image
<dtb> 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
-E => place data outside of the FIT structure
-B => align size in hex for FIT structure and header
-b => append the device tree binary to the FIT
-t => update the timestamp in the FIT
...
-p => place external data at a static position
...
./mkimage -V ==> print version information and exit
Use '-T list' to see a list of available image types
Long options are available; read the man page for details
可以给 zImage 添加文件头成为 uImage 格式,也可以根据 its 文件将多个镜像转换为 uImage 格式并合并到一个镜像。
1.2 制作 boot.scr
// boot.cmd
env set bootargs 'root=/dev/mmcblk0p2 rootwait rw'
fatload mmc 0:1 0x8000 zImage
fatload mmc 0:1 0x103cdda8 zynq-zc702.dtb
bootz 0x8000 - 0x103cdda8
// 编译命令
./mkimage -C none -A arm -T script -d boot.cmd boot.scr
将 U-Boot 启动引导命令编译成启动引导文件。
2 mkenvimage
$ ./mkenvimage
Please specify the size of the environment partition.
mkenvimage [-h] [-r] [-b] [-p <byte>] -s <environment partition size> -o <output> <input file>
This tool takes a key=value input file (same as would a `printenv' show) and generates the corresponding environment image, ready to be flashed.
The input file is in format:
key1=value1
key2=value2
...
Empty lines are skipped, and lines with a # in the first
column are treated as comments (also skipped).
-r : the environment has multiple copies in flash
-b : the target is big endian (default is little endian)
-p <byte> : fill the image with <byte> bytes instead of 0xff bytes
-V : print version information and exit
If the input file is "-", data is read from standard input
可以将环境变量写在 txt 文件,通过 mkenvimage 编译成二进制文件作为 U-Boot 的外部环境变量。书写格式按照 key=value 配对。
// env.txt
bootargs=console=ttyS0,115200
scriptaddr=0x20000
script_size_f=0x40000
fdt_addr_r=0x1f00000