U-Boot tools

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

怦然心动如往昔

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值