BBB - Automatically load a Device Tree overlay on boot

Don Branson picture Don Branson · Jul 21, 2013 · Viewed 11.2k times · Source

I have a device tree overlay:

/dts-v1/;
/plugin/;

/ {
    compatible = "ti,beaglebone", "ti,beaglebone-black";
    part-number = "mousetraps";
    version = "00A1";

    /* https://github.com/derekmolloy/boneDeviceTree/blob/master/docs/BeagleboneBlackP9HeaderTable.pdf */
    fragment@0 {
            target = <&am33xx_pinmux>;
            __overlay__ {
                    mousetrap_pins: pinmux_mousetrap_pins {
                            pinctrl-single,pins = <
                                    0x070 0x2f /* P9_11 30 INPUT MODE7 none */
                                    0x074 0x2f /* P9_13 31 INPUT MODE7 none */
                                    0x040 0x2f /* P9_15 48 INPUT MODE7 none */
                                    0x15c 0x2f /* P9_17 05 INPUT MODE7 none */
                            >;
                    };
            };
    };

    fragment@1 {
            target = <&ocp>;
            __overlay__ {
                    test_helper: helper {
                            compatible = "bone-pinmux-helper";
                            pinctrl-names = "default";
                            pinctrl-0 = <&mousetrap_pins>;
                            status = "okay";
                    };
            };
    };
};

which I can successfully load with:

echo mousetraps:00A1 >/sys/devices/bone_capemgr.8/driver/bone_capemgr.8/slots ; dmesg | grep bone

How can I configure the BBB/Angstrom to load it automatically on boot?

More specifically, how can I hook the dtbo file into the normal Device Tree loading mechanism? I know I can add the echo to a linux init script, but it seems like there must be something that triggers the loading of the dtbo files.

Answer

TheCodeArtist picture TheCodeArtist · Jul 22, 2013

One way to do this would be to copy the dtbo into /lib/firmware and modify capemgr.extra_override parameter in the kernel bootargs (in uEnv.txt) to point to the dtbo file. This technique also requires modifications to the /arch/arm/boot/dts/am335-bone-common.dtsi file. Details in this discussion.

Note that loading the device-tree overlay from the filesystem seems to be an issue specifically with the recent kernels(from the official repository) on the beaglebone black. To overcome this, an alternate method to compile the overlay is described here.