Browsed by
Category: Development

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'
EOM

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 https://github.com/bitcraze/crazyflie-firmware.git
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.

Unified Firmware Source Code

Unified Firmware Source Code

In my last post on compiling Crazyflie firmware on Mac OS X, I mentioned that the band at Bitcraze had plans to eventually merge the Crazyflie 2.0 firmware source with the Crazyflie Nano (1.0) source on the master branch and now they have done it! Crazyflie Nano (1.0) and Crazyflie 2.0 firmware source code is now unified in the Bitcraze crazyflie-firmware GitHub repository on the “master” branch. This is really great news because it makes building for either (or both) targets even easier now! Read on for updated instructions on building Crazyflie firmware on Mac OS X given the new unified firmware source…

Read More Read More

Reflashing the Bootloader

Reflashing the Bootloader

When I first set-up Eclipse on Mac to allow me to do some debugging on my Crazyflie 2.0, I built and flashed a debug version of the firmware for the first time. The “debug” target in Eclipse creates a build with the parameter “CLOAD=0.” This means that the debug firmware is flashed at the start of the Crazyflie 2.0’s STM32 flash memory. This where the radio bootloader is normally written so, if one existed before flashing debug firmware, it doesn’t exist after it. In any case, I spent a while scratching my head months later when, while trying to update my Crazyflie 2.0 firmware over-the-air (OTA), I found the Crazyradio couldn’t connect to the bootloader! Of course! There wasn’t one there any longer.

For a moment I panicked, thinking I’d smashed something important when I built my debug firmware, then I remembered an obscure thing I’d read on the wiki about DFU

Read More Read More

Compiling Crazyflie 2.0 Firmware on Mac OS X

Compiling Crazyflie 2.0 Firmware on Mac OS X

UPDATE 2015-Aug-01: Bitcraze has recently merged the Crazyflie Nano (1.0) and Crazyflie 2.0 firmware source code. As a result, it is even easier to build firmware for either model on Mac OS X. See my article on the merge for more information on building the firmware.

About six months ago I wrote a entry on compiling Crazyflie firmware with Mac OS X. Since that time, the Crazyflie 2.0 has come out and, as a result, compilation of firmware for the new model requires a new GCC-ARM development environment. This post explains what you need to do to compile firmware for the Crazyflie 2.0 on Mac OS X.

Read More Read More

Compiling Crazyflie Firmware on Mac OS X

Compiling Crazyflie Firmware on Mac OS X

UPDATE 2015-Aug-01: Bitcraze has recently merged the Crazyflie Nano (1.0) and Crazyflie 2.0 firmware source code. As a result, it is even easier to build firmware for either model on Mac OS X. See my article on the merge for more information on building the firmware.

Since I’m a Mac user, like I mentioned in my “Preparation” post, I naturally wanted to compile the Crazyflie firmware directly on a Mac. Of course, the Bitcraze boys provided a virtual machine that I can run on my Mac, but I don’t want to always use the virtual machine. Furthermore, if I can cross-compile on a Linux distro, obviously I can do it on Mac OS X as well. Since the STM32 MCU the Crazyflie uses is an ARM Cortex processor, I was worried it would be a nightmare setting up the toolchain build environment. I was pleasantly surprised to find out it wasn’t hard at all!

Read More Read More