ChibiOS/RT 2.4.0 RTOS update

I have updated the ChibiOS/RT library to version 2.4.0.

This library is a simple way to use the ChibiOS/RT RTOS on 328 and Mega Arduinos.

The download is at

The main new thing for AVR is support for pal (digital I/O). If you want to try this edit halconfig.h and change line 47 to this.

#define HAL_USE_PAL                 TRUE

I have not tested pal, just checked that it compiles with the above define. A lot of edits will be required since the default board is a Olimex AVR-MT-128 proto board.

There are a huge number of internal changes. The diff between 2.2.8 and 2.4.0 versions of the utility folder in the Arduino library has 4739 lines.

There are a lot of new files. Most of the new files are for features not supported for AVR


Thanks for your effort porting to ChibiOS, I was searching for something similar, because programming without an RTOS sometimes is not easy (and i don't want to start one more discussion about bare metal programming vs RTOS, it just depends on the complexity, even for such a limited device there is space for a RTOS in my opinion, usefull for some types of requirements). The problem I face in your porting is how to use it. i'm not familiar with ChibiOS, can you give some tips on how to use your port? From what I saw in the readme you are integrating it in the Arduino environment, so the IDE will still be the Arduino even using the ChibiOS (something like the DuinOS)? Does it work with the Arduino 022? or with 1.0? And the diferent folders, I didn't understand well what to change between the supplied folders and the original files from the chibiOS. If you can give some tips on how to do it it will be great!

Best regards


Very nice indeed. Thanx very much.

I've read that the delay function does not work (correctly?) in an interrupt handler routine. Can delay (or standard libs that use delay - like LCD) be used in the threads of ChibiOS?

The Arduino delay function will block all lower priority threads or all threads if used in an interrupt routine.

Arduino delay is just a loop that does not release the CPU:

void delay(unsigned long ms)
    uint16_t start = (uint16_t)micros();

    while (ms > 0) {
        if (((uint16_t)micros() - start) >= 1000) {
            start += 1000;

You should use ChibiOS thread functions like:

void chThdSleep (systime_t time) Suspends the invoking thread for the specified time.

void chThdSleepUntil (systime_t time) Suspends the invoking thread until the system time arrives to the specified value.

You can use scheduler functions to put a thread to sleep or wake a thread.

You can often use synchronization functions in place of delay.

Documentation is here

Wow, nice documentation! The pages are very clear, the tree is great, and the references to the actual code. Is the underlying structure of those webpages available to other groups? Thanks.