Up till now most of the autopilot boards we support in the ArduPilot project have been running on top of NuttX. We have done a ChibiOS port to gain more efficiency (it is smaller and faster), plus to gain the advantages of a much simpler RTOS to deal with.
We've been really surprised by the performance gains we've had with ChibiOS. We're seeing a huge drop in CPU usage, plus a big reduction in flash size. Some of the features of our port are:
- we implemented a easier way to do DMA sharing between peripherals in our ArduPilot HAL (AP_HAL), see https://github.com/ArduPilot/ardupilot/ ... ed_dma.cpp for details. This made a big difference as it means we can do DMA on a lot more peripherals
using CCM memory on the STM32F427 for key computationally intensive threads really helps
Perhaps the most unusual aspect of our port is the way we generate the needed #defines for the ChibiOS HAL. We start with a board definition file called "hwdef.dat", like this:
https://github.com/ArduPilot/ardupilot/blob/master/libraries/AP_HAL_ChibiOS/hwdef/fmuv3/hwdef.dat
then that gets processed as part of the build using a python script here:
https://github.com/ArduPilot/ardupilot/blob/master/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py
and it generates a hwdef.h file, which is what the port uses. An example output file is here:
http://uav.tridgell.net/tmp/fmuv3-hwdef.h
the python script uses tables that we auto-extracted from the STM32 datasheets to automatically resolve DMA conflicts and fill in all the alternate functions. For example, the STM32F412.py tables are here:
https://github.com/ArduPilot/ardupilot/blob/master/libraries/AP_HAL_ChibiOS/hwdef/scripts/STM32F427xx.py
Using this approach makes it extremely easy to add new boards to ArduPilot. The hwdef.dat format is meant to be easy for board designers to cope with, and can be written pretty much directly from the schematic. It doesn't support the wealth of MCUs that ChibiOS supports (there are quite a few STM32 specific things in there), but for our needs it saves a lot of effort.
The ArduPilot developer community would like to extend a huge thank you to the ChibiOS developers (and especially Giovanni) for the fantastic job you have done with ChibiOS. This is going to be flying in a lot of model aircraft soon!
Cheers, Tridge