设备树DTS 学习: 4-uboot 传递 dtb 给 内核

背景

得到 dtb 文件以后,我们需要想办法下载到 板子中,并给 Linux 内核使用。
(高级版本的 uboot也有了 自己使用设备树支持,我们这里不讨论 uboot 使用的设备树)

Linux 内核 有关规定

根据Documentation/arm/Booting的描述,我们需要提供 参数列表 或者 设备树镜像 地址。

4. Setup boot data
------------------

Existing boot loaders:      OPTIONAL, HIGHLY RECOMMENDED
New boot loaders:       MANDATORY

The boot loader must provide either a tagged list or a dtb image for
passing configuration data to the kernel.  The physical address of the
boot data is passed to the kernel in register r2.

Uboot 有关规定

根据上面的描述,uboot 传参有2种类型。
1)通过 tag 传递 参数列表 给 Linux 内核

通过 tag 给内核传参时,是只需要知道内核的地址就可以了。
因为uboot给内核传的参数一般是放到内存的某个地址,因为tag所占的内存比较小,所以一般都时放在内存的起始地址+0x100的位置
所以可以直接使用: bootm + 内核所在内存的地址 来运行内核

bootm <uImage_addr>

2)使用了设备树之后,一般我们是这样启动的

bootm <uImage_addr> <initrd_addr> <dtb_addr>

uImage_addr : 内核地址,需要是uImage 

initrd_addr : initrd的地址(如果不存在initrd,可以用 “-”代替),initrd是一个内存文件系统,因为在内核内启动之前,一般是文件系统还没加载上的。而有些东西必须要通过文件系统才能操作启动。所以必须要有一个过渡的文件系统。

dtb_addr    : 设备树地址

附录: uboot 的参考设定

以下是基于 以前接手过的一个项目中的一些参考信息。

# uboot 各部分 储存与内存 对应信息
...
tftp 0x100000 boot.bin; 
nand write 0x100000 0x0 0x300000;

tftp 0x1000000 logo.bin;
nand write 0x1000000 0x300000 0x200000;

tftp 0x2000000 uImage;
nand write 0x2000000 0x500000 0x500000;

tftp 0x3000000 zynq.dtb;
nand write 0x3000000 0xa00000 0x20000;

tftp 0x4000000 rootfs.img;
nand write.trimffs 0x4000000 0x2000000 0x8000000;


# 启动命令
uboot> print
以下是有关信息(节选)

boot_image=BOOT.bin

bootcmd=nand read 0x1000000 0x500000 0x500000;nand read 0x2000000 0xa00000 0x20000;bootm 0x1000000 - 0x2000000

posted @ 2020-01-19 12:23  schips  阅读(4205)  评论(0编辑  收藏  举报