Browse over 10,000 Electronics Projects

Understanding the BeagleBone’s Built-in Microcontrollers

Understanding the BeagleBone’s Built-in Microcontrollers



The BeagleBone Black is an inexpensive, credit-card sized computer that has two built-in microcontrollers called PRUs.

While the PRUs provide the real-time processing capability lacking in Linux,
using these processors has a learning curve.

In this article, I show how to run a simple program on the PRU, and then dive into the libraries and device drivers to show what is happening behind the scenes.

The BeagleBone uses the Sitara AM3358, an ARM processor chip running at 1 GHz—this is the thumbnail-sized chip in the center of the board below.

If you want to perform real-time operations, the BeagleBone’s ARM processor won’t work well since Linux isn’t a real-time operating system.

However, the Sitara chip contains two 32-bit microcontrollers, called Programmable Realtime Units or PRUs.

(It’s almost fractal, having processors inside the processor.)
By using a PRU, you can achieve fast, deterministic, real-time control of I/O pins and devices.

The BeagleBone computer is tiny, designed to fit inside an Altoids mint tin.

The BeagleBone computer is tiny. For some reason it was designed to fit inside an Altoids mint tin. The square thumbnail-sized chip in the center is the AM3358 Sitara processor chip. This chip contains an ARM processor as well as two 32-bit microcontrollers called PRUs.

The nice thing about using the PRU microcontrollers on the BeagleBone is that you get both real-time Arduino-style control, and “real computer” features such as a web server, WiFi, Ethernet, and multiple languages. The main processor on the BeagleBone can communicate with the PRUs, giving you the best of both worlds.

The downside of the PRUs is there’s a significant learning curve to use them since they have their own instruction set and run outside the familiar Linux world. Hopefully this article will help with the learning curve.


Running a “blink” program on the PRU

To motivate the discussion, I’ll use a simple program that uses the PRU to flash an LED.
This example is based on PRU GPIO example


Blinking an LED using the BeagleBone's PRU microcontroller.


Blinking an LED using the BeagleBone’s PRU microcontroller.

The easiest way to compile and assemble PRU code is to do it on the BeagleBone, since
the necessary tools are installed by default (at least if you get the Adafruit BeagleBone).
Perform the following steps on the BeagleBone.

  • Connect an LED to BeagleBone header P8_11 through a 1K resistor.
  • Download the assembly code file blink.p:
  • Download the host file to load and run the PRU code, loader.c.
  • Download the device tree file, /lib/firmware/PRU-GPIO-EXAMPLE-00A0.dts.
  • Compile and install the device tree file to enable the PRU:
    # dtc -O dtb -I dts -o /lib/firmware/PRU-GPIO-EXAMPLE-00A0.dtbo -b 0 -@ PRU-GPIO-EXAMPLE-00A0.dts
    # echo PRU-GPIO-EXAMPLE > /sys/devices/bone_capemgr.?/slots
    # cat /sys/devices/bone_capemgr.?/slots
  • Assemble blink.p and compile the loader:
    # pasm -b blink.p
    # gcc -o loader loader.c -lprussdrv
  • Run the loader to execute the PRU binary:
    # ./loader blink.bin

If all goes well, the LED should blink 10 times.[1]


The most important document that describes the Sitara chip is the 5041-page
Technical Reference Manual (TRM for short).

This article references the TRM where appropriate, if you want more information.
Information on the PRU is inconveniently split between the TRM and the AM335x PRU-ICSS Reference Guide.

For specifics on the AM3358 chip used in the BeagleBone, see the
253 page datasheet.

Texas Instruments’ has the
PRU wiki with more information.

If you’re looking to use the BeagleBone and/or PRU
I highly recommend the detailed and informative book Exploring BeagleBone.
Helpful web pages on the PRU include BeagleBone Black PRU: Hello World,
Working with the PRU and BeagleBone PRU GPIO example.

Pages: 1 2 3 4 5 6 7