Brian's Bench

You are here: Home / Archives for Multirotor

Betaflight-f4

April 3, 2016 by Brian

Betaflight-F4 is a direct port of Betaflight to a number of F4 targets. Some code has been imported from Raceflight to get this working on the F4 targets, but it doesn’t include any of the other modifications from Raceflight. Before getting into the rest of the details, I’d like to say thanks to all who have contributed to any of the open-source flight controller firmware. None of this would be possible without such a great community.

I created this branch for some of my own development. Since some others might be interested in it I decided to make it publicly available. I have only been running it on my own experimental boards, but it should work on the other F4 targets as well. I’ll try to do bugfixes for other targets if I get feedback, but I am unable to test any of them myself. You assume all risk by trying it, and I highly recommend testing everything with a current limited power source and no props first, just to be safe.

Where to get it:
Source
Release 2.6.0

Installation:
For wiring refer to Raceflight documentation.
Make sure proper STM32 VCP and DFU drivers are installed.

OPBL targets should be able to flash using bin files as normal.

For .hex files use Cleanflight Configurator->Firmware Flasher
If flashing from an OPBL target or unflashed board, follow Recovery/Lost communication instructions in configurator.
Use ‘Load Firmware [Local]’ to select your target’s hex file, then flash.

Configuration:
Refer to Cleanflight and Betaflight documentation.

Setting looptime in configurator will currently work up to 8kHz.
Acc is always enabled on F4 targets with SPI, gets disabled over 2.6kHz on I2C targets.
PID is capped at 2.6kHz for Oneshot125 same as Betaflight.
PID is capped at 4kHz when Oneshot42 or Multishot is enabled.
PID cap can be manually overridden in the CLI by lowering pid_process_denom. (min is 1)

Known issues:

  • Configurator connection trouble: As I understand, this is an operating system related issue with the drivers for the VCP. My mac has no problems, but my linux machine does. After connecting the USB or restarting the board I have to wait 20-60 seconds before the configurator will connect. I don’t have personal experience with it, but I believe Windows problems similar to what I have with linux.
  • BLHeli Passthrough: (all methods) Reading and writing settings works, but flash new image usually fails (>90% failure rate).
  • CLI dump: You only get the last part of the data when large amounts are sent. This only happens on VCP. I haven’t tracked down the exact cause, but I’m assuming it’s related to the buffers.
  • Revo nano: There are reported problems with this on Raceflight. They will likely exist here as well. I’m willing to try to fix this, but I don’t have the hardware to test.
  • Issue with USE_SERVOS and QUAD_MIXER_ONLY: Specific settings are required in all target files or compilation fails. Proper fix will be to deal with this in code, but for now setting the tags in target files works.
  • Misc compile warnings

Filed Under: Multirotor

Fixing Blackbox in Betaflight/Cleanflight

September 24, 2015 by Brian

This is just a quick unedited log of my attempts to resolve some blackbox logging issues that recently appeared.

I tried formatting the sdcard (normally just delete logs and leave config.txt) and I’m still having the same problems. I also tried some different sdcards with no luck.

I had previously looked at the headers and everything seemed fine, but your mention of them made me look more closely. I see that random data was missing from the middle of the header in some logs, and simply cut off early by data in others.

I figured out that the specific problem was gyro scaling, but there was quite a bit of other info missing too.

my temporary fix: Get a log in angle mode with settings as close as possible to the log I want to fix and copy its header into the log with problems.

Did some more testing. Tried going back to old commits and using cleanflight master branch, and still had problems with them. Since it looks like this isn’t a betaflight problem like I had originally thought, I did some more looking and found the appropriate rcgroups thread.

Solution was found in this pull request.

Manually merged changes into latest betaflight.
There was a problem on one line because it references masterConfig.looptime.
I just set it to a static value based on the looptime of 1000 and compiled it.

<< blackboxMaxHeaderBytesPerIteration = constrain((masterConfig.looptime * 3) / 500, 1, BLACKBOX_TARGET_HEADER_BUDGET_PER_ITERATION);
>> blackboxMaxHeaderBytesPerIteration = constrain(6, 1, BLACKBOX_TARGET_HEADER_BUDGET_PER_ITERATION);

Flashed the flight controller and logs are back to normal.

Filed Under: Multirotor

Copyright © 2025 · Log in