Drone-OS toolchain on Ubuntu 18.04

Posted On July 19, 2019

Let’s set up the complete toolchain for compiling and flashing a demo firmware written with Drone-OS library on the STM32 Nucleo-144 board. The point of departure is a minimal 64-bit Ubuntu 18.04.2 server installation.


CURL is a command-line utility to make HTTP requests and get data from web servers.
The other packages are the C/C++ compiler environment and supporting tools. gdb-multiarch ist an architecture independent GNU client for debugging processors.

This shell command will install the required packages on Ubuntu 18.04:

sudo apt-get install curl gcc autoconf pkg-config libtool gdb-multiarch

Install the Rust Language Compiler

rustup is the installer for the systems programming language Rust. It can be installed with this command:

curl https://sh.rustup.rs -sSf | sh

It will ask you if you want to change the install options. Choose:
1) Proceed with installation (default)
Most Rust developers use the stable version. But those who use experimental or new features will use the beta or nightly Rust toolchain. For more information about how Rust is made the please read the relevant chapter in ‘the book‘.

What you have installed now is the most recent stable release of the Rust toolchain. Follow the instructions at the bottom of the console log:

You can now display the details with the command:

rustup show

However, Drone-OS is using some new and advanced features of the Rust language and therefore needs a specific nightly build. A file with name rust_toolchain in our project’s root directory will specify the specific nightly build that is needed to build the project. The cargo package manager automatically fetches and installs the requested nightly build version from the Rust repository if it is not installed already.

Note that you can install several versions of the Rust toolchain and easily switch between them with the ‘rustup default <channel>[-<date>][-<host>]’ command at any time. Run the ‘rustup show’ command to list the installed and active toolchains:

Install Helper Tools

In our blog-post projects, we use the tool just as a handy way to store and execute command-line scripts. Install it with this shell command (cargo is the Rust package manager and is thus an inherent component of the Rust toolchain):

cargo install just

Prepare for Flash, Debug and Trace

You may already have experience in that field. There are many hardware adapters on the market, open-sourced like the inexpensive ST-LINK clones, or commercial ones like those from Segger. Developer boards such as the STM32 Nucleo even come with an on-board adapter.

Making those adapters and the host software work when connecting to new boards and to new MCUs of varying vendors can be time-consuming, if not frustrating. Some advanced features like the Instrumentation Trace Macrocell (ITM) logging need stable connections between the host and the embedded system. It may work perfectly with the proprietary tools of the IDE vendors, but we prefer an open-sourced and transparent toolchain!

Imagine a solution where a GDB Server is embedded and running in the debug and trace adapter remotely. The adapter processes the GDB Client requests and responses between the debugging host and the embedded system over USB. No additional debugging protocol layer is involved, such as it is the case with OpenOCD. The GDB Server resides in the debug probe and handles without any detours the electrical signals on the wires from the JTAG or SWD pins of the target MCU. Furthermore, the adapter will forward the data stream written to the Cortex-M Instrumentation Trace Macrocell (ITM) to a virtual COM-port on the debugging host.

Such a solution exists, and it is fully open-sourced! We have used it in our projects and are excited about its versatility and robustness. The native hardware might seem a bit on the expensive side ($60 here), but there are instructions available on how to port the software to an inexpensive $5 device.

The Black Magic Probe

All the information about that amazing software and hardware is available here:


Prepare your Ubuntu 18.04 for Black Magic Probe

  • Add the device rules for the virtual com-ports so that the GDB client can access them transparently.
  • Add your login user to the group ‘dialout
  • Install a simple application (a crate written in Rust) which uses libusb-1.0 to open the TRACESWO USB endpoint on the Black Magic Probe and dump the incoming raw data.

Add the following content to this new file:

# Black Magic Probe

# there are two ACM (emulated modem) devices, one for GDB and one for UART
# debugging, these are by default accessible by the dialout user and so we
# only need to create symlinks for these so that we can reliably find them
SUBSYSTEM=="tty", ATTRS{interface}=="Black Magic GDB Server", SYMLINK+="ttyBmpGdb"
SUBSYSTEM=="tty", ATTRS{interface}=="Black Magic UART Port", SYMLINK+="ttyBmpTarg"

# the TRACESWO is more difficult because it isn't an ACM device, it is frame
# based and does not have a kernel driver, hence we cannot set permissions on
# it individually, instead set the entire device to dialout so we can open it
SUBSYSTEM=="usb", ATTRS{product}=="Black Magic Probe", GROUP="dialout"

Add your userName to group dialout:

sudo usermod -a -G dialout userName

Download and install the crate which parses and dumps the TRACESWO output. It needs a nightly build of the Rust toolchain:

rustup default nightly
cargo install itmsink

Your Linux system environment is now ready to start with the first demo-firmware project on the Nucleo-144 STM32L4R5 demo board, using the Drone-OS toolchain and the Drone-OS unikernel library!

Written by alfred

1 Comment

  1. emil

    Test Comments


Submit a Comment

Your email address will not be published. Required fields are marked *