EPICS IOC on a Raspberry Pi

This is one of the most time-consuming and difficult parts of a series on how to set up EPICS control of an Arduino.  Technically, this part of the project isn’t very challenging, but the nitty-gritty details of getting it to work are kinda monotonous.

The aim of this is to build an IOC on a Raspberry Pi that can communicate via serial link with the Arduino system built in a previous post.  This needs the following steps:

  1. A working version of EPICS Base.
  2. Addition of the ASYN and StreamDevice libraries to the EPICS installation.  These are needed to communicate with the Arduino via serial commands.

To avoid confusion, the following will be done by the regular “pi” user, and any necessary privilege escalation will be made clear by the use of “sudo”.

Step 1

Working in ~/Downloads, grab the necessary source files.

wget http://www.aps.anl.gov/epics/download/base/baseR3.14.12.5.tar.gz
wget http://aps.anl.gov/epics/download/modules/asyn4-28.tar.gz
wget http://epics.web.psi.ch/software/streamdevice/StreamDevice-2.tgz

Create a new place to work, unpack EPICS there, and then link that to /usr/local

mkdir -p ~/Apps/epics
tar -zxf ~/Downloads/baseR3.14.12.5.tar.gz -C ~/Apps/epics/
sudo ln -s /home/pi/Apps/epics /usr/local/
ln -s /home/pi/Apps/epics/base- /home/pi/Apps/epics/base

On a fresh Raspian installation, the .bashrc file will source ~/.bash_aliases if it exists, so it’s a good place to add the EPICS environment variables.  So, if ~/.bash_aliases exists, add the following to it.  If it doesn’t, create it and then add the following.  If you’re not using Raspian, do the appropriate thing for your OS.

export EPICS_ROOT=/usr/local/epics
export EPICS_BASE=${EPICS_ROOT}/base
export EPICS_HOST_ARCH=`${EPICS_BASE}/startup/EpicsHostArch`
if [ "" = "${LD_LIBRARY_PATH}" ]; then

To make sure the environment is as it should be, log out and in again.  Then inspect the output of the following:

env | grep EPICS

This should produce a bunch of reasonable looking output.  Judge for yourself.

After this, EPICS should be ready to compile.  Go to, “~/Apps/epics/base”, and run make.  It should take ~15-20 minutes.

Step 2

In this stage, the plan is to install ASYN and StreamDevice into EPICS.  They’ve already been downloaded, so now it’s time to add them to the system.

mkdir -p ~/Apps/epics/modules
tar -zxf ~/Downloads/asyn4-28.tar.gz -C ~/Apps/epics/modules/
ln -s /home/pi/Apps/epics/modules/asyn4-28 /home/pi/Apps/epics/modules/asyn
cd ~/Apps/epics/modules/asyn

In this directory, edit the configure/RELEASE file.

  • Comment out the IPAC line
  • Comment out the SNCSEQ line
  • Comment out the EPICS_BASE line
  • Add the following

Inside ~/Apps/epics/modules/asyn run “make”.

When this completes, the system is ready for installation of the Stream Device code.

mkdir /home/pi/Apps/epics/modules/stream
cd /home/pi/Apps/epics/modules/stream
tar -zxvf ~/Downloads/StreamDevice-2.tgz -C  /home/pi/Apps/epics/modules/stream
makeBaseApp.pl -t support

The last line will ask a question about application names, but just leave it blank and hit enter to move on.

Now add the following line to the end of configure/RELEASE so that it knows where to find the ASYN package that has just been installed.


Now run “make” in this directory (/home/pi/Apps/epics/modules/stream).

Once this completes, cd into StreamDevice-2-6, and run “make” again.


If you’ve got to this stage, then you now have a working version of EPICS complete with ASYN and StreamDevice installed on your Raspberry Pi.  The next step is to create an EPICS database that will allow control of the Arduino set up in a previous post over Channel Access.