In this tutorial, we’ll compile our own Cleanflight/Betaflight firmware. You might ask yourself why do I want to compile the firmware on my own instead of just using the already compiled .hex files from Cleanflight/Betaflight? Well if you are okay with the original firmware you might as well use the precompiled files. But what if you want to add/remove some features or write some of your own code? You can do that by modifying the source code, which you then have to compile into a .hex file.
You will need Linux to compile the firmware. In this post, I will only cover the compilation part. If you would like to know how to set up Linux on Windows check out this post and you if want to know how to add/remove features from Cleanflight/Betaflight then check out this one.
- arm-none-eabi-gcc --version
- sudo apt-get install gcc-arm-none-eabi
Using the cd command move wherever you want the files to be downloaded to. Then download them using git.
- cd /home/"yourusername"/
- git clone https://github.com/cleanflight/cleanflight.git
- cd cleanflight
- make TARGET=NAZE //or TARGET="any other board"
You might get the following error:
make/tools.mk:296: *** **ERROR** your arm-none-eabi–gcc is ‘4.9.3’, but ‘6.3.1’ is expected. Override with ‘GCC_REQUIRED_VERSION’ in make/local.mk or run ‘make arm_sdk_install’ to install the right version automatically in the tools folder of this repo. Stop.
More about the error.
If you do indeed get the error do the following to fix it.
- make arm_sdk_install
- make TARGET=NAZE
- sudo apt-get install python
- make clean TARGET=NAZE
- //or just
- make clean
- make TARGET=NAZE
Moded or custom build flash size(text+data) is recommended to be kept smaller than the original build.
Same goes for (static)RAM usage(data+bss).
- cp obj/cleanflight_2.5.0_NAZE.hex /mnt/c/Users/"Username"/Desktop/
- C:\Users\"Windows User"\AppData\Local\lxss\home\"Linux User"\cleanflight\obj