Browsed by
Month: May 2016

Using Docker for Bitcraze Fun on Mac OS X

Using Docker for Bitcraze Fun on Mac OS X

Docker is the new hotness for Crazyflie development. The Bitcraze boys have a number of Docker VM images that can be used for everything from firmware builds to website editing! Pretty cool stuff. It takes a little setup though, and this is how to do it…

Install the Docker Environment

The easiest way to do this is to download the Docker Toolbox installer and run it. Keep in mind, you need to be running OS X 10.8 or later for compatibility. I just used the defaults for this installer. It installs all the Docker binaries in /usr/local/bin. At the end of the installation, I chose to run the “Docker Quickstart Terminal” which installed the docker engine.

Install the Bitcraze toolbelt

The toolbelt is a set of scripts that allow you run a VM instance, perform a build, and watch the VM instance disappear into the ether leaving only your build product. It’s magical. In the Terminal simply run the following to install it:

docker run --rm -it bitcraze/toolbelt

Add an alias to your .bashrc file

To easily use the Bitcraze Docker toolbelt environment, it’s best to add an alias that you can quickly type in your terminal. Here’s what to do…

cat <<EOM >> ~/.bashrc
alias tb='docker run --rm -it -e "HOST_CW_DIR=${PWD}" -e "CALLING_HOST_NAME=$(hostname)" -v ${PWD}:/tb-module -v ${HOME}/.ssh:/root/.ssh -v /var/run/docker.sock:/var/run/docker.sock bitcraze/toolbelt'

Now, you simply need to type tb to run the toolbelt! Cool!!

Clone the Crazyflie firmware

To build Crazyflie firmware, you first need to clone the crazyflie-firmware git repository from GitHub. This is pretty easy. Switch to the directory you’d like to clone the repository into (e.g. ~/Documents) and run the clone. Then pull down the required submodules.

cd ~/Documents
git clone
cd crazyflie-firmware
git submodule init
git submodule update

Run a Crazyflie firmware build

This part is insanely simple now. To run a firmware build, it’s only a matter of changing into the crazyflie-firmware directory and running the toolbelt build.

tb build

The process is awesome! Not only does it run a build, it also runs system tests. At the end of the build, you’re left with binary and dfu file ready for flashing.

You can also specify arguments to the Makefile on the tb command line. For instance, to build firmware for the Crazyflie Nano (1.0), clean the build and then specify the platform.

tb build clean
tb build PLATFORM=CF1

What could be easier and more consistent!?

The next time you want to build, make sure you run the Docker QuickStart Terminal application (it’s in /Applications/Docker), then just cd to your crazyflie-firmware directory in the Terminal window that opens and run tb build. It’s incredibly easy and consistent.