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. 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.
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
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.
# dtc -O dtb -I dts -o /lib/firmware/PRU-GPIO-EXAMPLE-00A0.dtbo -b 0 [email protected] PRU-GPIO-EXAMPLE-00A0.dts # echo PRU-GPIO-EXAMPLE > /sys/devices/bone_capemgr.?/slots # cat /sys/devices/bone_capemgr.?/slots
# pasm -b blink.p # gcc -o loader loader.c -lprussdrv
# ./loader blink.bin
If all goes well, the LED should blink 10 times.
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.