PlutoSDR includes a single-core ARM® Cortex™-A9 MPCore™ running at 666.66 MHz for which ADI provides a BuildRoot based Linux distribution. This is part of the firmware provided with PlutoSDR. Many users of PlutoSDR run applications on a local PC and stream data to and from PlutoSDR in frameworks like GNU Radio or MATLAB. However, since PlutoSDR is running Linux users can also write C or C++ applications, among others, that can be cross-compiled on a host, and then run on PlutoSDR itself like any other Linux system. This page will discuss an example application, including the necessary tools, to build applications on a host machine and run them directly on the PlutoSDR.
Prerequisites:
Once you have the necessary tools we can start to build an application. This example will be done using Linux since it is by far the simplest to set up. We will use v0.30 of the firmware, which is assumed running on the PlutoSDR. If you change the firmware you will likely have to recompile your applications since the compiler or libraries running on the Pluto can change over time.
/opt/Xilinx
, add the necessary tools to your path: tcollins@winston: source /opt/Xilinx/Vivado/2018.2/settings64.sh
tcollins@winston: cd /usr/local/bin tcollins@winston: sudo wget http://releases.linaro.org/components/toolchain/binaries/7.2-2017.11/arm-linux-gnueabihf/gcc-linaro-7.2.1-2017.11-i686_arm-linux-gnueabihf.tar.xz tcollins@winston: sudo tar -xf gcc-linaro-7.2.1-2017.11-i686_arm-linux-gnueabihf.tar.xz tcollins@winston: export PATH=$PATH:/usr/local/bin/gcc-linaro-7.2.1-2017.11-i686_arm-linux-gnueabihf/bin
tcollins@winston: arm-linux-gnueabihf-gcc --version arm-linux-gnueabihf-gcc (Linaro GCC 7.2-2017.11-rc1) 7.2.1 20171011 Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
tcollins@winston: wget https://github.com/analogdevicesinc/plutosdr-fw/releases/download/v0.30/sysroot-v0.30.tar.gz tcollins@winston: tar zxvf sysroot-v0.30.tar.gz tcollins@winston: mv staging $HOME/pluto-0.30.sysroot
tcollins@winston: mkdir /tmp/plutoapp tcollins@winston: cd /tmp/plutoapp
tcollins@winston: wget https://raw.githubusercontent.com/analogdevicesinc/libiio/master/examples/ad9361-iiostream.c
tcollins@winston: arm-linux-gnueabihf-gcc -mfloat-abi=hard --sysroot=$HOME/pluto-0.30.sysroot -std=gnu99 -g -o pluto_stream ad9361-iiostream.c -lpthread -liio -lm -Wall -Wextra
This is a little easier, since the compiler is already for ARM. You can follow the instructions for the i686 devices, but do not install a different compiler. And when compiling, just call gcc:
tcollins@rasberian: gcc -mfloat-abi=hard --sysroot=$HOME/pluto-0.30.sysroot -std=gnu99 -g -o pluto_stream ad9361-iiostream.c -lpthread -liio -lm -Wall -Wextra
Copy the executable to PlutoSDR
tcollins@winston: scp pluto_stream root@192.168.2.1:/tmp/
Run the app:
tcollins@winston:/tmp/plutoapp$ ssh -t root@192.168.2.1 /tmp/pluto_stream root@192.168.2.1's password: analog * Acquiring IIO context * Acquiring AD9361 streaming devices * Configuring AD9361 for streaming * Acquiring AD9361 phy channel 0 * Acquiring AD9361 RX lo channel * Acquiring AD9361 phy channel 0 * Acquiring AD9361 TX lo channel * Initializing AD9361 IIO streaming channels * Enabling IIO streaming channels * Creating non-cyclic IIO buffers with 1 MiS * Starting IO streaming (press CTRL+C to cancel) RX 1.05 MSmp, TX 1.05 MSmp RX 2.10 MSmp, TX 2.10 MSmp RX 3.15 MSmp, TX 3.15 MSmp RX 4.19 MSmp, TX 4.19 MSmp RX 5.24 MSmp, TX 5.24 MSmp RX 6.29 MSmp, TX 6.29 MSmp RX 7.34 MSmp, TX 7.34 MSmp RX 8.39 MSmp, TX 8.39 MSmp RX 9.44 MSmp, TX 9.44 MSmp
Depending on the project you are doing - you may need to include something like this in a Makefile project (with the appropriate path changes),
SYSROOT = /home/rgetz/github/pluto/staging/ PKG_CONFIG_PATH=${SYSROOT}/usr/lib/pkgconfig CC=arm-linux-gnueabihf-gcc CFLAGS += --sysroot=${SYSROOT} LIBS += --sysroot=${SYSROOT}