Changes between Initial Version and Version 1 of linux/devicetree


Ignore:
Timestamp:
10/22/2017 05:28:45 AM (7 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • linux/devicetree

    v1 v1  
     1[[PageOutline]]
     2
     3= Linux Device Tree support =
     4The modern linux kernel uses a system called 'devicetree' to describe hardware in a consistent fashion to avoid needing custom 'board support' files for boards.
     5
     6Typically the bootloader will pass a 'flattened device tree' (a compiled binary representation of a device-tree) to the kernel so that the kernel can configure all the components on the board.
     7
     8The Gateworks Ventana product family based off the Freescale i.MX6 CPU, uses devicetree (with the exception of the early Yocto 1.3 and Android jellybean BSP's which were based on a 3.0.35 non-device-tree kernel)
     9
     10[[Image(devicetree.png,400px)]]
     11
     12== Device Tree Terminology ==
     13 * dts - Board level definitions
     14 * dtsi - SoC level definitions
     15 * dtb - Binary blob of device tree loaded by bootloader
     16
     17
     18== Example Device Tree File ==
     19You can find the device tree files in arch/arm/boot/dts
     20
     21For an example, see here: [https://github.com/Gateworks/linux-imx6/blob/gateworks_3.10.53_1.1.0_ga/arch/arm/boot/dts/imx6qdl-gw54xx.dtsi]
     22
     23
     24== Accessing devicetree from the Bootloader ==
     25The Ventana u-boot has fdt support enabled and uses this through default bootscripts to load an fdt (based on the board model) from the filesystem of the boot media.  The bootloader then modifies the devicetree to disable components that are possible on the board, but perhaps not loaded on the bill-of-materials (for example, a Gateworks Special build).
     26
     27If desired you can use the ftd u-boot command to access/modify the devicetree before the kernel is booted.
     28
     29Examples:
     30 * display the fdt of a Ventana board (loaded from NAND flash ubifs):
     31{{{
     32setenv fsload 'ubifsload'
     33ubi part rootfs && ubifsmount ubi0:rootfs
     34run loadfdt && fdt addr ${fdt_addr} && fdt boardsetup
     35fdt print
     36}}}
     37 * disable PCI via device-tree:
     38{{{
     39setenv fsload 'ubifsload'
     40ubi part rootfs && ubifsmount ubi0:rootfs
     41run loadfdt && fdt addr ${fdt_addr} && fdt boardsetup
     42fdt resize
     43fdt set /soc/pcie@0x01000000 status disabled
     44}}}
     45
     46Note the Ventana bootloader has 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.
     47
     48
     49== Accessing devicetree from Linux ==
     50If the kernel is configured with CONFIG_PROC_DEVICETREE (which the Ventana OpenWrt BSP does configure) and procfs is enabled, you can access the devicetree via /proc/device-tree.  This can be useful to obtain information about the board that the bootloader configured, such as board model and serial number.
     51
     52Examples:
     53 * show board model:
     54{{{
     55echo $(cat /proc/device-tree/board)
     56}}}
     57 * show board serialnumber
     58{{{
     59echo $(cat /proc/device-tree/system-serial)
     60}}}
     61 * show devicetree compatible node (this describes which device-tree was used as there is one per base-board design):
     62{{{
     63echo $(cat /proc/device-tree/compatible)
     64}}}
     65 * show chosen bootargs (the bootargs passed in by the bootloader, same as /proc/cmdline):
     66{{{
     67echo $(cat /proc/device-tree/chosen/bootargs)
     68}}}
     69
     70
     71== Specifying the Device-tree that is used ==
     72The [wiki:/linux/bootloader bootloader] is responsible for loading the device-tree blob (DTB) and executing the kernel
     73The Gateworks ventana bootloader in a way that it knows where the DTB is loaded.
     74
     75Therefore, its the bootloader that decides which DTB to load and from where.
     76
     77See [wiki:/ventana/bootloader] for details on how the DTB filename is chosen and loaded.