Rockchip rk3588 U-Boot详解 (二)
1.1 DM
DM (Driver Model) 是 U-Boot 标准的 device-driver 开发模型,跟 kernel 的 device-driver 模型⾮常类似。
v2017版本也遵循 DM 框架开发各功能模块。建议读者先阅读DM⽂档,了解DM架构原理和实现。
README:
/doc/driver-model/README.txt
Terminology
-----------
Uclass - a group of devices which operate in the same way. A uclass provides
a way of accessing individual devices within the group, but always
using the same interface. For example a GPIO uclass provides
operations for get/set value. An I2C uclass may have 10 I2C ports,
4 with one driver, and 6 with another.
Driver - some code which talks to a peripheral and presents a higher-level
interface to it.
Device - an instance of a driver, tied to a particular port or peripheral.
简要概括:
- uclass: 设备驱动模型
- driver:驱动
- device:设备
核心代码:
./driver/core
1.2 Security
U-Boot在ARM TrustZone的安全体系中属于Non-Secure World, 无法直接访问任何安全的资源(如:安全memory、安全otp、efuse...),需要借助trust间接访问。RK平台上U-boot的CPU运行模式:
32位平台:Non-Secure PL2
64位平台:EL2(Always be Non-Secure)
1.3 Boot-order
RK平台根据前级Loader代码是否开源,目前有两套启动方式:
// 前级loader鼻渊
BOOTROM = > ddr bin = > Miniloader = > TRUST = > U-Boot = > KERNEL
// 前级loader开源
BOOTROM = > TPL(Tiny Program Loader) = > SPL(Secondary Program Loader) = > TRUST = > U-Boot = > KERNEL
TPL相当于ddr bin,SPL相当于miniloader。TPL + SPL 的组合实现了跟RK闭源ddr.bin+miniloader一致的功能,可相互替换。
1.4 Driver-probe
U-boot虽然引入了device-device开发模型,但初始化阶段不会像kernel那样自动发起已注册device-driver的probe。driver的probe必须由用户主动调用发起。接口如下
int uclass_get_device(enum uclass_id id, int index, struct udevice **devp);
int uclass_get_device_by_name(enum uclass_id id, const char *name,
struct udevice **devp);
int uclass_get_device_by_seq(enum uclass_id id, int seq, struct udevice **devp);
int uclass_get_device_by_of_offset(enum uclass_id id, int node, struct udevice
**devp);
int uclass_get_device_by_ofnode(enum uclass_id id, ofnode node, struct udevice
**devp);
int uclass_get_device_by_phandle_id(enum uclass_id id,
int phandle_id, struct udevice **devp);
int uclass_get_device_by_phandle(enum uclass_id id,
struct udevice *parent, struct udevice **devp);
int uclass_get_device_by_driver(enum uclass_id id,
const struct driver *drv, struct udevice **devp);
int uclass_get_device_tail(struct udevice *dev, int ret, struct udevice **devp);
......
上述接口的核心调用
1.5 Shell
U-Boot的Shell叫CLI(cmdline line interface),即命令行模式,用户可以根据自己需求自定义CMD,CMD除了通过Shell调用,还能通过run_command()和run_command_list()以代码的形式调用
int run_command(const char *cmd, int flag)
int run_command_list(const char *cmd, int len, int flag)
1.6 Boot-Command
U-Boot最终通过CONFIG_BOOTCOMMAND定义的启动命令引导kernel。在执行CONFIG_BOOTCMD之前还会执行CONFIG_PREBOOT预启动命令,通常这个命令定义为空
1.7 TPL/SPL/U-Boot-proper
U-Boot通过使用不同的编译条件可以用同一套代码获取三种不同功能的Loader:TPL/SPL/U-Boot-proper
- TPL: 运行在sram中,负责完成ddr初始化;
- SPL:运行在ddr中,负责完成系统的lowlevel初始化,后级固件加载(trust.img和uboot.img)
- U-Boot proper: 运行在ddr中,即我们通常所说的 U-Boot,它负责引导kernel;
启动流程:
BOOTROM => TPL(ddr bin) => SPL(miniloader) => TRUST => U-BOOT => KERNEL
1.8 Build-Output
U-Boot编译成功后会在根目录下生成一些重要文件(支持TPL/SPL编译时才有TPL/SPL的生成文件)
// U-Boot阶段
./u-boot.map //MAP表文件
./u-boot.sym //SYMBOL表文件
./u-boot //ELF文件,类同内核的vmlinux(重要!)
// SPL阶段
./spl/u-boot-spl.map //MAP表文件
./spl/u-boot-spl.sym //SYMBOL表文件
./spl/u-boot-spl // ELF文件,类同内核的vmlinux(重要)
./spl/u-boot-spl.dtb //spl自己的dtb文件
./spl/u-boot-spl.bin //可执行二进制文件,会被打包成loader用于烧写
// TPL阶段
./tpl/u-boot-tpl.map // MAP表文件
./tpl/u-boot-tpl.sym // SYMBOL表文件
./tpl/u-boot-tpl //ELF文件,类同内核的vmlinux(重要!)
./tpl/u-boot-tpl.dtb //tpl自己的dtb文件
./tpl/u-boot-tpl.bin // 可执行二进制文件,会被打包成loader用于烧写
1.9 Environment-Variables
ENV(Environment-Variables)是U-Boot支持的一种全局数据管理和传递方式,原理是构建一张HASH映射表,把用户的数据以“键值-数据”作为表项进行管理。
EVN通常用于定义平台配置参数:固件加载地址,网络配置(ipaddr、serverip)、bootcmd、bootargs等,用户可以在命令行下使用printenv命令打印出来
- ⽤⼾可选择是否把ENV数据保存到本地存储上
- ENV数据仅限于U-Boot使⽤,⽆法直接传递给内核、内核也⽆法直接解析
- ⽤⼾层可以通过U-Boot提供的fw_printenv⼯具访问ENV数据
RK 平台上 ENV 数据的存储地址和⼤小定义如下(单位:字节):
if ARCH_ROCKCHIP
config ENV_OFFSET
hex
depends on !ENV_IS_IN_UBI
depends on !ENV_IS_NOWHERE
default 0x3f8000
help
Offset from the start of the device (or partition)
config ENV_SIZE
hex
default 0x8000
help
Size of the environment storage area
endif
审核编辑 黄宇
-
Rockchip
+关注
关注
0文章
73浏览量
18675 -
RK3588
+关注
关注
7文章
349浏览量
4632
发布评论请先 登录
相关推荐
瑞芯微RK3588开发板RK3588 EVB和RK3588S EVB解读
![瑞芯微<b class='flag-5'>RK3588</b>开发板<b class='flag-5'>RK3588</b> EVB和<b class='flag-5'>RK3588</b>S EVB解读](https://file.elecfans.com/web2/M00/6B/85/poYBAGMsFZeAXB_6AAM2YY_fpBY992.png)
Rockchip rk3588 U-Boot详解(一)
![<b class='flag-5'>Rockchip</b> <b class='flag-5'>rk3588</b> <b class='flag-5'>U-Boot</b><b class='flag-5'>详解</b>(一)](https://file1.elecfans.com/web2/M00/89/8A/wKgZomSHDY-AGUqaAAMmzJbPIyU935.png)
有什么方法可以去修改RK3588默认的串口波特率吗
通过以下代码修改RK3588的默认串口波特率
如何在rk3588j上使用uboot命令行测试pwm驱动呢?
Banana Pi BPI-W3 RK3588开发板基本使用文档
【LGA封装RK3588核心板】基于RK3588,小而强大的ArmSom-W3 CORE BOARD
![【LGA封装<b class='flag-5'>RK3588</b>核心板】基于<b class='flag-5'>RK3588</b>,小而强大的ArmSom-W3 CORE BOARD](https://file.elecfans.com/web2/M00/AF/5E/pYYBAGSiee-AUV7XAAb4QgOEBIU728.png)
评论