Welcome to the uracoli Blog

µracoli stands for microcontroller radio communications library and is intended to be a package that demonstrates capabilities and usage of Atmel's IEEE-802.15.4 radio transceivers AT86RF{230,231,212} in combination with AVR 8 bit microcontrollers (e.g. ATmega16, ATmega1281, ATmega128RFA1, ...).

Dienstag, 18. April 2017

Using Docker Containers for Embedded Software Development


Setting up an embedded tool chain on a local PC or laptop requires very often to spend an enormous amount of time for installation and configuration of the individual software packages. It ends up in a "golden" installation on a single computer that is kept like a treasure. But with each new package installed on this computer, the golden installation is in danger.
Docker provides a light weight virtualization engine that runs on Linux, Windows or MacOS.
Docker containers contain virtual guest OSes and can easily be configured, deployed and executed. The article descibes how to create a suitable container for embedded software development and how to use it.

Installing Docker

In the first step, install docker on the local PC. We use the Docker Community Edition (Docker CE). On the docker installation
page click on your OS to get the latest installation instructions.

To run docker on Ubuntu as normal user, do
  • add the user to the "docker" group
    sudo gpasswd -a docker
  • log off and log on again
Now test the installation with the command
$ docker run hello-world

Create the first Docker Image

Create a working directory and add the file Dockerfile in it.
Edit the file Dockerfile and add the following content:

FROM ubuntu
MAINTAINER Main Tainer maintainer@example.org
RUN apt-get update \
# install packages
&& apt-get -y install \
    # build system related
    scons mercurial \
    # Python packages
    python python-pip \
    # AVR Tools
    binutils-avr gcc-avr avr-libc \
    # Documentation tools
# we skip doxygen-latex here, otherwise the image becomes "huuuuge"
RUN useradd -ms /bin/bash uracoli
USER  uracoli
RUN mkdir /home/uracoli/work
WORKDIR /home/uracoli/work
# command is running at start of the container
    echo == starting uracoli-development environment == \
    && /bin/bash

To create the image run the command:
$ docker build -t my-uracoli-env . 

The command creates an image named "my-uracoli-env".
It inherits from the latest Ubuntu installation. The "RUN" commands
  • install the standard Linux packages required to compile the µracoli project
  • create a user uracoli
  • create a working directory /home/uracoli/work
The "USER" statement makes the container run as user "uracoli" rather than "root".
The "CMD" statement at the end of the file is executed at every start of the container. It issues a message and starts bash.

First Run of the Container

After successfully creating the container, run the command
docker run -t -i my-uracoli-env
in a terminal

$ docker run -t -i u5idev
== starting uracoli-development environment ==

On this shell prompt type pwd to see that you are in the directory /home/uracoli/work.

Your first development session might start with the following commands:

uracoli@9311c77b2d54:~/work/uracoli$ hg clone http://hg.savannah.nongnu.org/hgweb/uracoli/
destination directory: uracoli
uracoli@9311c77b2d54:~/work/uracoli$ cd uracoli
uracoli@9311c77b2d54:~/work/uracoli$ scons radiofaro
scons: Reading SConscript files ...
build 1 of 104 boards

Adding some Comfort

After ending (Ctrl-D) and restarting the docker session, you will notice that the docker container is suffered  from amnesia. That means, after the next restart the directory /home/uracoli/work is empty. Also editing source code with terminal tools like "nano" or "vi" might not fit your regular development habits. To circumvent this, we simply map a local directory from the host computer into the docker container. So you can edit the files from the host machine with your favourite IDE or source-code editor. Mapping a local directory to docker is done by passing the -v option to the run command.

 docker run -v /home/axel/Work/uracoli-aw:/home/uracoli/work -it my-uracoli-env

Now you can edit the files on the host compile and compile it in the docker container.

Mapping Serial Devices into Docker

On Ubuntu it is possible to map serial devices into the docker container with the following command:
$ docker run  --device=/dev/ttyUSB0 -v .... -it my-uracoli-env

System Clean Up

While experimenting with docker, a lot of logfiles from different sessions and temporary images may waste a enormous amount of disk space. To get rid of this left overs, you can use the follwing commands on Linux/Ubuntu to clean the system

$ docker rm $(docker ps -aq)
$ docker rmi $(docker images -f "dangling=true" -q)


The article shows the first steps using docker containers for embedded software development. Containers provide an always fresh and clean environment and you can have multiple containers for e.g. different tool chain versions.

1 Kommentar:

  1. But the following are the top five areas I've found that need attention in the past few years. "(Blog)" pointers will send you to my previous blog postings on these topics.