Firmware
Now that your environment is ready, it’s time to get your hands dirty with the drone’s code.
In this section, you will learn how to download, configure, and compile the firmware that runs on the Crazyflie, getting everything ready to test your own code on the real drone.
Visual Studio Code
We will use Visual Studio Code as our IDE.
- Download and install Visual Studio Code from its official website.
Repository
Before you start programming, we need to bring the firmware code to your machine. We’ll do this in two steps: first, you create a copy (fork) of the repository, and then you donwload (clone) that copy to your computer.
Fork
- Create a fork of the repository that contains the firmware into your GitHub account.
Clone
-
Open Visual Studio Code.
-
Open a terminal window by clicking Terminal > New Terminal(1).
- You can also use the shortcut Ctrl + Shift + '.
Important
If you are using Windows, Visual Studio Code opens a PowerShell terminal by default. You must initialize the WSL terminal first:
wsl -
Clone your forked repository and initialize all Git submodules(1):
- Git submodules are like “repositories inside repositories”, and they are initialize with the the
--recursiveflag.
git clone --recursive https://github.com/username/quadcontrol-firmware.gitImportant
You must replace
usernamewith your GitHub username. - Git submodules are like “repositories inside repositories”, and they are initialize with the the
-
Open the project folder by clicking File > Open Folder....
Structure
The repository is composed of two folders and two files:

Let’s take a closer look at each one:
crazyflie-firmware– Folder that contains the Crazyflie firmware, which we use as a submodulesrc– Folder that contains the programs we will develop throughout the courseKbuild– File that defines which program will be compiledradio.config– File that defines the radio channel used to communicate with the Crazyflie
The src folder contains a subfolder called examples with two example programs: led_blink.c and hello_world.c. Open these files to see some very simple example programs:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | |
We define which program will be compiled through the Kbuild file:
| Kbuild | |
|---|---|
1 | |
As we develop new programs, don’t forget to update the Kbuild file with the name of the program you want to compile.
Important
Note that the file extension here is .o, not .c. What matters is that the program name matches exactly.
Configure
Now that you have the firmware on your machine, let’s adjust some important configurations. These settings ensure everything is properly aligned with your Crazyflie before compiling the code.
Radio Channel
-
Open the
radio.configfile. -
Change the radio channel according to your Crazyflie configuration:
radio.config 1RADIO_CHANNEL=1
Bypass the Stabilizer
-
Navigate to
crazyflie-firmware/src/modules/srcand open thestabilizer.cfile. -
Comment out lines 223–226, 326, and 356, as shown below(1):
- We do this to bypass the proprietary Crazyflie control algorithm. It will continue running in the background, but its commands will be ignored so that we can use our own control logic.
stabilizer.c221 222 223 224 225 226 227
static void setMotorRatios(const motors_thrust_pwm_t* motorPwm) { // motorsSetRatio(MOTOR_M1, motorPwm->motors.m1); // motorsSetRatio(MOTOR_M2, motorPwm->motors.m2); // motorsSetRatio(MOTOR_M3, motorPwm->motors.m3); // motorsSetRatio(MOTOR_M4, motorPwm->motors.m4); }326//stateEstimator(&state, stabilizerStep);355 356 357
} else { // motorsStop(); }
Select the Hardware Platform
-
Configure the firmware for the Crazyflie 2.1 Brushless platform by running the following command in the terminal:
make cf21bl_defconfig
Compile and Upload
With the firmware properly configured, it’s time to turn it into something the drone can understand. We will compile and upload it to the Crazyflie. This process will be repeated every time you want to test a new version of your program.
Build
- Compile the firmware:
make
Flash
-
Upload the firmware to the Crazyflie:
make cloadImportant
- The Crazyflie 2.1 Brushless must be powered on
- The Crazyradio PA must be connected to a USB port
Connect and Test
All set! Now let’s connect to the drone using the Crazyflie Client and verify that your code is running correctly. If everything is working as expected, you’ll see messages appearing in the console — and your drone will officially be under your control.
-
Open the Crazyflie Client:
cfclientImportant
If you are using Windows, this is the only command that must be run in PowerShell terminal instead of WSL.
-
Click on Scan button
-
Select the corresponding Crazyflie.
-
Click on Connect button
-
Verify that the quadcopter is responding (battery voltage, sensor status, etc.).
-
Click on View > Toolboxes > Console
-
Check whether messages from your code appear (for example, "Hello world!").
If no messages appear, you are most likely still running the led_blink.c program instead of hello_world.c. Update your Kbuild file to point to the correct program, then recompile and flash the firmware again.