Looking at the device tree from U-Boot

The U-Boot bootloader offers the fdt command to interact with a device tree blob. In the Wandboard's default environment, there are two variables related to the device tree:

  • fdtfile: This variable contains the name of the device tree file used
  • fdt_addr: This variable contains the location in memory to load the device tree

To fetch the Wandboard's device tree from the TFTP server location and place it in memory, we use the following command:

> tftp ${fdt_addr} ${fdtfile}  

Once we have the device tree blob in memory, we tell U-Boot where it is located:

> fdt addr ${fdt_addr}  

And then we can inspect nodes from the device tree using the full path to them from the root node. To inspect the selected levels, we use the list command, and to print complete subtrees, we use the print command:

> fdt list /cpus 
cpus { 
        #address-cells = <0x00000001>; 
        #size-cells = <0x00000000>; 
        cpu@0 { 
        }; 
        cpu@1 { 
        }; 
        cpu@2 { 
        }; 
        cpu@3 { 
        }; 
}; 
> fdt print /cpus 
cpus { 
        #address-cells = <0x00000001>; 
        #size-cells = <0x00000000>; 
        cpu@0 { 
                compatible = "arm,cortex-a9"; 
                device_type = "cpu"; 
                reg = <0x00000000>; 
                next-level-cache = <0x0000002c>; 
                operating-points = <0x00124f80 0x00137478 0x000f32a0 0x001312d0 0x000d0020 0x001312d0 0x000c15c0 0x0011edd8 0x00060ae0 
0x000ee098>; 
                fsl,soc-operating-points = <0x00124f80 0x00137478 0x000f32a0 0x001312d0 0x000d0020 0x001312d0 0x000c15c0 0x0011edd8 0x0 
0060ae0 0x0011edd8>; 
                clock-latency = <0x0000ee6c>; 
                clocks = <0x00000003 0x00000068 0x00000003 0x00000006 0x00000003 0x00000010 0x00000003 0x00000011 0x00000003 0x000000aa 
 0x00000003 0x000000e7 0x00000003 0x000000ee 0x00000003 0x000000e0>; 
                clock-names = "arm", "pll2_pfd2_396m", "step", "pll1_sw", "pll1_sys", "pll1", "pll1_bypass", "pll1_bypass_src"; 
                arm-supply = <0x0000002d>; 
                pu-supply = &lt;0x00000014>; 
                soc-supply = <0x0000002e>; 
        }; 
... 

U-Boot can also attach new nodes to the tree, assuming there is extra space in the device tree (refer to the Managing the device tree recipe for instructions on how to create a device tree with extra space):

> fdt mknode / new-node 
> fdt list /new-node 
new-node { 
}; 

It can also create or remove properties:

> fdt set /new-node testprop testvalue 
> fdt print /new-node                  
new-node { 
        testprop = "testvalue"; 
}; 
> fdt rm /new-node testprop            
> fdt print /new-node       
new-node { 
}; 

For example, it can be useful to modify the kernel command line through the chosen node.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset