In this tutorial we show the steps needed to change the software running in the Crazyflie, often called firmware. We will show how to modify the source code , how to build it and finally download and flash it to your Crazyflie. These are the necessary steps to write your own code and change the behaviour of your Crazyflie.
This tutorial is based on the virtual machine where all the tools you need are installed, configured and set up to make this really easy.
We assume that you have basic knowledge of the C-programming language.
For this tutorial you need:
- A Crazyflie
- A Crazyradio PA
- A computer with the Virtual Machine (VM) installed.
For details on how to install the VM and Crazyradio see
Getting started with the Crazyflie 2.X.
Fire up the virtual machine to get started. It comes with all tools you need pre-installed and configured to make programming simple.
From this point on in the tutorial, all steps refer to actions in the virtual machine.
Double click the “update all projects” icon on the desktop. This pulls down the latest source code from GitHub for all projects.
We will start out by modifying the source code. The update of the code is minimalistic, we will change the color of the front right LED from red to green.
The pre-installed IDE (Integrated Development Environment) is Eclipse. Double click the “Eclipse” icon on the desktop to start it.
Find the “Project explorer” window on the left side and expand the “crazyflie-firmware” project.
src/drivers/interface/led.h and double click to open it.
Find the line
#define SYS_LED LED_RED_R
and change it to
#define SYS_LED LED_GREEN_R
Now it’s time to build the source code into binary files that can be downloaded to the Crazyflie.
Locate the “Make target” tab on the right side at the top (or bottom left if you are using an older VM). Expand “crazyflie-firmware” and double click “clean”
The result should be displayed in the “console” tab under the editor window.
In the toolbar, click the hammer icon
Again, the result should be displayed in the “console” tab under the editor window.
Now we have the binary files and it is time to download them to the Crazyflie and save them in the flash memory, often called flashing. Our new modified version of the firmware will replace what ever version you currently have installed. If you want to go back to the official firmware just re-flash the Crazyflie with an official release.
Turn your Crazyflie 2.X off.
Start it in bootloader mode by pressing and holding the power button for 3 seconds. Both blue LEDs will blink.
In the “Make target” window double click “Flash using radio”.
Printouts in the “Console” window shows the progress and the LEDs on the Crazyflie flicker.