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

| | | | |

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

相关推荐
红茶要加冰16 小时前
linux的例行性工作——计划任务
linux·运维·服务器
社交怪人16 小时前
【浮点数相除的余】信息学奥赛一本通C语言解法(题号1029)
c语言·开发语言
byxdaz16 小时前
Linux中查看硬件信息
linux·运维
辣椒思密达16 小时前
Python爬虫中如何正确配置住宅IP代理?新手避坑指南
c语言·python
darkdragonking16 小时前
由一次构建 OpenEuler 22.03 dnf源所了解到的
linux·运维·服务器
米高梅狮子16 小时前
Ceph 分布式存储 部署
linux·运维·数据库·分布式·ceph·docker·华为云
曦夜日长17 小时前
Linux系统篇,开发工具(五):git的基本使用和浅层认识
linux·运维·服务器
Harm灬小海17 小时前
【云计算学习之路】学习Centos7系统-ROOT密码重置方法
linux·运维·服务器·学习·云计算
weixin_4536395917 小时前
Docker Redis 本地能 Ping 通但 6379 端口连不上?排查记录与解决
linux·redis
番茄灭世神17 小时前
PN学堂GD32教程第21篇——WiFiIOT
c语言·stm32·单片机·嵌入式·gd32