- Name runtime pct core prio
- loopTask 8361337 89% 1 1
- IDLE0 9270465 99% 0 0
- IDLE1 14782 <1% 1 0
- CAN_RX_25 218240 2% 1 24
- 100Hz_CAN_send_ 144393 1% 1 3
- tiT 11428 <1% 0 18
- 10Hz_CAN_send_t 19815 <1% 1 1
- LED blinker 2382 <1% 0 0
- CAN_WD_BI 4471 <1% 1 10
- 1Hz_CAN_send_ta 75161 <1% 1 1
- CAN_RX_24 195768 2% 1 24
- Tmr Svc 36 <1% 0 1
- ipc0 3502 <1% 0 24
- network_event 18 <1% 1 19
- eventTask 23 <1% 0 20
- CAN_RX 27 <1% 2147483647 15
- CAN_LORX 20 <1% 1 19
- mdns 141 <1% 0 1
- esptimer 4469 <1% 0 22
- ACAN2517Handler 60268 <1% 2147483647 24
- ACAN2517Handler 215147 2% 2147483647 24
- ipc1 22592 <1% 1 24
Undefined Reference to "uxTaskGetSystemState" Upon Any Attempt to Use.
- Fuzzyzilla
- Posts: 22
- Joined: Sun Apr 23, 2017 3:19 am
Undefined Reference to "uxTaskGetSystemState" Upon Any Attempt to Use.
Hello!
I have just started freeRTOS and I wanted to do some debugging of my tasks. I wrote a function to display all task states using "uxTaskGetSystemState()" but any attempt to use this function results in the following error:
C:\Users\...\AppData\Local\Temp\arduino_modified_sketch_317958/sketch_nov20a.ino:3: undefined reference to `uxTaskGetSystemState'
This happens on all computers I've tried it on. All other freeRTOS functions I've tried work fine, just not this one.
What can I do to fix this?
Thanks!
I have just started freeRTOS and I wanted to do some debugging of my tasks. I wrote a function to display all task states using "uxTaskGetSystemState()" but any attempt to use this function results in the following error:
C:\Users\...\AppData\Local\Temp\arduino_modified_sketch_317958/sketch_nov20a.ino:3: undefined reference to `uxTaskGetSystemState'
This happens on all computers I've tried it on. All other freeRTOS functions I've tried work fine, just not this one.
What can I do to fix this?
Thanks!
Re: Undefined Reference to "uxTaskGetSystemState" Upon Any Attempt to Use.
This function requires configUSE_TRACE_FACILITY=1. You have to check this option in menuconfig:
Code: Select all
menuconfig->Component config->FreeRTOS->Enable FreeRTOS trace facility
Re: Undefined Reference to "uxTaskGetSystemState" Upon Any Attempt to Use.
If we visit the Github for the ESP-IDF and do a search for uxTaskGetSystemState() we eventually find this source:
https://github.com/espressif/esp-idf/bl ... ks.c#L2287
If we look at the source, we see that it only gets compiled in if the configUSE_TRACE_FACILITY is set to 1.
We can set this in the "make menuconfig" within FreeRTOS > Enable FreeRTOS trace facility.
Switch this on and recompile. If that doesn't help, please post back and we'll try something else.
https://github.com/espressif/esp-idf/bl ... ks.c#L2287
If we look at the source, we see that it only gets compiled in if the configUSE_TRACE_FACILITY is set to 1.
We can set this in the "make menuconfig" within FreeRTOS > Enable FreeRTOS trace facility.
Switch this on and recompile. If that doesn't help, please post back and we'll try something else.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
- Fuzzyzilla
- Posts: 22
- Joined: Sun Apr 23, 2017 3:19 am
Re: Undefined Reference to "uxTaskGetSystemState" Upon Any Attempt to Use.
Thank you both for your answers. Do I have to install ESPIDF to access these options?
Edit: I tried changing the config file manually, that didn't help.
(tried setting CONFIG_FREERTOS_USE_TRACE_FACILITY to 'y' , '1', and 'true' and then recompiling in arduino.)
Edit: I tried changing the config file manually, that didn't help.
(tried setting CONFIG_FREERTOS_USE_TRACE_FACILITY to 'y' , '1', and 'true' and then recompiling in arduino.)
Re: Undefined Reference to "uxTaskGetSystemState" Upon Any Attempt to Use.
Im not sure but maybe try to change this option in sdkconfig.h
It is in sdk/include/config folder
Or change this file and set default value to y
https://github.com/espressif/esp-idf/bl ... onfig#L288
It is in sdk/include/config folder
Or change this file and set default value to y
https://github.com/espressif/esp-idf/bl ... onfig#L288
- Fuzzyzilla
- Posts: 22
- Joined: Sun Apr 23, 2017 3:19 am
Re: Undefined Reference to "uxTaskGetSystemState" Upon Any Attempt to Use.
Yeah, I've scanned through the different files changing them to 1, it still doesn't work...
Re: Undefined Reference to "uxTaskGetSystemState" Upon Any Attempt to Use.
Ahh just noticed that you are using Arduino. It may be that the ESP-IDF distributed with the Arduino version you are using pre-dates the latest ESP-IDF into which this option was recently added. You'd want to check the ESP-IDF commit history and find out what this option was added and then compare that against the ESP-IDF distributed by Arduino. If Arduino ESP-IDF distribution pre-dates that then this suggestion won't work as described and you would either have to find a new solution or wait for the Arduino ESP-IDF distibution to catch up.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: Undefined Reference to "uxTaskGetSystemState" Upon Any Attempt to Use.
I managed to make this work with the following steps:
[*]run git log in arduino-esp32 to find the latest tagged IDF (3.1 in my case)
[*]checkout that tag in esp-idf
[*]copy sdkconfig from arduino-esp32/tools/sdk/sdkconfig to esp-idf/examples/get-started/blink/sdkconfig
[*]run make menuconfig in esp-idf/examples/get-started/blink, turn on the options mentioned above
[*]make
[*]copy build/freertos/libfreertos.a to Arduino/hardware/expressif/esp32/tools/sdk/lib/
[*]copy build/esp32/libesp32.a to Arduino/hardware/expressif/esp32/tools/sdk/lib/
After doing these steps, I was able to compile this example: https://www.freertos.org/uxTaskGetSystemState.html
with the following changes
[*]use uxTaskGetNumberOfTasks() instead of uxCurrentNumberOfTasks()
[*]hack the task status data out of memory. I've still messed something up because sizeof(TaskStatus_t) evaluates to 36, but the actual struct size in memory was 40. I offset the pointers manually. Please do pardon my language.
This forum is fine, but BBcode is an awful impediment. Good Night.
[*]run git log in arduino-esp32 to find the latest tagged IDF (3.1 in my case)
[*]checkout that tag in esp-idf
[*]copy sdkconfig from arduino-esp32/tools/sdk/sdkconfig to esp-idf/examples/get-started/blink/sdkconfig
[*]run make menuconfig in esp-idf/examples/get-started/blink, turn on the options mentioned above
[*]make
[*]copy build/freertos/libfreertos.a to Arduino/hardware/expressif/esp32/tools/sdk/lib/
[*]copy build/esp32/libesp32.a to Arduino/hardware/expressif/esp32/tools/sdk/lib/
After doing these steps, I was able to compile this example: https://www.freertos.org/uxTaskGetSystemState.html
with the following changes
[*]use uxTaskGetNumberOfTasks() instead of uxCurrentNumberOfTasks()
[*]hack the task status data out of memory. I've still messed something up because sizeof(TaskStatus_t) evaluates to 36, but the actual struct size in memory was 40. I offset the pointers manually. Please do pardon my language.
- void print_shit(void)
- {
- char *str = (char *)malloc(sizeof(char) * 2000);
- memset(str, 0, 2000);
- char *pcWriteBuffer = str;
- TaskStatus_t *pxTaskStatusArray;
- volatile UBaseType_t uxArraySize, x;
- unsigned long ulStatsAsPercentage;
- uint32_t ulTotalRunTime;
- /* Make sure the write buffer does not contain a string. */
- *pcWriteBuffer = 0x00;
- /* Take a snapshot of the number of tasks in case it changes while this
- function is executing. */
- uxArraySize = uxTaskGetNumberOfTasks();
- /* Allocate a TaskStatus_t structure for each task. An array could be
- allocated statically at compile time. */
- Serial.printf("sizeof TaskStatus_t: %d\n", sizeof(TaskStatus_t));
- pxTaskStatusArray = (TaskStatus_t*)pvPortMalloc( uxArraySize * sizeof(TaskStatus_t));
- memset(pxTaskStatusArray, 0, uxArraySize * sizeof(TaskStatus_t));
- if( pxTaskStatusArray != NULL )
- {
- /* Generate raw status information about each task. */
- Serial.printf("Array size before: %d\n", uxArraySize);
- uxArraySize = uxTaskGetSystemState( pxTaskStatusArray,
- uxArraySize,
- &ulTotalRunTime );
- Serial.printf("Array size after: %d\n", uxArraySize);
- Serial.printf("Total runtime: %d\n", ulTotalRunTime);
- /* For percentage calculations. */
- ulTotalRunTime /= 100UL;
- /* Avoid divide by zero errors. */
- if( ulTotalRunTime > 0 )
- {
- /* For each populated position in the pxTaskStatusArray array,
- format the raw data as human readable ASCII data. */
- Serial.printf(" name runtime pct core prio\n");
- for( int x = 0; x < uxArraySize; x++ )
- {
- TaskStatus_t *fuckit;
- void *tmp = &pxTaskStatusArray[x];
- void *hmm = tmp + (4 * x);
- fuckit = (TaskStatus_t*)hmm;
- // Serial.printf("Name: %.5s, ulRunTimeCounter: %d\n", fuckit->pcTaskName , fuckit->ulRunTimeCounter);
- /* What percentage of the total run time has the task used?
- This will always be rounded down to the nearest integer.
- ulTotalRunTimeDiv100 has already been divided by 100. */
- ulStatsAsPercentage =
- fuckit->ulRunTimeCounter / ulTotalRunTime;
- if( ulStatsAsPercentage > 0UL )
- {
- sprintf( pcWriteBuffer, "%30s %10lu %10lu%% %5d %5d\n",
- fuckit->pcTaskName,
- fuckit->ulRunTimeCounter,
- ulStatsAsPercentage,
- *((int *)(&fuckit->usStackHighWaterMark)+1),
- fuckit->uxBasePriority);
- }
- else
- {
- /* If the percentage is zero here then the task has
- consumed less than 1% of the total run time. */
- sprintf( pcWriteBuffer, "%30s %10lu %10s %5d %5d\n",
- fuckit->pcTaskName,
- fuckit->ulRunTimeCounter,
- "<1%",
- *((uint32_t *)(&fuckit->usStackHighWaterMark)+1),
- fuckit->uxBasePriority);
- }
- pcWriteBuffer += strlen( ( char * ) pcWriteBuffer );
- // Serial.printf("len: %d, idx: %d\n", pcWriteBuffer - str, x);
- }
- Serial.print(str);
- }
- /* The array is no longer needed, free the memory it consumes. */
- // vPortFree( pxTaskStatusArray );
- // free(str);
- }
- }
Re: Undefined Reference to "uxTaskGetSystemState" Upon Any Attempt to Use.
Looks familiar
I wonder if this is any help to tie up that loose end:
https://github.com/espressif/esp-idf/bl ... ask.h#L176
Possibly CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID is different between the relevant precompiled file and the sdkconfig that Arduino uses?
I wonder if this is any help to tie up that loose end:
https://github.com/espressif/esp-idf/bl ... ask.h#L176
Possibly CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID is different between the relevant precompiled file and the sdkconfig that Arduino uses?
Re: Undefined Reference to "uxTaskGetSystemState" Upon Any Attempt to Use.
Thanks @boarchuz, adding `-DCONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID` to the `build.extra_flags` in platform.txt was all I needed.
While this approach has provided some very useful information on tasks, it has also unfortunately broken part of the WiFi stack.
While this approach has provided some very useful information on tasks, it has also unfortunately broken part of the WiFi stack.
Who is online
Users browsing this forum: No registered users and 85 guests