Adding a custom device tree to the Linux kernel

To add this device tree file to the Linux kernel, we need to add the device tree file to the arch/arm/boot/dts directory under the Linux kernel source, and a new default configuration under /arch/arm/configs/, initially both just copied from the reference board, and also modify the Linux build system's arch/arm/boot/dts/Makefile file to build it as follows:

dtb-$(CONFIG_SOC_IMX6Q) +=   
+ imx6qp-wandboard-custom-revd1.dtb   

This code uses diff formatting, where the lines with a minus prefix are removed, the ones with a plus sign are added, and the ones without a prefix are left as reference.

Once the patch is prepared, it can be added to the meta-bsp-custom/recipes-kernel/linux/linux-wandboard-4.1-2.0.x/ directory, as specified in the FILESEXTRAPATHS variable, and the Linux kernel recipe appended adding a meta-bsp-custom/recipes-kernel/linux/linux-wandboard_4.1-2.0.x.bbappend file with the following content:

FILESEXTRAPATHS_prepend := "${THISDIR}/${BP}:" 
SRC_URI_append = " file://0001-01_02-Add-a-custom-device-tree-and-configuration.patch" 
COMPATIBLE_MACHINE = "(wandboard|wandboard-custom)" 

The FILESEXTRAPATHS variable is used to extend BitBake's search path to include the directory with our patch, and using the := BitBake operator expands the variable's contents on definition instead of waiting until it is actually used.

It then adds the patch to the SRC_URI variable so that it is applied when building. Files added to the SRC_URI variable that end in the patch or diff prefixes will be applied in the order they are found. You can also force a file to be treated as patch by specifying an apply=yes property to it in SRC_URI.

Finally, it extends the COMPATIBLE_MACHINE variable to include both the wandboard and wandboard-custom machine, which means the recipe is not skipped when building for both machines.

A complete example patch that adds a custom device tree to the Linux kernel can be found in the source code that accompanies the book.

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

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