Introduction
This part covers the device tree overlay for our little Hello-World Example. I will not cover Linux device trees here or why they are useful because there are already a lot of good sources out there that do so.
The overlay source-code
This part will be pretty short. I will just throw some code at you and explain what it does. Once you have read at least one of the articles linked at the end of this page, you should understand what it does, even without comments (Yes it’s that simple).
/dts-v1/;
/plugin/;
/ {
/* This overlay is compatible with the following devices */
compatible = "ti,beaglebone", "ti,beaglebone-black";
/* overlay identification */
part-number = "BB-WAVE-GEN";
version = "00A0";
/* Define the resources used by this overlay */
exclusive-use = "P9.27", "pru0";
fragment@0{
/* target in the device tree */
target = <&am33xx_pinmux>;
/* The overlay we define */
__overlay__{
/* Change the GPIO-Pin mode according to the pinmuxing table */
pru_pru_pins: pinmux_pru_pru_pins{
/* The first value (0x1a4) is the offset of the pin's address */
/* Value two is the pin-multiplexing (pinmux) mode, we want */
/* 25 represents mode 5, output, pull-up enabled */
/* See the pinmux table (see below) */
pinctrl-single,pins = < 0x1a4 0x25 >;
};
};
};
fragment@2{
target = <&pruss>;
__overlay__{
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&pru_pru_pins>;
};
};
};
The Pinmuxing (Pin-Multiplexing) tables are available for download here.
Compiling the code
After you have copied the above code to your beaglebone black (save it as BB-WAVE-GEN-00A0.dts), you’ll have to compile it. To do so, use the following bash command:
dtc -I dts -O dtb -o BB-WAVE-GEN-00A0.dtbo -@ BB-WAVE-GEN-00A0.dts
After the compilation finished (with no errors), you’ll see a newly generated dtbo file. Copy it to /lib/firmware and change into the firmware directory.
Loading the overlay
Now you have to load the overlay so that the system can configure your hardware accordingly. To load the overlay, echo it into the slots file, which is located at:
/sys/devices/bone_capemgr.*/
The “*” is a wildcard. It is there because the number it represents changes from system to system. If you leave the “*” where it is, the system will extend the correct number for you. So to load your overlay, you have to enter the following command:
echo ./BB-WAVE-GEN:00A0.dtbo > /sys/devices/bone_capemgr.*/slots
If there is no output after you entered the above command, the overlay was loaded successfully. If there is, check the error message with dmesg and solve eventual problems. If you catenate the contents of the slots-file you can verify whether or not the overlay was loaded correctly:

As you can see, the last line (overlay #6) shows the overlay from above. You can unload it by echoing “-6” to the slots file.
Further readings
A very nice guide about device tree overlays (Adafruit)
About the theory behind device trees and the syntax
Official devicetree.org webpage
Very well written article about gpios and device trees on the bbb with discussions
About the PRU Sub System
Table of contents
Part 0 – Introduction
Part 1 – About device trees and overlays (You are here)
Part 2 – Programming

Hurrah! In the end I got a website from where I be capable
of truly take useful data regarding my study and knowledge.
LikeLiked by 1 person
Thanks very nice blog!
LikeLiked by 1 person
You’re welcome! 🙂
LikeLike
Simply want to say your article is astonishing. The clarity for your put up is simply cool and that
i can assume you are an expert in this subject. Fine with your permission let me to snatch your
RSS feed to stay up to date with imminent post. Thank you 1,000,000 and please continue the rewarding work.
LikeLiked by 1 person
Yes please, feel free to grab our RSS feed. However you can also subscribe to our newsletter on the right side of the website or in the footer. However I’m glad you like our articles! 🙂
LikeLike
I every time spent my half an hour to read this webpage’s articles or
reviews every day along with a mug of coffee.
LikeLike
Hi!
I’m glad you liked it! 🙂
LikeLike
Someone necessarily lend a hand to make significantly posts I
might state. That is the very first time I frequented your web page and so far?
I surprised with the research you made to make this particular put up incredible.
Fantastic activity!
LikeLike
How do I enter /lib/firmware library? I want to copy file there how do i do that?
LikeLiked by 1 person
To change to the /lib/firmware directory use cd /lib/firmware
To copy files in linux use the cp command:
cp /path/source-file /lib/firmware
To move a file use mv:
mv /path/source-file /lib/firmware
However you might need to use sudo to be able to copy the files. So for example:
sudo cp ~/my-cape.dtb /lib/firmware
Will copy a the file my-cape.dtb from your user directory to the /lib/firmware directory.
However these commands only work, if you work on your BBB locally.
To transfer files on the network, so from let’s say a Windows computer to your BBB, use the scp command.
Here is a guide on how to use it: https://nerdhut.de/2016/09/03/remote-file-transfers-with-scp/
Hope this helps! 🙂
LikeLike
thank for this nice write up your code is working for me. Im still new to pru programming but i want to get bettet at it. but there are almost no community links to start
LikeLiked by 1 person
Hi Michi!
I’m happy to hear, that the code worked for you! Look at the links I provided in the article above, they might help you out, because they give you a nice point to start from! I can especially recommend Derek Molloy’s book about the BBB!
LikeLiked by 1 person
Ok i will look at the book
LikeLike