U-boot device tree form get Bootargs
1. Procedure Call procedure
Do_bootm
Bootm_start (CMDTP, Flag, ARGC, argv)
bootm_load_os (Images.os, &load_end, 1)
BOOT_FN = Boot_ Os[images.os.os];
BOOT_FN (0, argc, argv, &images);
Do_bootm_linux
boot_prep_linux
create_fdt (bootm_headers_t *images)
Ftd_chosen
Bootargs
2. Detailed analysis
Do_bootm
Bootm_start (CMDTP, Flag, ARGC, argv)
bootm_load_os (Images.os, &load_end, 1)
BOOT_FN = Boot_ Os[images.os.os];
BOOT_FN (0, argc, argv, &images);
Do_bootm_linux
boot_prep_linux
//above content. See the previous section
#ifdef CONFIG_OF_LIBFDT
if (images->ft_len) {
debug ("using:fdt\n");
if (CREATE_FDT (images)) {
printf ("Fdt creation failed! Hanging ... ");
Hang ();
}
} else
#endif
//If you use the device tree to pass parameters, you need to define the macros in the corresponding header file #define CONFIG_OF_LIBFDT (Origen.h (\include\configs)
3. CREATE_FDT Analysis
static int Create_fdt (bootm_headers_t *images) ulong of_size = Images->ft_le
N
Char **of_flat_tree = &images->ft_addr;
ULONG *initrd_start = &images->initrd_start;
ULONG *initrd_end = &images->initrd_end;
struct LMB *LMB = &images->lmb;
ULONG Rd_len;
int ret;
Boot_fdt_add_mem_rsv_regions (LMB, *of_flat_tree); Reserve a space for FDT ret = Boot_ramdisk_high (LMB, Images->rd_start, Rd_len,initrd_start, Init
Rd_end);
RAMDisk settings, aside from ret = BOOT_RELOCATE_FDT (LMB, Of_flat_tree, &of_size); REDIRECT The device tree.
Get the address of the device tree ret = BOOT_RELOCATE_FDT (LMB, Of_flat_tree, &of_size);
Fdt_chosen (*of_flat_tree, 1);
Look for chosen node, if not, create a
str = getenv ("Bootargs");
Get startup Parameters Err = Fdt_setprop (FDT, Nodeoffset, "Bootargs", str, strlen (str) +1); Set Bootargs to the property of the device tree Fixup_memory_node (*of_flat
_tree); for (bank = 0; bank < config_nr_dram_banks; bank++) {Start[bank] = Bd->bi_dram[bank
].start;
Size[bank] = bd->bi_dram[bank].size; }//Memory's first address and length fdt_fixup_memory_banks (
Blob, start, size, config_nr_dram_banks);
Fix or add memory node fdt_fixup_ethernet (*of_flat_tree);
FDT associated with the NIC FDT_INITRD (*of_flat_tree, *initrd_start, *initrd_end, 1); RAMDisk related FDT
4.
Boot_jump_linux
#ifdef CONFIG_OF_LIBFDT
if (images->ft_len)
r2 = (unsigned long) images->ft_addr;
else
#endif
kernel_entry (0, Machid, r2);
The address that is passed to the kernel parameter, the address of the device tree.
Reference documents:
http://blog.csdn.net/xy010902100449/article/details/46918145
Uboot mainline supported device tree from v1.1.3, and its support for ARM was completed concurrently with the ARM core support device tree.
In order to enable device Tree, you need to compile uboot in the CONFIG file to add the # define CONFIG_OF_LIBFDT
In Uboot, the. DTB can be read into memory from any media, such as NAND, SD, or TFTP, assuming that the. DTB puts the memory address 0x71000000, and then runs the command uboot FDT command settings in addr. DTB address, such as:
u-boot> FDT Addr 0x71000000
FDT's other commands can be used, such as FDT resize, FDT print, and so on.
For ARM, the kernel can be started by Bootz kernel_addr initrd_address dtb_address command, i.e. dtb_address as the last parameter of Bootz or BOOTM, the first parameter is the address of the kernel image. The second parameter is the address of the INITRD, if there is no initrd, you can use-instead.