Cross compile GNU Radio and install on target

From GNU Radio
Jump to: navigation, search

Much of this write up assumes you are familiar with building GNU Radio and OOT modules on a regular development machine. If you haven't built GNU Radio before, it would be best practicing on you regular computer before starting to cross compile it.

We have our environment set up such that we've run the environment script provided by the SDK and we can talk to the device. To build the program, we just need to follow standard instructions for our build system to make sure it uses the right tools from the SDK. The environmental variables take care of a great many of these issues. For CMake-based projects like GNU Radio and GNU Radio out-of-tree modules, we also provide a toolchain file. Setting up the project is then as simple as (starting in the gnuradio source directory and assuming you setup the tools as described in other pages in the wiki):

$ mkdir build
$ cd build
$ cmake -Wno-dev \
   -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchains/oe-sdk_cross.cmake \
$ make
$ make install DESTDIR=~/mydevice
$ sudo make install DESTDIR=/usr/local/oecore-x86_64/sysroots/armv7a-...

Notice that we set the install prefix to /usr. That will be the installation location of the project on the embedded device. We use this because all links and references within the file system will be based on this prefix, but it is obviously not where we want to install these files to on our own system. Instead, we use the make program's DESTDIR directive. We point DESTDIR to the location of the mount point we previously established using sshfs. On the device itself, however, the file system would just have this installed onto /usr, which means all our links and references are correct as far as the device is concerned.

We can now go to the SSH shell of the device and use the installed program(s).

The second 'make install' line above also installs the newly-built GNU Radio or OOT project directly into the SDK. This, then, allows us to update the SDK's version of GNU Radio and any of our OOT modules so that we can then use them in future cross-compile builds.

If you want to build gr-vocoder, you will need to build the codebook generator for x86 and tell cmake how to find out. Assuming you are in the build directory and your gnuradio clone is in /home/balister/src/git/gnuradio ...

$ gcc ../gr-vocoder/lib/codec2/generate_codebook.c -o ../gr-vocoder/lib/generate_codebook -lm
$ echo "ADD_EXECUTABLE(generate_codebook IMPORTED)" > ../gr-vocoder/lib/generate_codebook.txt
$ echo "SET_PROPERTY(TARGET generate_codebook APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)" >> ..//gr-vocoder/lib/generate_codebook.txt
$ echo 'SET_TARGET_PROPERTIES(generate_codebook PROPERTIES IMPORTED_LOCATION_RELEASE "/home/balister/src/git/gnuradio/gr-vocoder/lib/generate_codebook")' >> ../gr-vocoder/lib/generate_codebook.txt

After this the generate_codebook file looks like this:

ADD_EXECUTABLE(generate_codebook IMPORTED)
SET_TARGET_PROPERTIES(generate_codebook PROPERTIES IMPORTED_LOCATION_RELEASE "/home/balister/src/git/gnuradio/gr-vocoder/lib/generate_codebook")

When you run cmake, add this option so it knows about the file you added (and remove the entry disabling GR_VOCODER):


And after running cmake, you need to cp a file into the build tree:

$ cp ../gr-vocoder/lib/codec2/defines.h gr-vocoder/lib/codec2/

Alternatively, we can use PyBOMBS to build and install the OE SDK and other GNU Radio projects.