In this entry I intend to show how to get started with PRU on the BBB using Debian Jessie.
The first problem I encountered while following the Guide in [1], was that Pin Management in BBB-Linux has changed, since this guide has been written. It has changed from slot files [2] to U-Boot overlays [3]. Additionally the userspace drivers have been replaced by remoteproc over time, so I wasn’t able to find newer Guides and had to close the gaps in the deprecated guide I used [1].
I also recommend updating the BBB to the newest distribution [4].
1. Enabling PRU UIO driver in /boot/uEnv.txt.
To use the PRU UIO driver in BB-Linux, their Uboot overlay has to be uncommented in /boot/uEnv.txt.
Before: #uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo
After: uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo
The sources of AM335X-PRU_UIO_00A0.dtbo can be found here [5].
If you intend to use PRU1 as well, you should disable HDMI.
2. Installing PRU UIO drivers.
Get the source files from [6].
git clone https://github.com/beagleboard/am335x_pru_package
Compile and install the assembler and PRU driver.
cd am335x_pru_package
sudo make all
sudo make install
cd ..
3. Getting example program from deprecated guide.
Download or copy/paste the pru programm loop.p and the loader loader.c script from [1].
Links to my Gists:
loop.p: https://gist.github.com/nilhoel1/1cbaf8a2e583317c2bfa669a1970d4b7
loader.c: https://gist.github.com/nilhoel1/7056d4bb0ce56f0b073742e5fd98e73d
The PRU program loop.p loops for 20 times, with a 500 ms delay in each loop. So executing loop.p should result in a runtime of 10 seconds as shown below.
20 * ((2 x 0.000000005 sec) * 50,000,000) = 10 sec
4. Compiling and assembling the examples.
The PRU assembly can be assembled with:
pasm -b loop.p
Before loader.c can be compiled we have to update the environment variable LD_LIBRARY_PATH with:
export LD_LIBRARY_PATH=”$LD_LIBRARY_PATH:/usr/local/lib”
Now the loader can be compiled:
gcc -o loader loader.c -lprussdrv
5. Running the example.
The example code provided from [1] will flash the P8_11 Pin ten times. The example can be executed with:
./loader loopd.bin
To see how long loop runs execute it with:
time ./loader loopd.bin
It should run for 10 seconds.
The next step will be to run a PRU program with access to BBBs IO Pins and to flash a LED with it.
Resources:
- http://www.righto.com/2016/08/pru-tips-understanding-beaglebones.html Deprecated Guide on PRU UIO.
- https://elinux.org/Beagleboard:BeagleBoneBlack_Debian#Where_did_the_slots_file_go.3F Old Pin management in BBB-Linux.
- https://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_Overlays New Pin management in BBB-Linux.
- https://markayoder.github.io/PRUCookbook/02start/start.html Guide for updating BBB.
- https://github.com/beagleboard/bb.org-overlays/blob/master/src/arm/AM335X-PRU-UIO-00A0.dts PRU UIO Pin settings.
- https://github.com/beagleboard/am335x_pru_package PRU UIO drivers.