Changes between Version 13 and Version 14 of linux/devicetree


Ignore:
Timestamp:
05/11/2022 06:15:31 PM (2 years ago)
Author:
Tim Harvey
Comment:

enhanced fixfdt section

Legend:

Unmodified
Added
Removed
Modified
  • linux/devicetree

    v13 v14  
    4040The U-Boot bootloader is responsible for Loading a device-tree, making any adjustments necessary, and passing it to the kernel.
    4141
    42 If desired you can use the {{{ftd}}} U-boot command to access/modify the devicetree before the kernel is booted.
     42If desired during this process you can use the {{{ftd}}} U-boot command to access/modify the devicetree before the kernel is booted. How and where to do this would depend greatly on the U-Boot bootscript used to boot your OS.
    4343
    4444Examples:
     45 * Venice: disable PCI:
     46{{{
     47setenv fsload 'load mmc 2:1'
     48run loadfdt && fdt addr $fdt_addr_r
     49fdt resize
     50fdt set /soc@0/pcie@33800000 status disabled
     51}}}
    4552 * Ventana: display the fdt on a NAND flash board:
    4653{{{#!bash
     
    5057fdt print
    5158}}}
    52  * Ventana: disable PCI via {{{fixfdt}}} script:
     59 * Ventana: disable PCI:
    5360{{{#!bash
    5461setenv fsload 'ubifsload'
     
    5966}}}
    6067
    61 Note some bootloader environments such as Ventana and Venice call a {{{fixfdt}}} script that can make integrating fixups like this into the boot process easy. See [http://trac.gateworks.com/wiki/ventana/bootloader#Specifyinganalternatedevice-treeblobDTB here] for details.
    62 
     68Important notes regarding the 'fdt set' command 'value' parameter:
     69 * numbers can be represented as decimal or as hex with a '0x' prefix
     70 * an array of cells is specified as a list of numbers enclosed in < and >, ie <0x00112233 4 05>
     71 * a byte stream can be represented as a list of numbers enclosed in [ and ], ie [00 11 22 .. nn]
     72 * a 32bit integer is a 4-byte MSB stream so a hex value of 0x1 would be represented as [00 00 00 01]
     73 * if the value does not start with a < or a [ it is treated as a string (quotes are stripped if present)
     74
     75
     76[=#fixfdt]
     77=== fixfdt script
     78If using the Gateworks BSP's the {{{fixfdt}}} env variable if set will be run as a script during the process as a feature of the Gateworks boot scripts.
     79
     80Examples:
     81 * Venice: The {{{loadfdt}}} script will load the dt to the address specified in the {{{fdt_addr_r}}} env var
     82  - disable PCI via {{{fixfdt}}} script:
     83{{{
     84setenv fixfdt 'fdt addr $fdt_addr_r; fdt resize; fdt set /soc@0/pcie@33800000 status disabled'
     85saveenv
     86}}}
     87  - limit PCI link to Gen 1 (default is Gen2 for Venice)
     88{{{
     89setenv fixfdt 'fdt addr $fdt_addr_r; fdt resize; fdt set /soc@0/pcie@33800000 fsl,max-link-speed [00 00 00 01]'
     90saveenv
     91}}}
     92 * Newport: U-Boot uses a live dt which is also passed to the kernel (dtb is not loaded) so you can alter the dt before running your normal bootscript
     93  - Disable PEM2 (PEM0=pci@87e0c0000000, PEM1=pci@87e0c1000000, PEM2=pci@87e0c2000000)
     94{{{
     95setenv bootscript 'fdt /soc@0/pci@87e0c2000000 status disabled; run distro_bootcmd'
     96saveenv
     97}}}
     98 * Ventana: The {{{loadfdt}}} script will load the dt to the address specified in the {{{fdt_addr}}} env var
     99  - disable PCI via {{{fixfdt}}} script:
     100{{{
     101setenv fixfdt 'fdt addr ${fdt_addr}; fdt resize; fdt set /soc/pcie@0x01000000 status disabled'
     102saveenv
     103}}}
     104
     105You can verify your changes took effect by checking the values in Linux via {{{/proc/device-tree}}} or by using {{{dtc}}} to de-compile the dt from {{{/sys/firmware/devicetree/base}}}:
     106{{{#!bash
     107# de-compile dt via dtc
     108dtc -I fs -O dts /sys/firmware/devicetree/base
     109# hexdump prop from /proc/device-tree
     110hexdump -C /proc/device-tree/soc\@0/pcie\@33800000/fsl\,max-link-speed
     111}}}
     112
     113=== dt overlay
    63114Note also that some bootloader environments such as Venice offer dt overlay support where the bootloader can apply overlays to a dt to alter it before passing it to the kernel. In the case of venice you can set the {{{fdt_overlay}}} env variable to a list of files to load and apply as an overlay to modify the base fdt which is typically used for adding features from an add-on board like a display or camera.
    64115
     116See [#overlay below]
    65117
    66118== Accessing devicetree from Linux ==
     
    87139}}}
    88140
     141
     142[=#overlay]
    89143== Device Tree Overlays (aka Fragments) ==
    90144The device-tree compiler and the U-Boot bootloader support the concept of applying changes to a base device-tree to make it easy to implement add-on boards such as a touchscreen display or camera that require dt bindings.