[etherlab-users] Etherlab on BeagleBone Black

Thomas Reischl reischl.tomml at web.de
Wed Jan 14 15:33:03 CET 2015

Hello everyone,

this is a post for everyone trying to control a plant with Etherlab over a BeagleBone Black. I’ll just describe my approach and how it worked for me as an example.

I am using an virtual machine (Linux ubuntu 3.13.0-32-generic) to make my Simulink model with additional Etherlab blocks and generate the C-code. After that, the model should be compiled and executed on the BBB (Linux beaglebone 3.8.13-bone47).

Virual Machine requirements:
Matlab/Simulink 2014a
Etherlab 2.1.0 development environment
Etherlab 2.1.0 runtime environment with PdServ and commoncpp2-1.8.1, log4cplus-1.1.3-rc2, yaml-0.1.5
EtherCAT-Master 1.5.2

BeagleBone Black requirements:
Etherlab 2.1.0 development environment
Etherlab 2.1.0 runtime environment with PdServ and commoncpp2-1.8.1, log4cplus-1.1.3-rc2, yaml-0.1.5
EtherCAT-Master 1.5.2

Etherlab installation:
I did the installation as directed (with default directory: /vol/opt/etherlab). Matlab 2014a should be installed (“/usr/local/MATLAB/R2014a”) with Simulink and Simulink Coder.
Moreover, gcc and cmake had to be downloaded from the repository for the BBB. On my virtual machine they where already available, I think.
--> Install etherlab-2.1.0 (cmake, make, make install)

To install PdServ there are three additional library dependecies: Log4cplus Library, CommonCpp2 Library and YAML Library, which can be downloaded as tarballs.
Now unzip them and install (tar –xjf for .bz2/ tar –xf for .xz or .gz, ./configure, make, make install). On the BBB the installation of commoncpp2 was a little tricky, because I got an error saying:

“applog.cpp: In constructor 'ost::logger::logger(const char*, bool)': applog.cpp:300:43: error: 'S_IREAD' was not declared in this scope applog.cpp:300:53: error: 'S_IWRITE' was not declared in this scope applog.cpp:300:61: error: 'mkfifo' was not declared in this scope”

To fix that error I edited the file “/src/applog.cpp” and substituted every S_IREAD through S_IRUSR and S_IWRITE through S_IWUSR. Additionally, I added “#include <sys/stat.h>” on top of that file. (cf. http://www.patrickmin.com/linux/tip.php?name=commoncpp)
Now I was able to install commoncpp2 (./configure, make, make install) and after that PdServ (cmake, make, make install).

EtherCAT-Master installation:
Again, I did the installation according to the instruction-pdf. Download the tarball and unzip (tar –xjf).
The ./configure call has to be done with some special options, since Etherlab and EtherCAT-Master have to be installed into the same directory (/vol/opt/etherlab). Furthermore, library paths have to be the same as etherlab-library paths (see below the libdir option)
I configured it as follows:

virtual machine:    ./configure --disable-8139too --prefix=/vol/opt/etherlab --libdir=/vol/opt/etherlab/lib/x86_64-linux-gnu
BeagleBone:        ./configure --disable-8139too --prefix=/vol/opt/etherlab --libdir=/vol/opt/etherlab/lib/arm-linux-gnueabihf

These options are important, as the default installation path of the EtherCAT-Master is “opt/etherlab” (not “/vol/opt/etherlab”) and the default lib-path of EtherCAT-Master is “/opt/etherlab/lib”. The last libdir directory is probably different for other systems, so just
have a what your directory in “/vol/opt/etherlab/lib/” after the Etherlab installation is called.
If there are missing “linux sources” for configuring I found a script generating the for BeagleBone Black: http://dumb-looks-free.blogspot.de/2014/06/beaglebone-black-bbb-kernal-headers.html
Now you should be able to install the EtherCAT-Master (./configure ..., make, make install, make modules, make modules_install).
To start the EtherCAT-Master just adapt “/vol/opt/etherlab/etc/sysconfig/ethercat” and copy it into the directory “/etc/sysconfig/” (I had to create /etc/sysconfig at first). Start it with ./ethercat start (in directory “/vol/opt/etherlab/etc/init.d/”).

At this point you are able to create your simulink model with your virtual machine and generate c-code, saved in a directory called (MODEL)_etl_hrt. The following files are needed on the BBB to build an executable and can be transported via usb-stick (usb-stick appears in /media):

+       @\cp $(MODEL).mk $(MODEL)_etl_hrt/+       @\cp rtw_proj.tmw $(MODEL)_etl_hrt/+       @\cp *.h $(MODEL)_etl_hrt/+       @\cp *.c $(MODEL)_etl_hrt/+       @\cp Makefile $(MODEL)_etl_hrt/+       @\cp $(MATLAB_ROOT)/simulink/include/*.h $(MODEL)_etl_hrt/simulink/include/+       @\cp $(MATLAB_ROOT)/extern/include/*.h $(MODEL)_etl_hrt/extern/include/+       @\cp $(MATLAB_ROOT)/rtw/c/src/*.h $(MODEL)_etl_hrt/rtw/c/src/+       @\cp $(MATLAB_ROOT)/rtw/c/src/*.c $(MODEL)_etl_hrt/rtw/c/src/+       @\cp $(MATLAB_ROOT)/rtw/c/tools/unixtools.mk $(MODEL)_etl_hrt/rtw/c/tools/+       @\cp $(MATLAB_ROOT)/rtw/c/src/ext_mode/common/*.h $(MODEL)_etl_hrt/rtw/c/src/ext_mode/common+       @\cp $(MATLAB_ROOT)/rtw/c/src/ext_mode/common/*.c $(MODEL)_etl_hrt/rtw/c/src/ext_mode/common
- (MODEL) must be exchanged with your model name, of course
- the Makefile is only a link to (MODEL).mk and has the same content.
- MATLAB_ROOT on the virtual machine was in my case “/usr/local/MATLAB/R2014a”

I saved these files on my BBB in “/home/debian/(MODEL)_etl_hrt/”. Afterwards I had to adapt the variable PLATFORM_LIBDIR into “lib/arm-linux-gnueabihf” inside the Makefile. I copied the file rtwtypes.h from “/home/debian/(MODEL)_etl_hrt” to “home/debian/(MODEL)_etl_hrt/rtw/c/src” and i copied all .h- and .c-files from “/home/debian/(MODEL)_etl_hrt” to “/vol/opt/etherlab/rtw/src”.

Now it should be possible to create an executable with: “make MATLAB_ROOT=/home/debian/(MODEL)_etl_hrt ETHERLAB_DIR=/vol/opt/etherlab”
It normally appears in “/home/debian”.

If “error while loading shared libraries: libccext2-1.8.so.0: cannot open shared object file: No such file or directory” appears when executing, you have to call “ldconfig” to make shared libraries usable.

This is how it worked for me and I hope it will help other users trying something similar.

Best regards,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20150114/931d1511/attachment-0002.htm>

More information about the Etherlab-users mailing list