ChibiOS port of ArduPilot

Hi All,
I am placing this topic up for discussion and collaboration on the ChibiOS port of APM. The project will be hosted @ https://github.com/bugobliterator/ardupilot-chibios , followed with PR to master repo . The major benefit I am expecting out of this port is smaller footprint and ease of moving across broad range of ARM devices specifically STM32Fxx series. I am currently taking STM32F412 Nucleo board as a reference platform. I see future ports to be done for wide variety of stm32fxx ranging from revo mini boards to Pixhawk 2!

Please feel free to share views on this post and if anyone wants to collaborate, fork the repository mentioned above and make PRs to it.

8 Likes

this is great Sid! Really looking forward to it.

very interesting work Sid!

1 Like

Recent Update: a maiden flight with Ardupilot running over ChibiOS on Pixhawk 2.1 Cube and all the sensors that are in it were active and had the same configuration as in Nuttx platform.

There are some ways to go to complete the full port, but this is a big milestone and progress until this has validated a lot of potential that comes with us using ChibiOS as a platform for APM.

Special thanks to Tridge for helping to make this port a success!!

4 Likes

fantastic, great work Sid!

I thought I’d mention some of the scheduling results we’re getting with ChibiOS.
Testing on a PH2.1 cube with 3 IMUs (two running at 8kHz), two baros and two compasses, we get:

APM: PERF: 0/4000 max=2829 min=2124 avg=2500 sd=89
APM: PERF: 0/4000 max=2829 min=2170 avg=2500 sd=89
APM: PERF: 0/4000 max=2833 min=2170 avg=2500 sd=88
APM: PERF: 0/4000 max=2830 min=2170 avg=2499 sd=88
APM: PERF: 0/4000 max=2835 min=2171 avg=2500 sd=90
APM: PERF: 0/4000 max=2831 min=2188 avg=2499 sd=87
APM: PERF: 0/4000 max=2830 min=2170 avg=2500 sd=88
APM: PERF: 0/4000 max=2831 min=2123 avg=2499 sd=89
APM: PERF: 0/4000 max=2829 min=2190 avg=2500 sd=90
APM: PERF: 0/4000 max=2829 min=2171 avg=2499 sd=91
APM: PERF: 0/4000 max=2830 min=2121 avg=2500 sd=90
APM: PERF: 0/4000 max=2829 min=2166 avg=2499 sd=87
APM: PERF: 0/4000 max=2834 min=2167 avg=2500 sd=92

that shows a scheduling accuracy worst case deviation of just over 300usec, with zero scheduling misses. Given it is doing 7k SPI transactions per second that is remarkable.

the total cpu load shown by SYS_STATUS.load is about 20%.

For comparison, on the current px4-v3 PX4/NuttX build with the same board, we get this:

APM: PERF: 39/4000 max=3851 min=2177 avg=2510 sd=128
APM: PERF: 38/4000 max=4080 min=2165 avg=2510 sd=126
APM: PERF: 36/4000 max=3591 min=2209 avg=2508 sd=116
APM: PERF: 40/4000 max=3702 min=2176 avg=2509 sd=123
APM: PERF: 40/4000 max=3880 min=2119 avg=2509 sd=124
APM: PERF: 41/4000 max=3800 min=2135 avg=2509 sd=122
APM: PERF: 39/4000 max=3839 min=2113 avg=2508 sd=123

and a SYS_STATUS.load of around 38%. The worst case scheduling deviation is over 1500usec, so 5x worse than with ChibiOS and nearly double the average CPU load. This is despite us having put a lot of effort into improving the NuttX results over the past year.

I think this is an extremely promising port.

wow,that’s great,how to build?

very interesting

is there an “obvious” reason for why chibios is so much better, or is it the result of many many little things?

@RobertWZ build procedure for current repo is via waf. so you would do ./waf configure --board pixhawk-cube and then ./waf --target bin/arducopter and so on. Since this is under heavy development, build breaking and change in board name could happen.

@olliw42 I decided to go with chibios because of its peripheral HAL layer which makes it easy to port APM without writing much code for hardware peripherals. Its lightweight nature and portability among famous ARM controllers made it a good choice as well. Also my own existing familiarity with chibios also played a role to this choice. We were only to move forward with ChibiOS if it trumps existing RTOS on majority of the counts. So far it looks like it, but we will know more as we spend more time with it.

Autoconfiguration : enabled
Setting board to : pixhawk-cube
Checking for program ‘arm-none-eabi-ar’ : /opt/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-ar
Using toolchain : arm-none-eabi
Checking for ‘g++’ (C++ compiler) : /usr/lib/ccache/arm-none-eabi-g++
Checking for ‘gcc’ (C compiler) : /usr/lib/ccache/arm-none-eabi-gcc
Checking for program ‘make’ : /usr/bin/make
Checking for program ‘arm-none-eabi-objcopy’ : /opt/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-objcopy
Checking for program ‘st-flash’ : not found
Could not find the program [‘st-flash’]

Fixed, removed dependency to st-flash

great ,no need PX4Firmware and nuttx.

No, But you do need ChibiOS submodule

Siddharth and I have created a gitter channel to discuss the work being done on this:

just stay it here - ArduCopter at 1kHhz

PERF: 0/10000 max=1112 min=883 avg=1000 sd=9
PERF: 0/10000 max=1150 min=889 avg=999 sd=10
PERF: 0/10000 max=1112 min=890 avg=1000 sd=10
PERF: 0/10000 max=1151 min=882 avg=1000 sd=9
PERF: 0/10000 max=1105 min=892 avg=999 sd=8
PERF: 0/10000 max=1121 min=877 avg=999 sd=10
PERF: 0/10000 max=1129 min=869 avg=1000 sd=9
PERF: 0/10000 max=1151 min=889 avg=1000 sd=9
PERF: 0/10000 max=1112 min=880 avg=1000 sd=10
PERF: 0/10000 max=1121 min=875 avg=1000 sd=9
PERF: 0/10000 max=1148 min=878 avg=999 sd=11
PERF: 0/10000 max=1149 min=883 avg=999 sd=9
PERF: 0/10000 max=1132 min=865 avg=1000 sd=10
PERF: 0/10000 max=1424 min=892 avg=1000 sd=11
PERF: 0/10000 max=1108 min=892 avg=1000 sd=9
PERF: 0/10000 max=1113 min=884 avg=1000 sd=9
PERF: 0/10000 max=1108 min=889 avg=1000 sd=10
PERF: 0/10000 max=1148 min=884 avg=1000 sd=10

seems little better, isn’t it? :slight_smile:

For applications that put a heavy load on the autopilot, this will be life altering. For example, if you’re running a mavlink gimbal, logging the gimbal status, ADS-B, co-computer, GCS, etc all at once, it really loads it up. On my Solo with all of that stuff, it’s 2500/10000 max 8000. Horrid. I think ChibiOS will make a big difference in those applications.

The ChibiOS PR has been merged to master. That PR supports the following boards (and variants of them):

  • pixhawk
  • pixhawk2
  • pixracer
  • mindpx-v2

there is still plenty more to do, but it is great to get this initial work merged.

that is impressive! Is that still running the AHRS update at 1kHz? Or has this been cut down in some way?

fantastic, congratulations !!!

one point confuses me:
With the latest master would it still be possible to compile for “Nuttx”, for which all features are available, or is master ChibiOS-only now and one would have to wait if a feature is missing?
If it still can be compiled for Nuttx, what would I have to change to my compile procedure (I’m using the make-based px4 toolchain on Win), or does using make with the parameters as before will do what it did before?

(I would think there would be new parameters for compiling for chibios, so that nothing changes, but some statements I read confused me, hence my questions)

THX

The procedures for building with Nuttx are unchanged and still work. And that’s what people should still use unless they want to be test pilots for ChibiOS.

Make based builds are no longer even used or supported in ArduPilot. WAF is has been the build system of choice for quite some time. So if you’re using something really old with make, it does not and never will build ChibiOS anyway.