歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> U-Boot中fdt命令的使用

U-Boot中fdt命令的使用

日期:2017/3/1 10:24:29   编辑:Linux編程

依linux community的要求,從linux-3.5後,新提交的code必須對device tree進行支持。下面介紹如何使u-boot支持device tree,以及fdt命令的使用。

1. u-boot對fdt(flattened device tree)的支持。

實現:只要加入

#define CONFIG_OF_LIBFDT /* Device Tree support */ 重新編譯u-boot,就可以實現對device tree的支持。
2. u-boot下的fdt命令使用 2.1 首先查看fdt的幫助信息。 ------------------------------------------------ U-Boot> fdt
fdt - flattened device tree utility commands

Usage:
fdt addr <addr> [<length>] - Set the fdt location to <addr>
fdt move <fdt> <newaddr> <length> - Copy the fdt to <addr> and make it active
fdt resize - Resize fdt to size + padding to 4k addr
fdt print <path> [<prop>] - Recursive print starting at <path>
fdt list <path> [<prop>] - Print one level starting at <path>
fdt set <path> <prop> [<val>] - Set <property> [to <val>]
fdt mknode <path> <node> - Create a new node after <path>
fdt rm <path> [<prop>] - Delete the node or <property>
fdt header - Display header info
fdt bootcpu <id> - Set boot cpuid
fdt memory <addr> <size> - Add/Update memory node
fdt rsvmem print - Show current mem reserves
fdt rsvmem add <addr> <size> - Add a mem reserve
fdt rsvmem delete <index> - Delete a mem reserves
fdt chosen [<start> <end>] - Add/update the /chosen branch in the tree
<start>/<end> - initrd start/end addr
NOTE: Dereference aliases by omiting the leading '/', e.g. fdt print ethernet0.
U-Boot> ------------------------------------------------2.2 使用fdt命令

把device tree blob (dtb)文件下載到內存裡。

-----------------------------------------

U-Boot> tftpboot 0x71000000 bshen/test-ek.dtb

-----------------------------------------

設置fdt的地址

-----------------------------------------

U-Boot> fdt addr 0x71000000

-----------------------------------------

然後就可以使用其余的命令參數了

-----------------------------------------

U-Boot> fdt header
magic: 0xd00dfeed
totalsize: 0x1887 (6279)
off_dt_struct: 0x38
off_dt_strings: 0x1648
off_mem_rsvmap: 0x28
version: 17
last_comp_version: 16
boot_cpuid_phys: 0x0
size_dt_strings: 0x23f
size_dt_struct: 0x1610
number mem_rsv: 0x0

-----------------------------------------

fdt print 不跟參數時,打印出整顆樹

fdt print加path參數,則打path內容,如下(其中/memory是path):

-----------------------------------------

U-Boot> fdt print /memory
memory {
device_type = "memory";
reg = <0x70000000 0x4000000>;
};

-----------------------------------------

U-Boot源代碼下載地址 http://www.linuxidc.com/Linux/2011-07/38897.htm

Copyright © Linux教程網 All Rights Reserved