简体   繁体   English

如何从u-boot内部为Linux内核选择不同的设备树

[英]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. 我需要将不同的设备树变体传递给我的linux内核,这取决于只能在运行时确定的电路板修订版。

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? 设置内核启动以处理只能在启动时从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. 使用u-boot,您实际上可以为此编写一个宏。

The u-boot environment variable for the device tree file is " fdtfile ". 设备树文件的u-boot环境变量是“ 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 : 然后,您可以只创建一个.txt文件来注册此宏,然后使用mkimage工具创建一个二进制映像.img以供u-boot加载:

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命令采用三个参数:

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

While the third one is the address of the flattened device tree blob in the memory. 第三个是内存中展平的设备树blob的地址。 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. 因此,如果您具有不同的设备树,则将它们加载到不同的内存地址中并将它们传递给bootm ,或使用不同的blob加载该内存地址。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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