This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
doc:crazyflie:dev:starting [2015-02-23 12:07] arnaud |
doc:crazyflie:dev:starting [2020-05-12 14:16] kimberly |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | <WRAP center round important 60%> | ||
+ | This page has deprecated and moved to the new documentation framework of the main Bitcraze website. Please go to [[https:// | ||
+ | </ | ||
+ | |||
+ | |||
+ | ====== 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 [[projects: | ||
+ | |||
+ | 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 [[http:// | ||
+ | |||
+ | ===== System architecture ===== | ||
+ | |||
+ | ===== Compiling and flashing the firmware ===== | ||
+ | ==== STM32 ==== | ||
+ | |||
+ | Clone the crazyflie-firmware project, or update it using the virtual machine " | ||
+ | |||
+ | < | ||
+ | ~$ cd projects/ | ||
+ | crazyflie-firmware$ git checkout master | ||
+ | </ | ||
+ | |||
+ | Then make the firmware. | ||
+ | |||
+ | For **Crazyflie 2.0**:< | ||
+ | crazyflie-firmware$ make | ||
+ | (...) | ||
+ | DFUse cf2.dfu | ||
+ | Crazyflie 2.0 build! | ||
+ | Build 54: | ||
+ | Version extracted from git | ||
+ | Crazyloader build! | ||
+ | | ||
+ | 85844 | ||
+ | rm version.c | ||
+ | crazyflie-firmware$ | ||
+ | </ | ||
+ | |||
+ | Or, for **Crazyflie Nano** (1.0):< | ||
+ | crazyflie-firmware$ make PLATFORM=CF1 | ||
+ | (...) | ||
+ | DFUse cf1.dfu | ||
+ | Crazyflie Nano (1.0) build! | ||
+ | Build 54: | ||
+ | Version extracted from git | ||
+ | Crazyloader build! | ||
+ | | ||
+ | 66068 | ||
+ | rm version.c | ||
+ | crazyflie-firmware$ | ||
+ | </ | ||
+ | |||
+ | 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 | ||
+ | </ | ||
+ | ==== NRF51 ==== | ||
+ | ==== 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 // | ||
+ | < | ||
+ | OPENOCD_INTERFACE ?= interface/ | ||
+ | OPENOCD_TARGET | ||
+ | </ | ||
+ | |||
+ | ==J-LINK== | ||
+ | |||
+ | The SEGGER J-LINK can be used for debugging and flashing. | ||
+ | |||
+ | * Download and install a recent version of [[http:// | ||
+ | * (Optional) Download and install (or extract) the [[https:// | ||
+ | * In order to flash the NRF51, add the following to your crazyflie2-nrf-firmware/ | ||
+ | < | ||
+ | OPENOCD_INTERFACE ?= interface/ | ||
+ | OPENOCD_TARGET | ||
+ | OPENOCD_CMDS | ||
+ | </ | ||
+ | * In order to flash the STM32, add the following to your crazyflie-firmware/ | ||
+ | < | ||
+ | OPENOCD_INTERFACE ?= interface/ | ||
+ | OPENOCD_TARGET | ||
+ | OPENOCD_CMDS | ||
+ | </ | ||
+ | |||
+ | * 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 | ||
+ | </ | ||
+ | |||
+ | === Eclipse === | ||
+ | |||
+ | |||
+ | |||
+ | ===== Working with cflib ===== | ||
+ | ==== Modifying and running the client ==== | ||
+ | ==== Running cflib examples ==== | ||
+ | ===== Contributing code back ===== | ||
+ | ===== Finding more information ===== | ||
+ | ===== Tips and Tricks ===== | ||
+ | ==== Reset EEPROM ==== | ||
+ | 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: | ||
+ | - Unplug your Crazyradio | ||
+ | - Connect the Crazyflie to the PC using a USB-cable | ||
+ | - Execute the following from the examples of [[https:// | ||
+ | < | ||
+ | python3 write-eeprom.py | ||
+ | </ | ||
+ | | ||
+ | |||
+ | This will find your first Crazyflie (which is the one you connected over USB) and write the default values to the EEPROM. | ||
+ | |||