mkimage 打包镜像
1 前言
应用场景是从 uboot 拉起某个 rtos。由于需要同时用 TFTP 加载几个文件才能正常启动运行,这样的加载方式释放给客户容易出错,本地开发也比较麻烦,因为每次编译生成的文件都有改动,需要重新加载。
2 解决方法
使用 uboot 的工具 mkimage 来实现多个文件的打包功能,并可以加入文件的校验。加载操作过程只需要传输一个打包文件,然后在 uboot 里输入启动命令即可。
3 实现步骤
- 搭建正常使用 mkimage 的环境
在 Linux 环境下很简单安装对应的工具就可以使用
在 Windows 环境下需要安装 msys2 的环境,然后才可以正常使用 - 使用命令编译生成打包文件
mkimage -f cmd.its cmd.itb
- cmd.its 的语法规则 github 这个链接里有使用方法的示例
- 我使用的 cmd.its。在 uboot 中将打包好的文件加载到 0x90000000 之后,运行命令 bootm start 0x90000000 && source 0x90000000:run
/dts-v1/;
/ {
description = "Configuration to load a ROTS";
#address-cells = <1>;
images {
vsc {
description = "vsc binary";
data = /incbin/("./vsc.bin");
type = "kernel";
arch = "arm64";
os = "linux";
compression = "none";
load = <0xa02e0000>;
entry = <0xa02e0000>;
hash-1 {
algo = "md5";
};
};
configbin {
description = "Config.bin";
data = /incbin/("./config.bin");
type = "kernel";
arch = "arm";
compression = "none";
load = <0xaf900000>;
hash-1 {
algo = "md5";
};
};
APP {
description = "VM...";
data = /incbin/("./APP.bin");
type = "kernel";
arch = "arm";
os = "linux";
compression = "none";
load = <0xb0000000>;
hash-1 {
algo = "md5";
};
};
APP2 {
description = "VM...";
data = /incbin/("./APP2.bin");
type = "kernel";
arch = "arm";
os = "linux";
compression = "none";
load = <0xC0000000>;
hash-1 {
algo = "md5";
};
};
run {
description = "src...";
data = "dcache off && go 0xa02e0000";
type = "script";
};
};
configurations {
default = "config-3";
config-3 {
description = "RTOS loader";
kernel = "vsc";
loadables = "APP", "configbin", "APP2", "vsc";
script = "boot";
};
};
};
备注:bootm start 0x90000000 命令执行时,会自动将 loadables 里面的内容加载到指定的内存里。source 0x90000000:run 会自定义的 uboot shell 命令进行启动。