Random thoughts

Bite sized information that has not yet made it into the blog yet,

Kernel Hacking

Raspberry Pi now uses Device Trees

18th July, 2015

The Raspberry Pi Foundation has recently introduced Device Trees as a mechanism for loading device drivers.  This is to address the problem of multiple drivers contending for the same resources, and also to support automated configuration of the new HAT (Hardware Attached to Top?) compliant add-on modules.

If you building your own kernel, and are using a HAT compliant module, such as the IQaudIO DAC+, then you will need to configure the kernel with a valid trailer in order to enable Device Tree support.

If you do not do this then Raspbian will not load the required drivers – you will not see them under dmesg or via modprobe.

What to do

Download the Raspberry Pi kernel tools

$ git clone --depth=1 https://github.com/raspberrypi/tools

Does the kernel have a valid trailer?

# tools/mkimage/knlinfo linux/arch/arm/boot/Image
* no trailer

If not then we can make one

# tools/mkimage/mkknlimg linux/arch/arm/boot/Image linux/arch/arm/boot/Image.trailer
Version: Linux version 3.18.13-v7+ (xxxx) (gcc version 4.6.3 (Debian 4.6.3-14+rpi1) ) #2 SMP PREEMPT Mon May 11 07:22:52 AEST 2015
DT: y
DDT: n
283x: n
For Raspberry Pi2
# mv /boot/kernel7.img /boot/kernel7.img.saved
# cp linux/arch/arm/boot/Image.trailer /boot/kernel7.img
For Raspberry Pi A, B, B+
# mv /boot/kernel.img /boot/kernel.img.saved
# cp linux/arch/arm/boot/Image.trailer /boot/kernel.img

Edit /boot/config.txt to load the required module, eg

# IQaudIO Pi-DAC+

Time to reboot – fingers crossed ;).


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Because it just had to be built!

%d bloggers like this: