ArduPilot port to ChibiOS

This forum is about you. Feel free to discuss anything is related to embedded and electronics, your awesome projects, your ideas, your announcements, not necessarily related to ChibiOS but to embedded in general. This forum is NOT for support.
tridge
Posts: 141
Joined: Mon Sep 25, 2017 8:27 am
Location: Canberra, Australia
Has thanked: 10 times
Been thanked: 20 times
Contact:

ArduPilot port to ChibiOS

Postby tridge » Sat Jan 20, 2018 7:58 am

I thought it may interest some people that ArduPilot (see http://ardupilot.org/) now supports ChibiOS.
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

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: ArduPilot port to ChibiOS

Postby Giovanni » Sat Jan 20, 2018 11:47 am

Hi,

Very interesting and thanks for the detailed explanation, I am glad you found ChibiOS so useful.

Feel free to comment about ArduPilot on this board if you think it could help.

Giovanni

tridge
Posts: 141
Joined: Mon Sep 25, 2017 8:27 am
Location: Canberra, Australia
Has thanked: 10 times
Been thanked: 20 times
Contact:

Re: ArduPilot port to ChibiOS

Postby tridge » Sat Jan 20, 2018 10:21 pm

Thanks Giovanni!
One question I had was about the STM32 DMA_MSK values. We noticed that there are some DMA channel options missing in the ChibiOS headers. For example, STM32_SPI1_TX_DMA_MSK for the F412 is missing the (2,2) option from the datasheet. Is this deliberate due to some other conflict or is it a bug?
Same thing for the (1,1) stream in STM32_I2C1_TX_DMA_MSK
We can submit a patch to fix these if there isn't some reason why they were omitted.
Cheers, Tridge

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: ArduPilot port to ChibiOS

Postby Giovanni » Sun Jan 21, 2018 8:45 am

Hi,

The STM32 HAL is very complex, when you see such things, even if in doubt, just post in the "bug reports" forum so we can verify. Posting patches is appreciated.

Giovanni


Return to “User Projects”

Who is online

Users browsing this forum: Bing [Bot] and 6 guests