简体   繁体   中英

How can I choose different device trees from inside u-boot for the Linux kernel

I need to have different variants of a device tree passed to my linux kernel dependant on a board revision that can only be determined at run time.

What's the established way of setting up the boot of the kernel to deal with various hardware layouts that can only be determined at boot time from within u-boot?

Late answer, but i recently add to deal with the same problem.

Using u-boot , you can actually write a macro for that.

The u-boot environment variable for the device tree file is " fdtfile ".

From there, you can define a macro that set this variable according to your specific need for example :

setenv findfdt '
if test $mycondition = value1; then setenv fdtfile devicetree1.dtb; fi;
if test $mycondition = value2; then setenv fdtfile devicetree2.dtb; fi;
..'

Then you can just create a .txt file to register this macro and then use mkimage tool to create a binary image .img for u-boot to load :

mkimage -T script -d macros.txt macros.img

You can of course wrap this macro with a more sophisticated one that will be executed at each boot.

The bootm command is taking three parameters:

bootm ${kernel_addr} ${ramdisk_addr} ${fdt_addr}

While the third one is the address of the flattened device tree blob in the memory. So if you have different device trees, either load them into different memory addresses and pass them to bootm , or load that memory address with different blobs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM