Device Tree Configuration for Opal-6

What is the Device Tree?

The device tree is a data structure comprising of nodes which define the hardware controlled by the Linux kernel. This will include processor, ram, regulators, audio, video, uarts, peripherals attached to i2c and spi interfaces and so on. The device tree is composed of one or more files. For example the device trees for the Opal-6Q development kit comprises of the following files:

imx6q-opaldk.dts – defines the development kit specific hardware

imx6q-opal6.dtsi – defines the Opal6Q module hardware and is included by the .dts file above

The above source files are then compiled to create a binary ‘blob’ called a .dtb file. In our case above, this would result in a file called imx6q-opaldk.dtb. It is this file which is used by the kernel.

Why would I need to change it?

You will need to change the device to support your custom hardware. The device tree we supply is specific to the Opal-6 development kit. Specifically you will need to update the .dts file to reflect your actual hardware. Note that the .dtsi file defining the module hardware should not change.

How do I change it?

Devices trees are located in the kernel source tree at /arch/arm/boot/dts/imx6...

The Opal-6 development kit device trees are imx6dl-opaldk.dts and imx6q-opaldk.dts. These files reference the Opal-6 module device tree

Compiling the Device Tree

Compiling the device is simple. If we take our Opal-6 development kit as an example, we would compile the device tree as follows:

$ make imx6q-opaldk.dtb

Remember to use the Opal-6 toolchain to build this.

Loading it onto a board

To change an existing device tree you just need to copy over the new binary dtb file to the target. The standard Opal-6 partitions are such that partition 1 of the eMMC holds the kernel and device tree binaries so do the following:

From your development host:

$ scp linux-opal6/arch/arm/boot/dts/imx6q-opaldk.dtb root@192.168.1.69:~/

And from your Opal-6 debug terminal:

$ mkdir p1
$ mount /dev/mmcblk3p1 p1
$ mv p1/imx6q-opaldk.dtb imx6q-opaldk.dtb.backup
$ mv imx6q-opaldk.dtb p1
$ sync

The above lines mount partition 1, backup the original dtb file and replace with the new device tree.

Reset your board to startup with your new device tree.

On this page

Device Tree Documentation

A useful starting point to learn about Device Trees is:

https://events.linuxfoundation.org/sites/events/files/slides/petazzoni-device-tree-dummies.pdf

The main kernel documentation describing the latest device tree entries (bindings) can be found in the kernel source tree at:

http://linux-opal6/Documentation/devicetree/bindings

Existing device trees are also a good source of information and it is worth examining a few of these to gain a better idea of what is required.