I’d like to measure task execution time by using uxTaskGetSystemState in task.h
So I defined configUSE_TRACE_FACILITY and check the included path of task.h
build clean and rebuild…
but link error occurred as below.
what should I check?
c:/users/jjs/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\esp-wrover-kit\src\main.cpp.o:(.literal._Z17checkTaskExecTimev+0x8): undefined reference to `uxTaskGetSystemState'
c:/users/jjs/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\esp-wrover-kit\src\main.cpp.o: in function `checkTaskExecTime()':
C:\Users\JJS\Documents\PlatformIO\Projects\221212-140807-arduino-blink/src/main.cpp:494: undefined reference to `uxTaskGetSystemState'
#include <freertos/task.h>
...
void checkTaskExecTime(void)
{
#define TASK_NAME_LEN 16
// Get the number of tasks in the system
UBaseType_t numTasks = uxTaskGetNumberOfTasks();
// Allocate memory for the task status array
TaskStatus_t *taskStatusArray = (TaskStatus_t *)pvPortMalloc(numTasks * sizeof(TaskStatus_t));
// Get the task status array
UBaseType_t numTasksUpdated = uxTaskGetSystemState(taskStatusArray, numTasks, NULL);
// Iterate through the task status array
for (UBaseType_t i = 0; i < numTasksUpdated; i++)
{
TaskStatus_t taskStatus = taskStatusArray[i];
// Check if this is the task we are interested in
if (strncmp(taskStatus.pcTaskName, "Task", TASK_NAME_LEN) == 0)
{
// Print the execution time of the task
Serial.printf("Task execution time: %u ticks\n", taskStatus.ulRunTimeCounter);
}
}
// Free the memory allocated for the task status array
vPortFree(taskStatusArray);
}
Arduino is based on a precompiled ESP-IDF version, menaing the configXXX macros were set once, static .a files were generated, and are then included in Arduino-ESP32.
Changing the value of the macro after that fact has 0 impact on the .a file where the implementation lives. Meaning the include files will probably tell you that the function is available, but since the .a files are not recompiled, the implementation is still missing, and thus you can “undefined reference”.
I don’t want to use espidf and arduino together because of the terrible build times.
Can I install and use an external freertos library instead of the freertos built-in of the esp32 arduino framework? If I set libdeps = ext_freertos, can I use the built-in freertos overriding?
You’ll have to use GitHub - espressif/esp32-arduino-lib-builder to regenerate the .a libraries anew with your wanted target configuration, then them to replace those stored in C:\Users\<user>\.platformio\packages\framework-arduinoespressif32\tools\sdk\esp32\lib. At least libfreertos.a.
I ran the command as below, but it said that cmake needs to be registered in the PATH. Please tell me where the cmake executable is located.
$ ./build.sh -t esp32 -b menuconfig
...
'cmake' must be available on the PATH to use idf.py
idf.py -DIDF_TARGET="esp32" -DSDKCONFIG_DEFAULTS="configs/defconfig.common;configs/defconfig.esp32;configs/defconfig.qio_ram" menuconfig
ESP-IDF v4.4.3-347-g9ee3c8337d
'cmake' must be available on the PATH to use idf.py
When /build.sh -t esp32 -b menuconfig is executed, the settings of the library in esp32-arduino-lib-builder are displayed in the menu. How can I display the settings in C:\Users\JJS\.platformio\packages\framework-arduinoespressif32\tools\sdk\esp32\lib in the menuconfig menu?
For example, in the library used in the project, core dump is set to not use, but the library in esp32-arduino-lib-builder is set to flash as shown below.