Dear Friends,
after some time of evaluation of software architecture for Multipilot32 I decide to put on it a Real Time Operating Systems.
Instead of choose FreeRtos or other clone . I found this interesting operating system that yet support HAL .
Above there's an introduction of Chibi OS , what do you think about ? My idea is to rewrite the lib of our Arducopter project using a professional approach with a Realtime Kernel on low level OS call.
A video of Chibios User that develop his quadcopter ... :)
I'm waiting your feedback :)
This is official Discussion Thread : http://www.virtualrobotix.com/forum/topics/multipilot32-need-a-rt-os-what
Chibios Introduction :
This document will help you understand what ChibiOS/RT has to offer in a world with so many similar products.
Why another RTOS:
The first question to be answered is: there was really the need for yet another RTOS? There are several reasons:
- The ChibiOS/RT ancestor has been created more than 15 years ago and while it had far less features than the current product it was complete and functioning. ChibiOS/RT is just a new (and silly) name given to something created when there were not many free RTOSs around (actually none, at least none in my knowledge, there was no widespread Internet at that time).
- When, after a while, I needed a RTOS again, none of the existing FOSS projects met my expectations or my ideas of how a RTOS should be. I decided that work on that old project was a better idea than contribute to, or fork, something else.
- I wanted another toy.
How is different ?
Well, there are some design choices that should be explained and contribute to make ChibiOS/RT a peculiar design. Nothing really new in itself but the whole is interesting.
Not Just a scheduler.
While the ChibiOS/RT kernel can be used even alone, see the General Architecture document, the RTOS also offers other subsystems:
- Support for startup and board initialization.
- An HAL abstracting many common device drivers, see the Features Matrix.
- Integration with other open source projects like File Systems, Networking Stacks etc.
ChibiOS/RT is meant to be a whole operating system not just a scheduler.
Static Design.
Everything in the kernel is static, nowhere memory is allocated or freed, there are three allocator subsystems but those are optional and not part of core OS, dynamic services are built as a layer on top of the fully static kernel.
Safety is something you design in, not something you can add later, using memory allocation in the kernel is unnecessary and relying on that is just asking for trouble.
No Internals structure and tables.
The kernel has no internal tables, there is nothing that must be configured at compile time or that can overflow at run time, no upper bounds, the internal structures are all dynamic even if all the objects are statically allocated.
No error Condition.
System APIs have no error conditions, all the previous points are finalized to this objective. Everything you can invoke in the kernel is designed to not fail unless you pass garbage as parameters, stray pointers for examples. The APIs are not slowed down by parameter checks, parameter checks (and consistency checks) do exist but only when the related debug switches are activated.
All the static core APIs always succeed if correct parameters are passed. Exception to this rule are the optional dynamic APIs that, of course, can report memory exhausted.
Very Simple API.
Each API function should have the parameters you would expect for that function and do just one thing with no options.
Fast and Compact.
Note, first “fast” then “compact”, the focus is on speed and execution efficiency and then on code size. This does not mean that the OS is large, the kernel size with all the subsystems activated weighs around 5.5KiB (STM32, Cortex-M3), see the section ”Performance and Testing Data” for more details about performance and footprint.
It would be possible to make something even smaller but:
- It would be pointless, it is already really small.
- I would not trade efficiency or features in order to save few bytes.
Test and Metric.
I think it is nice to know how an OS is tested and how it performs before committing to use it. Test results on all the supported platforms and performance metrics are included in each ChibiOS/RT release. The test code is released as well, all the included demos are capable of executing the test suite and the OS benchmarks. See the section ”Performance and Testing Data” for more details about performance and footprint.
Comments
@Henrik: I can tell you that while I wrote my quad software using ChibiOS, I also asked myself whether I shouldn't just run boiler-plate code and write my own timer-based scheduler. On the first quad I built, I ran very bare-bones code on an Atmega328 (does not even use Arduino libraries). When I ported this code to the ARM platform and ChibiOS, setting up the hardware via the OS (serial for telemetry, PWM, DAC over DMA, etc...) was much easier and less error-prone. Adding GPS and mouse sensor navigation later in separate threads was also much easier than trying to fiddle it in my Atmega code.
I guess it is in the nature of most microcontroller projects using an RTOS that they are still much closer to the hardware than an application written for a more traditional OS...
Marko
@Henrik,
i would put a Real Time OS on MP32 because it's a good improvment of stability and scalability of our system . For example is possible to put a SD on MP32 and logging in realtime the data of sensor or fly info without loss of performances. Another my idea is to implement a Script language on CLI in arducopter project . For this feature wee need multitasking available for mantain a good performances. This is only some simple example . Another feature is that you can improve the device driver without change the main code and obtain better performances. Inside a OS there're a lot of function available for evaluate the level of performances of system and define fault toulerant functionality. At the end using OS you can introduce an Hardware abstraction layer that could you develop a firmware that is totally independent to the hardware . So if you change the micro controller you only change the driver and the systems continue to work.
@Marko,
congratulation for you beautifull work !! .
I try to use ChibiOS/RT on MP32 . Can I ask you some help with i2c device ? I spoke today with Giovanni and he told me that is available to support MP32 RT project this is a great news for our community :)
when using an os think also about a debugger.
the best os is not really helpfull without debugger.
a clean c++ concept is also a good starting point.
i already posted the link for c++ and freertos.
this would be a starting point for me
Hi Robero,
I am actually the guy in the video with the ChibiOS based quad.
I can definitely recommend ChibiOS as a good choice for an RTOS. I am doing all my development using a development board with a serial bootloader, I don't even own a JTAG debugger. ChibiOS has been stable enough so far that I haven't felt the need to actually debug something this way...
One caveat about the HAL in ChibiOS: there is no official support for I2C in the currently latest version. I managed to use somebody else's implementation and patch it into ChibiOS, but it is not yet an official part of the OS. I believe it is planned to be included in future releases.
Giovanni (the author of ChibiOS) seems to be actively improving ChibiOS - he is also extremely helpful when it comes to questions in the support forum.
Let me know if you have any questions, I might even be able to answer them ;-) (I am by no means an expert in RTOS, though...).
Marko
May I express my admiration for the Quad stability performance that is achive in your video.
As for the technical aspects exposed, I feel luky that guys like you work on these issues.
Thanks for shearing
Bernard