User Tools

Site Tools


Getting started developing for Crazyflie

This page aims at documenting how to start developing with Crazyflie. This document should work for both Crazyflie 1 and Crazyflie 2.0.

Prerequisite and assumption

To develop for Crazyflie you should have a Crazyflie (1 or 2.0) and a Crazyradio (PA). Jtag or SWD programming cable is not strictly required, though if you plan on doing complex development it is very advised.

As for software, this page assumes you are running the bitcraze VM 0.6, it makes it a lot easier to describe a unified enviroment. The virtual machine runs under VirtualBox with 1G of RAM, it means that you will need a computer on Windows, Linux or Mac OS with 4G of ram to run it. Alternatively you can install the required development environment on your machine.

Crazyflie firmware is witten in C. To modify it you should know how to program in C and having some embedded system experience is a plus. Just keep in mind that Crazyflie 1 has 20K of ram and Crazyflie 2.0 196K (which is pretty big by our standard!).

The official host-side lib and client is written in Python so knowledge of python is advised. There are good online material to learn python.

Third party libs and clients exists in other languages as well. Though, for the beginning, it might be easier getting some thing to work in python as it is updated along with the firmware.

All source code repository are managed with Git and hosted on github. You need to be familiar with git in order to save your work and be able to contribute code back.

System architecture

Compiling and flashing the firmware


Clone the crazyflie-firmware project, or update it using the virtual machine “Update all projects” script. For Crazyflie 2.0 or Crazyflie Nano (1.0) make sure the current branch is “master.”

~$ cd projects/crazyflie-firmware/
crazyflie-firmware$ git checkout master     # For Crazyflie Nano (1.0) or Crazyflie 2.0

Then make the firmware.

For Crazyflie 2.0:

crazyflie-firmware$ make
  DFUse cf2.dfu
Crazyflie 2.0 build!
Build 54:b4b7a369d1f4 (2015.08.1-54) CLEAN
Version extracted from git
Crazyloader build!
   text	   data	    bss	    dec	    hex	filename
  85844	   1248	  29856	 116948	  1c8d4	cf2.elf
rm version.c

Or, for Crazyflie Nano (1.0):

crazyflie-firmware$ make PLATFORM=CF1
  DFUse cf1.dfu
Crazyflie Nano (1.0) build!
Build 54:b4b7a369d1f4 (2015.08.1-54) CLEAN
Version extracted from git
Crazyloader build!
   text	   data	    bss	    dec	    hex	filename
  66068	    356	  19796	  86220	  150cc	cf1.elf
rm version.c

To program using the radio bootloader:

For Crazyflie 2.0:

crazyflie-firmware$ make cload

Or, for Crazyflie Nano (1.0):

crazyflie-firmware$ make cload PLATFORM=CF1


Note on programming cables

To be able to flash code without using the radio and to debug it a Jtag or SWD cable is needed.

  • Crayzyflie 1 works with JTAG
  • Crazyflie 2.0 works with SWD/SWV

By default any cable supported by openODC can be used. STLink-V2 is used by the Bitcraze team. Other cables like JLink can also be used but will require to manually enter the flashing command line and to modify Eclipse configuration.

Makefiles are configured to use STLink-V2 by default, to configure another programming cable create a file named in the project root folder:

OPENOCD_INTERFACE ?= interface/stlink-v2.cfg
OPENOCD_TARGET    ?= target/stm32f4x_stlink.cfg

The SEGGER J-LINK can be used for debugging and flashing.

  • Download and install a recent version of OpenOCD, you will need at least version 0.9.
  • (Optional) Download and install (or extract) the J-Link Software. The following was tested with version 5.10u.
  • In order to flash the NRF51, add the following to your crazyflie2-nrf-firmware/
OPENOCD_INTERFACE ?= interface/jlink.cfg
OPENOCD_TARGET    ?= target/nrf51.cfg
OPENOCD_CMDS      ?= -c "set WORKAREASIZE 0" -c "transport select swd"
  • In order to flash the STM32, add the following to your crazyflie-firmware/tools/make/
OPENOCD_INTERFACE ?= interface/jlink.cfg
OPENOCD_TARGET    ?= target/stm32f4x.cfg
OPENOCD_CMDS      ?= -c "transport select swd"
  • If there is an error, you can execute the following once and type connect in the command prompt. This fixes issues in case openOCD left the J-Link in an invalid state.
./JLinkExe -device STM32F405RG -if swd -speed 4000

Command line

From command line the flash make target flashed the firmware using programming cable

make flash


Working with cflib

Modifying and running the client

Running cflib examples

Contributing code back

Finding more information

Tips and Tricks


The EEPROM stores configuration data, which persists even after a firmware update. You might want to reset this information. For example, if you forget the address of your Crazyflie, you won't be able to connect wirelessly anymore. In order to reset the EEPROM, follow the following steps:

  1. Unplug your Crazyradio
  2. Connect the Crazyflie to the PC using a USB-cable
  3. Execute the following from the examples of crazyflie-lib-python:

This will find your first Crazyflie (which is the one you connected over USB) and write the default values to the EEPROM.

doc/crazyflie/dev/starting.txt · Last modified: 2016-09-20 21:26 by whoenig