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!
The first order of business was finding out what version of the GCC ARM embedded toolchain Bitcraze was using. That was easy enough to get from their wiki. There’s a development environment page there that lists exactly what they’re using. It clearly shows gcc-arm-none-eabi-4_7-2013q1-20130313 is the right install. So off to the the GCC ARM Embedded page at to grab the distribution package. A quick scan of the 4.7 series shows the Q1 update in the 2013 milestones and there’s a Mac distro! Hooray!!

So, I downloaded it and verified the MD5 checksums.

cd ~/Downloads
mkdir GCC-ARM; cd GCC-ARM
curl -s -S -O -L ""
curl -s -S -O -L ""
MY_MD5=$( md5 "gcc-arm-none-eabi-4_7-2013q1-20130313-mac.tar.bz2"  | awk -F' = ' '{print $2}' ); echo -e "\nMY MD5: ${MY_MD5}"
DL_MD5=$( cat +md5 | awk '{print $1}' ); echo "DL MD5: ${DL_MD5}"
if [ "${MY_MD5}" == "${DL_MD5}" ]; then echo -e "\nMD5 VERIFIED\n"; else echo -e "\nMD5 FAILED\n"; fi

Since everything looked good, I unpacked the tarball and added the directory to my path. Actually, I found that the MacPorts install I had in /opt/local caused me some trouble so, when I added gcc-arm-none-eabi to my path, I also removed /opt/local and some of the other cruft to make sure things were neat and clean.

cd ~/Downloads/GCC-ARM
tar -xjf "gcc-arm-none-eabi-4_7-2013q1-20130313-mac.tar.bz2"
export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:$( pwd )/gcc-arm-none-eabi-4_7-2013q1/bin"

That’s really all that’s needed to build the Crazyflie firmware on Mac OS X. Finally it was simply a matter of cloning the git repository and running make.

cd ~/Downloads
mkdir; cd
git clone
cd crazyflie-firmware
make all

Viola! crazyflie.bin! Firmware ready to be flashed to the STM32. Best thing about it: it was surprisingly simple to do. Thanks Bitcraze!

Here’s a bash script that will do the download and checksum for you. You just need to decompress the package, export the path, clone the repository, and run make.

Comments are closed.