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

| | | | |

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

相关推荐
金色熊族5 分钟前
qt5.15.9编译qt-creator7.0.2源码
linux·qt
Rabitebla28 分钟前
【Linux】文件篇(五):手撕简易 FILE——模拟实现 C 标准 I/O 缓冲机制
linux·服务器·c语言·笔记·学习·ubuntu
蜗牛一步步往上爬1 小时前
第十章 使用编辑器
linux
无足鸟ICT5 小时前
【RHCA+】swap和物理内存
linux
老花眼猫9 小时前
C语言绘图方法:(14)长方体旋转
c语言·经验分享·青少年编程·课程设计
Huangjin007_10 小时前
【Linux 系统篇(四十一)】线程(二):线程的优缺点、资源共享与上下文切换
linux·运维·服务器
嵌入式 Linux手记11 小时前
嵌入式面试都考的置位清位:位运算四件套
linux·c语言·驱动开发·面试·职场和发展·嵌入式
Rabitebla11 小时前
【Linux】文件篇(六):Shell 实战——从系统调用到命令行重定向
linux·服务器·c++·笔记·学习
dingdingfish12 小时前
TLPI 第57章 读书笔记:Sockets: UNIX Domain
linux·socket·domain·sendto·recvfrom·tlpi·socketpair
戊本菌21 小时前
进程(三)runqueue 与 Linux 的 O(1) 调度
linux·运维·服务器