BeagleBone Black programmable realtime unit (PRU) Hello World – Part 1


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 other articles in the interweb already contain great articles about this topic. I will give you some links at the end of this page.

The overlay source-code

So 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 on the bottom of this page, you should understand what it does, even without comments (Yes it’s that simple).


/ {
 /* 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 ressources used by this overlay */
 exclusive-use = "P9.27", "pru0";

 /* target in the device tree */
 target = <&am33xx_pinmux>;
 /* The overlay we define */
     /* 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 is hex for mode 5, output, pull-up enabled */
         /* See the pinmux table (very bottom) */
         pinctrl-single,pins = < 0x1a4 0x25 >;

     target = <&pruss>;
         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 that one to /lib/firmware and change into the firmware directory.

Loading the overlay

Now you have to load the overlay, so that the system can change your hardware accordingly. To load the overlay, you just have to echo it into the slots file, which is located at:


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 do the following in bash:

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 (feel free to write a command if you don’t know how). If you catentate the contents of this slots-file, you can verify if your overlay was loaded correctly, or not:

Bildschirmfoto 2016-05-23 um 20.39.32

As you can see, the last line (overlay #6) shows our loaded overlay. You can unload this overlay by echoing “-6” into the slots file.

Further readings

A very nice guide about device tree overlays (Adafruit)
About the theory behind device trees and the syntax
Official 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



23 thoughts on “BeagleBone Black programmable realtime unit (PRU) Hello World – Part 1

  1. Hurrah! In the end I got a website from where I be capable
    of truly take useful data regarding my study and knowledge.


  2. 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.


    1. 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! 🙂


  3. I every time spent my half an hour to read this webpage’s articles or
    reviews every day along with a mug of coffee.


  4. 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!


    1. 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:

      Hope this helps! 🙂


    1. 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!

      Liked by 1 person

Leave your two cents, comment here!

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

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

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s