rockchip 平台 linux FIT 打包格式介绍

1 基础介绍

FIT(flattened image tree)是U-Boot⽀持的⼀种新固件类型的引导⽅案,⽀持任意多个image打包和校

验。FIT 使⽤ its (image source file) ⽂件描述image信息,最后通过mkimage⼯具⽣成 itb (flattened image

tree blob) 镜像。its⽂件使⽤ DTS 的语法规则,⾮常灵活,可以直接使⽤libfdt 库和相关⼯具。

FIT 是U-Boot默认⽀持且主推的固件格式,SPL和U-Boot阶段都⽀持对FIT格式的固件引导。更多信息请

参考:

因为官⽅的FIT功能⽆法满⾜实际产品需求,所以RK平台对FIT进⾏了适配和优化。所以FIT⽅案中必须

使⽤RK U-Boot编译⽣的mkimage⼯具,不能使⽤PC⾃带的mkimage。

2 范例介绍

如下以u-boot.its和u-boot.itb作为范例进⾏介绍。

/images :静态定义了所有的资源,相当于⼀个 dtsi⽂件;

/configurations :每个 config 节点都描述了⼀套可启动的配置,相当于⼀个板级dts⽂件。

default = :指明默认启⽤的config;

./doc/uImage.FIT/

/dts-v1/;

/ {

description = "Simple image with OP-TEE support";

#address-cells = <1>;

images {

uboot {

description = "U-Boot";

data = /incbin/("./u-boot-nodtb.bin");

type = "standalone";

os = "U-Boot";

arch = "arm";

compression = "none";

使⽤mkimage⼯具和its⽂件可以⽣成itb⽂件:

fdtdump 命令可以查看 itb⽂件内容:

load = <0x00400000>;

hash {

algo = "sha256";

};

};

optee {

description = "OP-TEE";

data = /incbin/("./tee.bin");

type = "firmware";

arch = "arm";

os = "op-tee";

compression = "none";

load = <0x8400000>;

entry = <0x8400000>;

hash {

algo = "sha256";

};

};

fdt {

description = "U-Boot dtb";

data = /incbin/("./u-boot.dtb");

type = "flat_dt";

compression = "none";

hash {

algo = "sha256";

};

};

};

// configurations 节点下可以定义任意多个不同的conf节点,但实际产品⽅案上我们只需要⼀个

conf即可。

configurations {

default = "conf";

conf {

description = "Rockchip armv7 with OP-TEE";

rollback-index = <0x0>;

firmware = "optee";

loadables = "uboot";

fdt = "fdt";

signature {

algo = "sha256,rsa2048";

padding = "pss";

key-name-hint = "dev";

sign-images = "fdt", "firmware", "loadables";

};

};

};

};

mkimage + dtc

u-boot.its\] + \[images\] =========\> \[u-boot.itb

cjh@ubuntu:~/uboot-nextdev/u-boot$ fdtdump fit/u-boot.itb | less

/dts-v1/;

// magic: 0xd00dfeed

// totalsize: 0x600 (1536)

// off_dt_struct: 0x48

// off_dt_strings: 0x48c

// off_mem_rsvmap: 0x28

// version: 17

// last_comp_version: 16

// boot_cpuid_phys: 0x0

// size_dt_strings: 0xc3

// size_dt_struct: 0x444

/memreserve/ 7f34d3411000 600;

/ {

version = <0x00000001>; // 新增固件版本号

totalsize = <0x000bb600>; // 新增字段描述整个itb⽂件的⼤小

timestamp = <0x5ecb3553>; // 新增当前固件⽣成时刻的时间戳

description = "Simple image with OP-TEE support";

#address-cells = <0x00000001>;

images {

uboot {

data-size = <0x0007ed54>; // 新增字段描述固件⼤小

data-position = <0x00000a00>; // 新增字段描述固件偏移

description = "U-Boot";

type = "standalone";

os = "U-Boot";

arch = "arm";

compression = "none";

load = <0x00400000>;

hash {

// 新增固件的sha256校验和

value = <0xeda8cd52 0x8f058118 0x00000003 0x35360000 0x6f707465

0x0000009f 0x00000091 0x00000000>;

algo = "sha256";

};

};

optee {

data-size = <0x0003a058>;

data-position = <0x0007f800>;

description = "OP-TEE";

type = "firmware";

arch = "arm";

os = "op-tee";

compression = "none";

load = <0x08400000>;

entry = <0x08400000>;

hash {

value = <0xa569b7fc 0x2450ed39 0x00000003 0x35360000 0x66647400

0x00001686 0x000b9a00 0x552d426f>;

algo = "sha256";

};

};

fdt {

3 itb结构

itb本质是fdt_blob + images的⽂件集合,有如下两种打包⽅式,RK平台⽅案采⽤结构2⽅式。

data-size = <0x00001686>;

data-position = <0x000b9a00>;

description = "U-Boot dtb";

type = "flat_dt";

compression = "none";

hash {

value = <0x0f718794 0x78ece7b2 0x00000003 0x35360000 0x00000001

0x6e730000 0x636f6e66 0x00000000>;

algo = "sha256";

};

};

};

configurations {

default = "conf";

conf {

description = "Rockchip armv7 with OP-TEE";

rollback-index = <0x00000001>; // 固件防回滚版本号,没有⼿动指定时默认为0

firmware = "optee";

loadables = "uboot";

fdt = "fdt";

signature {

algo = "sha256,rsa2048";

padding = "pss";

key-name-hint = "dev";

sign-images = "fdt", "firmware", "loadables";

};

};

};

};

fdt blob

|-----------------------------------|

| |------| |------| |------| |

| | img0 | | img1 | | img2 | | 结构1:image在fdt_blob内,即:itb = fdt_blob(含

img)

| |------| |------| |------| |

|-----------------------------------|

|--------------|------|------|------|

| | | | |

| fdt blob | img0 | img1 | img2 | 结构2:image在fdt_blob外,即itb = fdt_blob +

img

| | | | |

|--------------|------|------|------|

相关推荐
XH华4 小时前
C语言第十一章内存在数据中的存储
c语言·开发语言
3壹7 小时前
单链表:数据结构中的高效指针艺术
c语言·开发语言·数据结构
deeper_wind8 小时前
k8s-容器化部署论坛和商城服务(小白的“升级打怪”成长之路)
linux·运维·容器·kubernetes
勇往直前plus8 小时前
VMware centos磁盘容量扩容教程
linux·运维·centos
knd_max9 小时前
C语言:内存函数
c语言
猫猫的小茶馆9 小时前
【STM32】CubeMX(十二):FreeRTOS消息队列
驱动开发·stm32·单片机·嵌入式硬件·mcu·智能硬件
政安晨9 小时前
Ubuntu 服务器无法 ping 通网站域名的问题解决备忘 ——通常与网络配置有关(DNS解析)
linux·运维·服务器·ubuntu·ping·esp32编译服务器·dns域名解析
YLCHUP10 小时前
【联通分量】题解:P13823 「Diligent-OI R2 C」所谓伊人_连通分量_最短路_01bfs_图论_C++算法竞赛
c语言·数据结构·c++·算法·图论·广度优先·图搜索算法
路溪非溪11 小时前
嵌入式Linux驱动开发杂项总结
linux·运维·驱动开发
特立独行的猫a11 小时前
C/C++三方库移植到HarmonyOS平台详细教程
c语言·c++·harmonyos·napi·三方库·aki