How to install the FreeRTOS in the VSCode/Platformio?

Good afternoon,

I would like to know, first if it is possible, and if the answer is yes, how to install the FreeRTOS in the VSCode/Platformio, instead to work with the version inside of Arduino Framework?

Today I need to work with heap4.c Memory Management Scheme and I need to change a lot of thing in the original FreeRTOS embedded in the Arduino Framework. Then I think that it will be better in the near future, to work with the FreeRTOS download from

Soon I will need to change to AWS FreeRTOS, because I will work with AWS IoT Core for LoRaWAN. This is one of major reasons to think now about this change.



I assume your question refers to the ESP32 series ??
All FreeRTOS functions are available in the Arduino framework for the ESP32.

What do you want to change and why do you want to change?
I fear a xy-problem.

You don’t need to adapt FreeRTOS for the ESP32 yourself. The effort would be far too high.
What you are looking for is the ESP-IDF Framework, which is based on a FreeRTOS adapted for the ESP32 (framework = espidf in the platformio.ini).

This allows you to change the SDK settings (menu-config).

No, I am using Cortex-M4, a Nordic nRF52840, with framework Arduino.

I already have a super looping architecture code that I will become it in event-drive architecture using FreeRTOS.

I didn´t find a documentation in Platformio, where I can find “how to use it”. Let me give a example:

I can´t declare any FreeRTOS library, for example, “task.h”, because I receive error messages. Everything is working fine without any FreeRTOS “# include …”

The last strange behavior was relate to “vTaskStartScheduler()”, because when I declare it, I didn´t receive any error message in the compile/linkedit process, but the firmware freezes.

Well it is working the API call like, xTaskCreate, task handle operations, like delete, suspend, list and resume. Then I am assuming that “something” is doing the “vTaskStartScheduler()” and when I declare “again”, the firmware crash. Then I guess that I don´t have to declare the vTaskStartScheduler(), but I didn´t find any documentation about framework Arduino.



Then my assumption and everything that followed was unfortunately wrong.

The Nordic nRF52 platform supports the Arduino, Mbed and Zephyr RTOS frameworks.

Implementing your own FreeRTOS will (probably) not be trivial.
I haven’t done anything like that yet.

The Adafruit nRF52 core has FreeROS built in.

So if you choose a board like board = adafruit_feather_nrf52840, you have access to FreeRTOS within Arduino.

platform = nordicnrf52
board = adafruit_feather_nrf52840
framework = arduino

You can just start calling into FreeRTOS functions directly without having to start FreeRTOS, because the Arduino core already starts it for you. In fact, it runs setup() and loop() already in a FreeRTOS task.

#include <Arduino.h>

void my_task(void* pvArgs) {
    (void) pvArgs;
    while(1) {
        vTaskDelay(1000 / portTICK_PERIOD_MS);

void setup() {
    xTaskCreate(&my_task, "my task", 512, NULL, TASK_PRIO_NORMAL, NULL);

void loop() { }


1 Like

Thank you very much Max! Your answer is exactly what I was looking for, but I didn´t find any documentation with the relationship between FreeRTOS and Arduino Framework in Platformio.

The reason that I am looking for a way to install FreeRTOS, it is the version that comes with Adafruit_nRF52_Arduino is old in Memory Management, only one heap treatment: Adafruit_nRF52_Arduino/cores/nRF5/freertos at master · adafruit/Adafruit_nRF52_Arduino · GitHub

In the FreeRTOS website we can find a Memory Management with 5 kind of management with dynamic memory allocation control:

I think you can still supress the building of the core’s heap_3.c by either using a src_filter expression or advanced scripting: