Programmable real-time unit and industrial communications subsystem (PRU-ICSS)
What is a PRU-ICSS?
Per https://training.ti.com/pru-training-series:
The Programmable Real-time Unit and Industrial Communications Subsystem (PRU-ICSS / PRU-ICSSG) is a small processor that is tightly integrated with an IO subsystem, offering low-latency control of IO pins on ... SoC devices, including the AM335x, AM437x, AM57x, and AM65x Sitara™ processors.
The PRU-ICSS / PRU-ICSSG is customer-programmable and can be used to implement simple and flexible control functions, peripherals and state machines that directly access IO pins of the device, as well as can communicate with the application cores.
Why PRUs?
A programmable real-time unit (PRU) is a fast (200-MHz, 32-bit) processor with single-cycle I/O access to a number of the pins and full access to the internal memory and peripherals on the AM3358 processor on BeagleBones (BeagleBone, BeagleBone Black, BeagleBone Green, etc.). They are design to provide software-defined peripherals as part of the Programmable Real-time Unit Industrial Control SubSystem (PRU-ICSS) and are capable of implementing things like 25 pulse-width modulators, 4 soft UARTs, stepper motor drivers and much more. Having these controllers integrated is really handy to avoid throwing in another device to control or interface to a new peripheral. The real power comes when you need high-bandwidth between the main CPU and these controllers, such as in BeagleLogic.net, MachineKit or LEDscape. Those are all super-cool projects to check out.
The MIT Center for Bits and Atoms did a study of a critical metric for building machines able to control the physical world, a software ring oscillator. This metric may help to give some perpective on how much of a game-changer having the PRU-ICSS is: https://pub.pages.cba.mit.edu/ring/.
Links to good resources
Check out the new PRU Cookbook!
There are also PRU examples for BeagleBone Black, BeagleBone AI, and PocketBeagle.
TI links
- PRU Training Series
- Search on TI.com
- Search for TI Training
- Linux getting started guide
- PRU-ICSS subsystem comparison guide
- PRU assembly language guide
- PRU read latencies
This page is still in development. You should also explore https://elinux.org/Category:PRU.
Latest example
The latest examples on getting started with PRU programming are at /examples/extras/pru in Bone101. The list of examples there should be growing soon and is a bit small right now. You can learn about the architecture with the resources below, but getting a new image and using the Bone101 examples should be the fastest path to getting your code compiled and running.
TI Introductory Video
PRU Workshop
Materials from the PRU workshop held at the SE Michigan BeagleBone Users' Group meetup will be uploaded here shortly.
Workshop BealgeBone Black flasher image
The image used in the workshop is http://debian.beagleboard.org/images/20141104_pru_sensortag_workshop.img.7z and needs at least a 2GB microSD card. Don't worry if you run out of space flashing your 2GB microSD as it was copied off of a larger card. This image doesn't have bug that you'll see in the video where I forgot to install the 'ply' Python library--instead this image has it already installed.
To create the image, I roughly did the following steps
- Started with the 9/3/2014 Debian image
- Installed an updated kernel that includes PRU Speak
- Installed PRU C compiler version 2.1.0 from http://software-dl.ti.com/codegen/non-esd/downloads/download.htm#PRU
- Processed bone101 with Jekyll
- Installed PRU Speak built firmware, Python scripts and 'ply' Python library using https://github.com/jadonk/pruspeak
- Installed node-red (you can modify it to start on opening port 1880 by using these node-red systemd socket activation configuration files
- Installed node.js sensortag library
- ... more later ...
Workshop videos
Help in editing this videos, by combining them into one, switching screens at the right point, adding annotations and indexing, would be very welcome.
Slides
Steps
- Flash the BeagleBone with the provided build, and boot it up.
- Go to Cloud-9 - http://192.168.7.2:3000/
- Disable HDMI in /boot/uEnv.txt (back in Cloud9 IDE terminal window)
sed -i '/cape_disable=capemgr.disable_partno=BB-BONELT-HDMI,BB-BONELT-HDMIN$/ s/^#//' /boot/uEnv.txt
- Restart the BeagleBone
shutdown –r now
- Load the kernel module (back in Cloud9 IDE terminal window)
modprobe pru_speak
- Load the device tree overlay (from Cloud9 IDE terminal window)
config-pin overlay BB-PRUSPEAK
This the remote proc server, which loads firmware and manages communication between files and the PRU. It is placed inthe OS Kernel. - (skip) Install 'ply' Python library (not required on provided image, but was needed to
be done during the recording of the workshop)
- Enable Internet Connection Sharing on your host to the BeagleBone network port
- Obtain an IP address (in a Cloud9 IDE terminal subwindow)
dhclient eth0
- Install the 'ply' Python library using 'pip'
pip install ply
- Run PRU Speak tcp server (in a Cloud9 IDE terminal window)
cd /var/lib/cloud9/examples/extras/pruspeak python bs_tcp_server.py
PRU Speak should now be running - Use 'netcat' to connect to running PRU Speak server (in a separate Cloud9 IDE terminal window)
nc localhost 6060
- Place an LED (that includes an internal resistor or using a resistor in series) between P9_42 (round side) and P9_46 (flat side). The GPIO mapping can be found in the PRU headers image on the main bone101 support page under where the location of the headers on the board is shown. Sparkfun has a nice article describing the polarity of an LED.
- Execute SET DIO[4],1 in PRU Speak to turn the LED on.
- Blink LED (to Cloud9 IDE terminal window running netcat connected to PRU Speak server)
SCRIPT SET DIO[4], 1 WAIT 100 SET DIO[4], 0 WAIT 100 GOTO 0 ENDSCRIPT RUN