設備樹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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM