<HTML><HEAD></HEAD>
<BODY dir=ltr>
<DIV dir=ltr>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: 'Calibri'; COLOR: #000000">
<DIV>Hello everyone,</DIV>
<DIV> </DIV>
<DIV>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.</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>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).</DIV>
<DIV> </DIV>
<DIV>Virual Machine requirements:</DIV>
<DIV>Matlab/Simulink 2014a</DIV>
<DIV>Etherlab 2.1.0 development environment</DIV>
<DIV>Etherlab 2.1.0 runtime environment with PdServ and commoncpp2-1.8.1,
log4cplus-1.1.3-rc2, yaml-0.1.5</DIV>
<DIV>EtherCAT-Master 1.5.2</DIV>
<DIV> </DIV>
<DIV>BeagleBone Black requirements:</DIV>
<DIV>Etherlab 2.1.0 development environment</DIV>
<DIV>Etherlab 2.1.0 runtime environment with PdServ and commoncpp2-1.8.1,
log4cplus-1.1.3-rc2, yaml-0.1.5</DIV>
<DIV>EtherCAT-Master 1.5.2</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>Etherlab installation:</DIV>
<DIV>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.</DIV>
<DIV>Moreover, gcc and cmake had to be downloaded from the repository for the
BBB. On my virtual machine they where already available, I think.</DIV>
<DIV>--> Install etherlab-2.1.0 (cmake, make, make install)</DIV>
<DIV> </DIV>
<DIV>To install PdServ there are three additional library dependecies: Log4cplus
Library, CommonCpp2 Library and YAML Library, which can be downloaded as
tarballs.</DIV>
<DIV>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:</DIV>
<DIV> </DIV>
<DIV>“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”</DIV>
<DIV> </DIV>
<DIV>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. <A
title=http://www.patrickmin.com/linux/tip.php?name=commoncpp
href="http://www.patrickmin.com/linux/tip.php?name=commoncpp">http://www.patrickmin.com/linux/tip.php?name=commoncpp</A>)</DIV>
<DIV>Now I was able to install commoncpp2 (./configure, make, make install) and
after that PdServ (cmake, make, make install).</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>EtherCAT-Master installation:</DIV>
<DIV>Again, I did the installation according to the instruction-pdf. Download
the tarball and unzip (tar –xjf).</DIV>
<DIV>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)</DIV>
<DIV>I configured it as follows:</DIV>
<DIV> </DIV>
<DIV>virtual machine: ./configure --disable-8139too
--prefix=/vol/opt/etherlab --libdir=/vol/opt/etherlab/lib/x86_64-linux-gnu</DIV>
<DIV>BeagleBone: ./configure
--disable-8139too --prefix=/vol/opt/etherlab
--libdir=/vol/opt/etherlab/lib/arm-linux-gnueabihf</DIV>
<DIV> </DIV>
<DIV>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</DIV>
<DIV>have a what your directory in “/vol/opt/etherlab/lib/” after the Etherlab
installation is called.</DIV>
<DIV>If there are missing “linux sources” for configuring I found a script
generating the for BeagleBone Black: <A
title=http://dumb-looks-free.blogspot.de/2014/06/beaglebone-black-bbb-kernal-headers.html
href="http://dumb-looks-free.blogspot.de/2014/06/beaglebone-black-bbb-kernal-headers.html">http://dumb-looks-free.blogspot.de/2014/06/beaglebone-black-bbb-kernal-headers.html</A></DIV>
<DIV>Now you should be able to install the EtherCAT-Master (./configure ...,
make, make install, make modules, make modules_install).</DIV>
<DIV>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/”).</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>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):</DIV>
<DIV> </DIV><PRE style="MARGIN: 0cm 0cm 0pt"><FONT face="Courier New"><FONT style="FONT-SIZE: 10pt">+<SPAN style="mso-tab-count: 1"> </SPAN>@\cp $(MODEL).mk $(MODEL)_etl_hrt/</FONT></FONT></PRE><PRE style="MARGIN: 0cm 0cm 0pt"><FONT face="Courier New"><FONT style="FONT-SIZE: 10pt">+<SPAN style="mso-tab-count: 1"> </SPAN>@\cp rtw_proj.tmw $(MODEL)_etl_hrt/</FONT></FONT></PRE><PRE style="MARGIN: 0cm 0cm 0pt"><FONT face="Courier New"><FONT style="FONT-SIZE: 10pt">+<SPAN style="mso-tab-count: 1"> </SPAN>@\cp *.h $(MODEL)_etl_hrt/</FONT></FONT></PRE><PRE style="MARGIN: 0cm 0cm 0pt"><FONT face="Courier New"><FONT style="FONT-SIZE: 10pt">+<SPAN style="mso-tab-count: 1"> </SPAN>@\cp *.c $(MODEL)_etl_hrt/</FONT></FONT></PRE><PRE style="MARGIN: 0cm 0cm 0pt"><FONT face="Courier New"><FONT style="FONT-SIZE: 10pt">+<SPAN style="mso-tab-count: 1"> </SPAN>@\cp Makefile $(MODEL)_etl_hrt/</FONT></FONT></PRE><PRE style="MARGIN: 0cm 0cm 0pt"><FONT face="Courier New"><FONT style="FONT-SIZE: 10pt">+<SPAN style="mso-tab-count: 1"> </SPAN>@\cp $(MATLAB_ROOT)<SPAN class=moz-txt-tag><I>/</I></SPAN><I>simulink/include<SPAN class=moz-txt-tag>/</SPAN></I>*.h $(MODEL)_etl_hrt/simulink/include/</FONT></FONT></PRE><PRE style="MARGIN: 0cm 0cm 0pt"><FONT face="Courier New"><FONT style="FONT-SIZE: 10pt">+<SPAN style="mso-tab-count: 1"> </SPAN>@\cp $(MATLAB_ROOT)<SPAN class=moz-txt-tag><I>/</I></SPAN><I>extern/include<SPAN class=moz-txt-tag>/</SPAN></I>*.h $(MODEL)_etl_hrt/extern/include/</FONT></FONT></PRE><PRE style="MARGIN: 0cm 0cm 0pt"><FONT face="Courier New"><FONT style="FONT-SIZE: 10pt">+<SPAN style="mso-tab-count: 1"> </SPAN>@\cp $(MATLAB_ROOT)<SPAN class=moz-txt-tag><I>/</I></SPAN><I>rtw/c/src<SPAN class=moz-txt-tag>/</SPAN></I>*.h $(MODEL)_etl_hrt/rtw/c/src/</FONT></FONT></PRE><PRE style="MARGIN: 0cm 0cm 0pt"><FONT face="Courier New"><FONT style="FONT-SIZE: 10pt">+<SPAN style="mso-tab-count: 1"> </SPAN>@\cp $(MATLAB_ROOT)<SPAN class=moz-txt-tag><I>/</I></SPAN><I>rtw/c/src<SPAN class=moz-txt-tag>/</SPAN></I>*.c $(MODEL)_etl_hrt/rtw/c/src/</FONT></FONT></PRE><PRE style="MARGIN: 0cm 0cm 0pt"><FONT face="Courier New"><FONT style="FONT-SIZE: 10pt">+<SPAN style="mso-tab-count: 1"> </SPAN>@\cp $(MATLAB_ROOT)<SPAN class=moz-txt-tag><I>/</I></SPAN></FONT><I><FONT style="FONT-SIZE: 10pt">rtw/c/tools/unixtools.mk $(MODEL)_etl_hrt/rtw/c/tools</FONT><SPAN class=moz-txt-tag><FONT style="FONT-SIZE: 10pt">/</FONT></SPAN></I></FONT></PRE><PRE style="MARGIN: 0cm 0cm 0pt"><FONT face="Courier New"><FONT style="FONT-SIZE: 10pt">+<SPAN style="mso-tab-count: 1"> </SPAN>@\cp $(MATLAB_ROOT)<SPAN class=moz-txt-tag><I>/</I></SPAN><I>rtw/c/src/ext_mode/common<SPAN class=moz-txt-tag>/</SPAN></I>*.h $(MODEL)_etl_hrt/rtw/c/src/ext_mode/common</FONT></FONT></PRE><PRE style="MARGIN: 0cm 0cm 0pt"><FONT face="Courier New"><FONT style="FONT-SIZE: 10pt">+<SPAN style="mso-tab-count: 1"> </SPAN>@\cp $(MATLAB_ROOT)<SPAN class=moz-txt-tag><I>/</I></SPAN><I>rtw/c/src/ext_mode/common<SPAN class=moz-txt-tag>/</SPAN></I>*.c $(MODEL)_etl_hrt/rtw/c/src/ext_mode/common</FONT></FONT></PRE>
<DIV> </DIV>
<DIV>Hints: </DIV>
<DIV>- (MODEL) must be exchanged with your model name, of course</DIV>
<DIV>- the Makefile is only a link to (MODEL).mk and has the same content.</DIV>
<DIV>- MATLAB_ROOT on the virtual machine was in my case
“/usr/local/MATLAB/R2014a”</DIV>
<DIV> </DIV>
<DIV>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”.</DIV>
<DIV> </DIV>
<DIV>Now it should be possible to create an executable with: “make
MATLAB_ROOT=/home/debian/(MODEL)_etl_hrt ETHERLAB_DIR=/vol/opt/etherlab”</DIV>
<DIV>It normally appears in “/home/debian”.</DIV>
<DIV> </DIV>
<DIV>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.</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>This is how it worked for me and I hope it will help other users trying
something similar.</DIV>
<DIV> </DIV>
<DIV>Best regards,</DIV>
<DIV>Thomas</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV></DIV></DIV></BODY></HTML>