Introduction
The Beaglebone Black PRU cores are great for high speed operations. The AM3359 chip on the BBB contains an ARM core and two PRU cores amongst other modules. They run as independent CPUs at 200MHz, freeing up the ARM core for continuing to run Linux applications. It is quite amazing to have three processors in a single chip that are fairly easy to use. This post is about a library called ACE that could be useful for any method we create to communicate to the PRU cores easily, hopefully to accelerate PRU adoption and make code easier to understand. Hopefully we can come up with good protocols for communication with the PRU cores.
Improving communications with the PRU
Some method is required for transferring binary code to be run on the PRU, and for communication between PRU and ARM while the binary code is run. The TI example software makes use of shared memory communications. Some method or protocol is still required to make this simple and safe to use, and to allow multiple processes to communicate with the PRU if desired. Not everyone will want to know about memory locations just to push a command to software running on the PRU.
An example approach
For example, one approach would be to have some code on the ARM that sleeps until a command is received from some Linux app. It would interpret the command and then send some data (via shared memory for example) that the PRU could use. The PRU would be sitting in a loop waiting for the data. The PRU would read the data, and execute some task (such as read from an ADC) and then send a response back. Meanwhile, the Linux app would continue to run at full speed. Once the PRU completes, the response would be sent to the original application that had issued the command.
ACE
One proposed approach is to make use of ACE available from here. It is considered to be reliable. (There may be other software that is also suitable). It would allow a higher level interface to be created to talk with the PRUs from Linux hosted applications.
This post investigates if ACE can run on the BBB, to encourage protocols to be devised later, for the communication to the Linux process and then a lower layer for communication down to the PRU (maybe people know of some existing methods that could be reused). The latter protocol needs to be lightweight and easy for the PRU to understand, maybe just tag/length/value encoded for example.
Compiling ACE
On the BBB, create a folder to do the development work in, e.g. off your home directory, something like /home/root/develop and create a folder called ace, i.e. so the path is /home/root/develop/ace
Download ACE - the required version is ACE-6.2.0.tar.bz2 and place it in that folder.
bunzip2 ACE-6.2.0.tar.bz2
tar xvf ACE-6.2.0.tar
The tar command will result in a folder called ACE_wrappers being created.
cd ACE_wrappers
ACE_ROOT=/home/root/develop/ace/ACE_wrappers
export ACE_ROOT
cd ace
(the path is now /home/root/develop/ace/ACE_wrappers/ace)
cp config-linux.h config-bbb-linux.h
Create a new file:
vi config.h
in this new blank file, add this line:
#include "ace/config-bbb-linux.h"
Save and exit.
cd ../include/makeinclude/
cp platform_linux.GNU platform_bbb_linux.GNU
Edit the platform_bbb_linux.GNU file, and insert after the comments at the top, this line:
static_libs_only ?= 1
Save and exit.
Then, create this new file:
vi platform_macros.GNU
in this new file, add a line (note there is no hash):
include $(ACE_ROOT)/include/makeinclude/platform_bbb_linux.GNU
Save and exit.
LD_LIBRARY_PATH=/home/root/develop/ace/ACE_wrappers/lib:/usr/lib:/lib
export LD_LIBRARY_PATH
cd $ACE_ROOT
(the path is now /home/root/develop/ace/ACE_wrappers )
cd ace
make
This will take a while to compile (about 20 minutes).
Now that the ACE library is compiled, create a folder and subfolders where you want to store everything, if you don't want to copy to /usr immediately, or if you wish to save the compiled stuff for transferring to other BBBs.
For example:
mkdir /home/root/develop/ace/built
cd /home/root/develop/ace/built
mkdir include
mkdir bin
mkdir lib
mkdir share
Then, type these commands to install in the created folders:
INSTALL_PREFIX=/home/root/develop/ace/built
export INSTALL_PREFIX
cd $ACE_ROOT
cd ace
make install
To now install in the usual folders:
INSTALL_PREFIX=/usr
export INSTALL_PREFIX
cd $ACE_ROOT
cd ace
make install
Quick ACE test
To test out ACE, make an example application (this one was selected at random):
cd $ACE_ROOT
cd examples/Logger
make
Then, in one window, execute
cd /home/root/develop/ace/ACE_wrappers/examples/Logger
./simple-server/server_loggerd
(7136|3070193664) starting up server logging daemon
And in another window,
cd /home/root/develop/ace/ACE_wrappers/examples/Logger
./client/logging_app
You should see this at the server:
(7136|3070193664) connected with localhost.localdomain
message = 1
message = 2
message = 3
message = 4
message = 5
message = 6
message = 7
message = 8
message = 9
message = 10
server logging daemon closing down
The built libraries are attached.