User Tools

Site Tools


misc:hacks:betaflight

This is an old revision of the document!


Betaflight for Crazyflie 2.0

Betaflight was originally an R&D fork fromCleanflight focused on bleeding edge performance improvements/experiments but has since become one of the most popular flight controller firmwares in use today.

One of the hallmark features of the Betaflight/Cleanflight/Baseflight ecosystem is support for an extensible “target” framework which allows the firmware to run on a wide variety of ARM chips/boards. This wiki details the CRAZYFLIE2 target.

What's Supported

This target currently supports basic functionality required to fly - motors, accel/gyro, LEDs, and handling of the syslink/crtp protocols (though, limited to commander packets) from the NRF51.

The NRF51 code was intentionally left unchanged so all existing crazyflie clients ought to continue working without modification (including Bluetooth clients). However, currently only DeviationTx and the Android mobile app have been tested. Mileage on the other clients may vary – please report findings in the forum.

The target currently doesn't support the magnetometer, the barometer, or any expansion decks. It also doesn't support many of the crazyflie core features like the logging framework, the parameter framework, etc.

Setup Instructions

WARNING: Running Betaflight on the Crazyflie 2.0 is still experimental and in development. There's very low risk of bricking or damaging your hardware (the main STM bootloader is in ROM and can't be erased), but it's recommended you only try this out if you know what you're doing and can accept a bit of risk. Access to JTAG or SWD is highly recommended and may be necessary to re-provision with the stock Crazyflie firmware/bootloader.

Building

TEMPORARY: As of this writing, the changes for the Crazyflie 2.0 target have not been merged back into the Betaflight repo – temporarily working out of a private fork. Intent is to merge into Betaflight ASAP once a few bugs in the latest Betaflight are ironed out.

Execute the following from a bash shell (uses the same toolchain as the crazyflie-firmware project – this can be done on the Bitcraze VM for example)

  1. git checkout cf2
  2. export TARGET=CRAZYFLIE2
  3. make

You should see “betaflight_3.2.0_CRAZYFLIE2.hex” appear in the obj directory of the project.

Flashing

To flash the board, follow the Betaflight flashing instructions. Be sure to choose 'full chip erase' for the first flash.

These instructions call for booting with the BOOT0 pin held high to boot the chip into DFU mode. The Crazyflie can be booted in to DFU mode without needing to short this pin. Note that the Betaflight configurator will reboot the STM32 after flashing but it will not reset the NRF51 – the whole board must be power cycled after flashing in order to restore the NRF51's Rx functionality.

Note: If you've previously installed the libusb-win32 driver on the Crazyflie 2.0 device node using Zadig in Windows, the driver must be changed before it will enumerate as a COM device after flashing. To change the driver, follow these steps:

  1. Open device manager
  2. Navigate to the 'libusb-win32' device node
  3. Right click on Crazyflie 2.0 and choose 'update drivers'
  4. select 'browse my computer for driver software'
  5. select 'let me pick from a list of available drivers on my computer'
  6. select 'USB Serial Device'

Configuring Betaflight

The defaults after flashing should be sufficient for flight.

Configuring Transmitter

The NRF51 defaults to 2mbps, channel 2.

To use a client that uses the legacy commander packet type (cfclient, mobile apps, older versions of DeviationTx) ensure the max roll/pitch angles are set to 50.0 degrees and the max yaw rate is set to 400deg/s. The handler for this packet type rescales the degree setpoint into a PWM-style value (range of 1000-2000) and assumes these values as max values when making the conversion. Using other values should work but might produce unexpected results.

Using the new CPPM Emulation commander type (supported in Deviation) is recommended.

misc/hacks/betaflight.1492032735.txt.gz · Last modified: 2017-04-12 23:32 by theseankelly