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


/ {
  /* 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";

    /* 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 represents mode 5, output, pull-up enabled */
        /* See the pinmux table (see below) */
        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 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:


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:

Bildschirmfoto 2016-05-23 um 20.39.32

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


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

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

    Liked by 1 person

    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! πŸ™‚


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


  3. 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.