Raspberry PI: Cross compiling the KNX/EIB eibd

Hello,

if you want to use the Raspberry PI as a EIB/KNX Gateway or Tunnel you must compile the eibd sources from the scratch, because no precomplied binaries are currently available.

There are two ways to build the eibd. Compiling directly on the Raspberry PI or you compile it on your i386 PC. The last option means you have to “cross” compile the sources, because the RapsberryPi has a different processor architecture than your Intel/AMD PC. Here are the steps to build the eibd on an i386 using a crosscompiler for the ARM architucture.

I verfied the steps at a minimal debian system in a VirtualBox. So it is reproducible:-)

Install all necessary packages. Login as root

apt-get -y install git rsync cmake make gcc g++ binutils automake flex bison patch
Now you can Login as a “normal” user. Define a working folder
export BUILD_PATH=~/eibdbuild
mkdir -p $BUILD_PATH
cd $BUILD_PATH
We need a cross compiler respectively the toolchain for the arm1176jzf arm processor.

For the RaspberryPI a project exists at Github.  Define a folder for the tools and compiler, create and change to it
export RASPBERRY_CROSS_COMPILER=$BUILD_PATH/raspPiTools
mkdir -p $RASPBERRY_CROSS_COMPILER
cd $RASPBERRY_CROSS_COMPILER
Get the latest version
git clone git://github.com/raspberrypi/tools.git
Add the location of compiler binary to the search PATH
PATH=$PATH:$RASPBERRY_CROSS_COMPILER/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin
Check the compiler, this should return something like this
arm-linux-gnueabihf-gcc -v
Using built-in specs.
COLLECT_GCC=arm-linux-gnueabihf-gcc
COLLECT_LTO_WRAPPER=/home/michael/eibdbuild/raspPiTools/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../libexec/gcc/arm-linux-gnueabihf/4.7.2/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: /cbuild/slaves/oort61/crosstool-ng/builds/arm-linux-gnueabihf-raspbian-linux/.build/src/gcc-linaro-4.7-2012.08/configure --build=i686-build_pc-linux-gnu --host=i686-build_pc-linux-gnu --target=arm-linux-gnueabihf --prefix=/cbuild/slaves/oort61/crosstool-ng/builds/arm-linux-gnueabihf-raspbian-linux/install ............

define the architecture

export TARGET_ARCH=arm-linux-gnueabihf
define a folder where the complied binaries should copied to.
export BUILD_ROOT=$BUILD_PATH/build
Get and compile pthsem
cd $BUILD_PATH
mkdir pthsem
cd pthsem
wget http://www.auto.tuwien.ac.at/~mkoegler/pth/pthsem_2.0.8.tar.gz
tar -xvzf pthsem_2.0.8.tar.gz
cd pthsem-2.0.8

./configure --enable-static=yes --build=i386-linux-gnu --target=$TARGET_ARCH --host=$TARGET_ARCH --prefix=$BUILD_ROOT CC="$TARGET_ARCH-gcc" CFLAGS="-static -static-libgcc -static-libstdc++ -marm -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s" --with-mctx-mth=sjlj --with-mctx-dsp=ssjlj --with-mctx-stk=sas LDFLAGS="-static -static-libgcc -static-libstdc++"
make && make install

Check if the new pthsem library is in the correct folder

ls -l $BUILD_ROOT/lib
total 132
-rw-r--r-- 1 michael michael 126842 Oct 17 22:32 libpthsem.a
-rwxr-xr-x 1 michael michael    894 Oct 17 22:32 libpthsem.la
drwxr-xr-x 2 michael michael   4096 Oct 17 22:32 pkgconfig

Add the path of the library to LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$BUILD_ROOT/lib:$LD_LIBRARY_PATH
Get and compile the bcusdk
cd $BUILD_PATH
mkdir bcusdk
cd bcusdk
wget http://netcologne.dl.sourceforge.net/project/bcusdk/bcusdk/bcusdk_0.0.5.tar.gz
tar -xvzf bcusdk_0.0.5.tar.gz
cd bcusdk-0.0.5

Before you start configure. Select the features which the eibd daemon should support:

Select the features eibd should support:
–enable-ft12         enable FT1.2 backend
–enable-pei16        enable BCU1 kernel driver backend
–enable-tpuart       enable TPUART kernel driver backend (deprecated)
–enable-pei16s       enable BCU1 user driver backend (very experimental)
–enable-tpuarts      enable TPUART user driver backend
–enable-eibnetip     enable EIBnet/IP routing backend
–enable-eibnetiptunnel       enable EIBnet/IP tunneling backend
–enable-usb                  enable USB backend
–enable-eibnetipserver       enable EIBnet/IP server frontend
–enable-groupcache           enable Group Cache (default: yes)
–enable-java         build java client library

Add or remove it from the configure command line.

./configure --enable-onlyeibd --enable-tpuarts --enable-tpuart --enable-ft12 --enable-eibnetip --enable-eibnetiptunnel --enable-eibnetipserver --enable-groupcache --enable-static=yes  --build=i386-linux-gnu --target=$TARGET_ARCH --host=$TARGET_ARCH --prefix=$BUILD_ROOT --with-pth=$BUILD_ROOT  --without-pth-test CC="$TARGET_ARCH-gcc" CFLAGS="-static -static-libgcc -static-libstdc++ -marm  -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s" LDFLAGS="-static -static-libgcc -static-libstdc++ -s" CPPFLAGS="-static -static-libgcc -static-libstdc++ -Os -fmerge-constants"

make && make install
If the compilation succeeds you find the eibd and the tools at
ls -l $BUILD_ROOT/bin
total 1512
-rwxr-xr-x 1 michael michael 156775 Oct 17 22:44 bcuaddrtab
-rwxr-xr-x 1 michael michael 154727 Oct 17 22:44 bcuread
-rwxr-xr-x 1 michael michael 8171 Oct 17 22:44 busmonitor1
-rwxr-xr-x 1 michael michael 8167 Oct 17 22:44 busmonitor2
-rwxr-xr-x 1 michael michael 399715 Oct 17 22:44 eibd
-rwxr-xr-x 1 michael michael 161259 Oct 17 22:44 eibnetdescribe
-rwxr-xr-x 1 michael michael 161439 Oct 17 22:44 eibnetsearch

Copy the all subfolders of  the $BUILD_ROOT folder to your Raspberry PI. Either to /usr or /usr/local folder. I prefer the last one to sparate it from the system files.

Whats left are startup scripts for eibd. See next post.

Michael

2 thoughts on “Raspberry PI: Cross compiling the KNX/EIB eibd”

  1. Hey again,

    worked seamless on Raspberry Pi 3 Model B with ubuntu 16.04 minimal server from here … ubuntu-pi-flavour-maker.org
    So I don’t know who now has access to my Bus, but who cares 😛

    Thx again, really cool

Leave a Reply Cancel reply