In this post I explore how to cross-compile custom apps on an Ubuntu 20.04 x64 machine for running natively on the ADALM-Pluto.

As it uses a Zynq SoC, which in turn uses an ARM core inside, we need to install a new toolchain. Fortunately, a suitable one can be found in Ubuntu's repo and can be installed using

sudo apt install gcc-arm-linux-gnueabihf

With the toolchain installed, we can now create a directory for our project. Inside it, we need to download the sysroot that matches our firmware version. For the v0.33, it can be accomplished as follows:

mkdir -p pluto-project/build-tools
cd pluto-project/build-tools
wget "https://github.com/analogdevicesinc/plutosdr-fw/releases/download/v0.33/sysroot-v0.33.tar.gz"
tar -xvf sysroot-v0.33.tar.gz
mv staging sysroot
rm sysroot-v0.33.tar.gz
cd ..

The lines above will download, unpack and rename the sysroot for you.

For this example, we'll use a simple test from Analog. It is the same used in the official docs. First download it at your project root:

wget https://raw.githubusercontent.com/analogdevicesinc/libiio/master/examples/ad9361-iiostream.c

Finally, you can compile it with:

arm-linux-gnueabihf-gcc -mfloat-abi=hard --sysroot=./build-tools/sysroot -Wall -Wextra -std=gnu99 -lpthread -liio -lrt -lm ad9361-iiostream.c -o pluto_stream

You'll be left with a `pluto_stream` binary ready for running inside your Pluto! So transfer it and run it via the network interface:

scp pluto_stream [email protected]:/tmp/
ssh -t [email protected] /tmp/pluto_stream

You should be presented with the following output, indicating that the test was successfull:

* 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
	RX    10.49 MSmp, TX    10.49 MSmp
	RX    11.53 MSmp, TX    11.53 MSmp
	RX    12.58 MSmp, TX    12.58 MSmp
	RX    13.63 MSmp, TX    13.63 MSmp
	RX    14.68 MSmp, TX    14.68 MSmp
    
    [...]

And that's it! With this basic commands you can start developing applications that run natively on your Pluto, bypassing that pesky slow USB 2.0 interface!