uxTaskGetSystemState x Compilation error

Please Help me,

I try use the freeRTOs command is not working?

The compilation error:

I would like to know where I am going wrong?

What should I do ?

My code:

extern "C"{
      #include "freertos/FreeRTOS.h"
      #include <freertos/task.h>
      #include "freertos/timers.h"
      #include "freertos/queue.h"


          xTaskCreatePinnedToCore(v_PrintTask, "v_PrintTask", 4096, NULL, tskIDLE_PRIORITY, &Handle_PrintTask, tskNO_AFFINITY);

void v_PrintTask(void *parameters) {
      while(1) {
              UBaseType_t numTasks;
              TaskStatus_t *taskStatusArray;
              numTasks = uxTaskGetNumberOfTasks();
              taskStatusArray = (TaskStatus_t *)pvPortMalloc(numTasks * sizeof(TaskStatus_t));
              if (taskStatusArray != NULL) {
                  numTasks = uxTaskGetSystemState(taskStatusArray, numTasks, NULL);
                  for (int i = 0; i < numTasks; i++) {
                      Serial.printf("Task Name: %s, Status: %s, Priority: %u, Stack High Water Mark: %u\n",
                            (taskStatusArray[i].eCurrentState == eRunning ? "Running" : "Blocked"),

          vTaskDelay(1500 / portTICK_PERIOD_MS);

The compilation error:

/home/allacmc/.arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /tmp/arduino/sketches/758AE0273AE4F87A05FA14066003C8E7/sketch/objs.a(MapaTemperatura_LVGL_v4.ino.cpp.o):(.literal._Z11v_PrintTaskPv+0xc): undefined reference to `uxTaskGetSystemState'
/home/allacmc/.arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /tmp/arduino/sketches/758AE0273AE4F87A05FA14066003C8E7/sketch/objs.a(MapaTemperatura_LVGL_v4.ino.cpp.o): in function `v_PrintTask(void*)':
/home/allacmc/Arduino/MapaTemperatura_LVGL_v4/MapaTemperatura_LVGL_v4.ino:321: undefined reference to `uxTaskGetSystemState'
collect2: error: ld returned 1 exit status
Multiple libraries were found for "SD.h"
  Used: /home/allacmc/.arduino15/packages/esp32/hardware/esp32/2.0.11/libraries/SD
  Not used: /home/allacmc/.arduino15/libraries/SD
exit status 1

Compilation error: exit status 1

Please define configUSE_TRACE_FACILITY to 1 in your FreeRTOSConfig.h:

#define configUSE_TRACE_FACILITY 1

I’m using the Arduino IDE, I don’t have a FreeRTOSConfig.h file that I can use.

Or is he hidden?

Where am I going wrong?

Thanks for helping me

You MUST have a FreeRTOSConfig.h, as that is required by FreeRTOS. You IDE may just be hiding it. If it actually actively makes it so you can’t edit it, then you need to file a ticket with their support about it.

I find the config file in:

Please Help me:

Whereas I found the freertos.h file this way.

What is the correct approach?

To include this define in my code?

Which of the two commands?



#define configUSE_TRACE_FACILITY 1

I tested both and it didn’t work. Always gives compilation error

You can give a try to the options mentioned in this link , looks like Arduino ESP32 IDE might have an option to enable trace facility from menu config

menuconfig->Component config->FreeRTOS->Enable FreeRTOS trace facility

I read the entire suggested post.

And I found the proposed solution very complex.

I honestly gave up on using this command on the Arduino.

I have to migrate to ESP-IDF and there is no way.

Are you able to execute idf.py from your command line?

I have ESP-IDF on another machine and I use FreeRTOS together with ESP-IDF.

It is a Linux machine (ubuntu) prepared just for this.

The help I’m asking for is a program that was already written in Arduino IDE and migrating it to ESP-IDF would take a lot of time. So I try to fix it inside the Arduino IDE.

I gave up on making this command work in the Arduino IDE.

The Arduino IDE is not a 100% prepared environment for FreeRTOs. It has a lot of abstraction.

I am not familiar with Arduino IDE but there must be a way to edit FreeRTOSConfig.h. In the image you shared above, there is a section:

    #define configUSE_TRACE_FACILITY  1

Can you try changing it to the following:

 #define configUSE_TRACE_FACILITY  1