Baf for cross compiling

Often it is necessary to run a linux tool or deamon which is not part of the standard firmware or another app of the beroNet Gateway. baf provides the complete toolchain to cross compile any in source code available tool. It might though often be necessary to modify and adjust some of the source code, so that it is compatible with the uclibc and the rather old libraries that run on the beroNet gateway.

NOTE: you should have baf already installed in order to use this documentation.

This page explains the way how to approach a cross compilation and what to do with the resulting binary.

Setup the Path

It is very useful to setup the path, so that the compiler can be found by configure:

export PATH=/usr/local/share/baf/toolchain/bin/:$PATH

It can be handy to put this into your .bash_profile or such, so that you don't need to setup the path each time you open a new shell.

 

download the source package

Find the package on the internet or get it via the

apt-get source $package$

under debian/ubuntu like distros. Unpack it and make sure there is a "configure" script.

In this example we're showing how to cross compile siproxd to run it on the beroNet Gateway.

After downloading and unpacking the siproxd source (in this case version 0.8.2) change into the source folder:

cd siproxd-0.8.2

passing the cross compile arguments to configure

The configure script needs to know that it is used for cross compilation:

--prefix tells configure where the binaries and libraries should be installed and --host tells it to use the arm-linux compiler which can be found in the $PATH

 

After running configure we learn that siproxd requires libosip2, which is not present on the beroNet gateway:

so we need to donwload and compile it too.

compiling required libraries

siproxd requires libosip which needs to be downloaded as source and compiled for the arm platform. after downloading and unpacking libosip configure needs to get the right arguments:

--prefix tells configure where the library and header files should be installed and --host tells it to use the cross compiler.

after configure ran the libary needs to be compiled and installed with

 

re-running configure

After having compiled and installed the necessary libraries, we can re-run configure:

this time telling configure where the library libosip can be found.

 

compile the package

The compilation process starts with the command

During compilation you will notice that the compiler "arm-linux-gcc" is used instead of "gcc". At the end of the compilation process there should be no error and the binary should be available under:

with

the binary and all necessary libraries will be installed in the target directory. This can be helpful to figure out which files need to be copied later into the App.

To check if the binary can be run on the beroNet Gateway use file:

The output shows ARM, Version 1, which stands for the ARM CPU of the beroNet Gateway, everything looks fine!

strip the binary

To remove debugging symbols and make the binary smaller the tool "arm-linux-strip" can be used:

create an app

Create the app with baf:

in the siproxd-appsfolder there is a template folder. This folder is used to build the app.

You can simply copy all binaries and libraries into the bin and lib folder.

Now the app can be created:

 

and installed through the beroNet Gateway GUI (Apps->Market)

After installation you can login to the gateway with the admin user through ssh (make sure to have ssh access enabled Preferences->security):

Now move to

when you try to start siproxd with:

you will get an error message:

you can check if library depencies exists with ldd:

It is necessary to tell the shell where it can find the library by using the env variable LD_LIBRARY_PATH:

now it runs and shows us the help page:

 

If you need scheduled remote assistance, you can request our on-demand support services: https://www.beronet.com/support