FreeRTOS TAD Runtime stat not working if optimization is used

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FreeRTOS TAD Runtime stat not working if optimization is used

Jump to solution
1,866 Views
MartinHo
Contributor IV

I have the following configuration:

MCPXpresso V10.3.1

LPC1519 CPU

FreeRTOS is configured to generate Runtime statistics

The Task List (FreeRTOS) is working ok when the Project is compiled with -O0.

But when i change to any other Optimization level the TAD plugin is not capabel to show the Runtime statistics

The TAD log for working case is:

"FreeRTOS Task Aware Debugger for GDB" version 1.0.8 (201810241449)
(c) 2016-2018 NXP Semiconductors, Inc.
==================================
09:32:35.762 INFO: [TadModel] DSF session ID 12 has started.
09:32:49.91 INFO: [TadState] TAD state changed: DEBUG_STARTED -> DEBUG_INIT_0 (RESUMED, USER_REQUEST)
09:32:49.321 INFO: [TadState] TAD state changed: DEBUG_INIT_0 -> DEBUG_INIT_1 (SUSPENDED, SIGNAL)
09:32:51.320 INFO: [TadState] TAD state changed: DEBUG_INIT_1 -> DEBUG_SUSPENDED (RESUMED, USER_REQUEST)
09:32:51.444 INFO: [TadState] TAD state changed: DEBUG_SUSPENDED -> DEBUG_SUSPENDED (SUSPENDED, BREAKPOINT)
09:32:59.513 INFO: [TadState] TAD state changed: DEBUG_SUSPENDED -> DEBUG_RESUMED (RESUMED, USER_REQUEST)
09:33:02.826 INFO: [TadState] TAD state changed: DEBUG_RESUMED -> READY (SUSPENDED, SIGNAL)
09:33:04.960 INFO: [Benchmark] Loading data for "Determine FreeRTOS version" has started.
09:33:04.967 ERROR: [VariableReader] Could not read variable expression: "&(FreeRTOSDebugConfig)".
09:33:04.973 ERROR: [VariableReader] Could not read variable expression: "sizeof(struct TaskControlBlock_t)".
09:33:04.984 ERROR: [VariableReader] Could not read variable expression: "&(((struct QueueDefinition *) 0)->pcTail)".
09:33:04.984 INFO: [TadModel] FreeRTOS version has been identified from available FreeRTOS symbols as 10,11.
09:33:04.984 INFO: [Benchmark] Loading data for "Determine FreeRTOS version" took 24 ms.
09:33:04.984 INFO: [Benchmark] Loading data for "Task List" has started.
09:33:04.991 ERROR: [VariableReader] Could not read variable expression: "sizeof(xQueueRegistry)".
09:33:04.991 ERROR: [QueueFactory] Queue registry size is zero! Each queue must be registered with vQueueAddToRegistry() and configQUEUE_REGISTRY_SIZE macro
must be greater than zero (found in FreeRTOSConfig.h)
09:33:06.888 INFO: [Benchmark] Loading data for "Task List" took 1903 ms.
09:33:16.511 INFO: [TadModel] DSF session ID 12 has ended.

while the error case is:

"FreeRTOS Task Aware Debugger for GDB" version 1.0.8 (201810241449)
(c) 2016-2018 NXP Semiconductors, Inc.
==================================
09:33:40.26 INFO: [TadModel] DSF session ID 13 has started.
09:33:53.624 INFO: [TadState] TAD state changed: DEBUG_STARTED -> DEBUG_INIT_0 (RESUMED, USER_REQUEST)
09:33:53.848 INFO: [TadState] TAD state changed: DEBUG_INIT_0 -> DEBUG_INIT_1 (SUSPENDED, SIGNAL)
09:33:55.424 INFO: [TadState] TAD state changed: DEBUG_INIT_1 -> DEBUG_SUSPENDED (RESUMED, USER_REQUEST)
09:33:55.531 INFO: [TadState] TAD state changed: DEBUG_SUSPENDED -> DEBUG_SUSPENDED (SUSPENDED, BREAKPOINT)
09:33:57.940 INFO: [TadState] TAD state changed: DEBUG_SUSPENDED -> DEBUG_RESUMED (RESUMED, USER_REQUEST)
09:33:59.588 INFO: [TadState] TAD state changed: DEBUG_RESUMED -> READY (SUSPENDED, SIGNAL)
09:34:00.894 INFO: [Benchmark] Loading data for "Determine FreeRTOS version" has started.
09:34:00.901 ERROR: [VariableReader] Could not read variable expression: "&(FreeRTOSDebugConfig)".
09:34:00.908 ERROR: [VariableReader] Could not read variable expression: "sizeof(struct TaskControlBlock_t)".
09:34:00.918 ERROR: [VariableReader] Could not read variable expression: "&(((struct QueueDefinition *) 0)->pcTail)".
09:34:00.919 INFO: [TadModel] FreeRTOS version has been identified from available FreeRTOS symbols as 10,11.
09:34:00.919 INFO: [Benchmark] Loading data for "Determine FreeRTOS version" took 25 ms.
09:34:00.919 INFO: [Benchmark] Loading data for "Task List" has started.
09:34:00.927 ERROR: [VariableReader] Could not read variable expression: "sizeof(xQueueRegistry)".
09:34:00.927 ERROR: [QueueFactory] Queue registry size is zero! Each queue must be registered with vQueueAddToRegistry() and configQUEUE_REGISTRY_SIZE macro
must be greater than zero (found in FreeRTOSConfig.h)
09:34:00.942 INFO: [FreeRTOS] FreeRTOS macro "configGENERATE_RUN_TIME_STATS" is disabled.
09:34:02.684 INFO: [Benchmark] Loading data for "Task List" took 1765 ms.
09:34:11.345 INFO: [TadModel] DSF session ID 13 has ended.

Some how the Plugin is thinking that configGENERATE_RUN_TIME_STATS is not define if the optimization is used.

Labels (1)
0 Kudos
1 Solution
1,449 Views
BlackNight
NXP Employee
NXP Employee

Hi Martin,

thanks for finding that ulTotalRuntime!

I already had to add several updates to the original FreeRTOS kernel sources to deal with compiler and linker optimizations.

There is the desire to have the kernel as compiler independent as possible, but sometimes this is really not feasible.

As for this current issue, removing the 'static' solves the problem for me. Another (and I think better) solution is to use the used attribute:

#if 1 
  PRIVILEGED_DATA static
  #ifdef __GNUC__
  __attribute__((used))
  #endif
  uint32_t ulTotalRunTime = 0UL;   /*< Holds the total amount of execution time as defined by the run time counter clock. */
#else
  PRIVILEGED_DATA static uint32_t ulTotalRunTime = 0UL;   /*< Holds the total amount of execution time as defined by the run time counter clock. */
#endif

I have now added this to our university FreeRTOS port (available on McuOnEclipseLibrary/lib at master · ErichStyger/McuOnEclipseLibrary · GitHub ). If you are interested: that port deals as well with the -lto (Link time optimization) of the GNU tool chain, search for configLTO_HELPER

Thanks,

Erich

View solution in original post

0 Kudos
4 Replies
1,449 Views
MartinHo
Contributor IV

OK I did some research by my self.

The TAD check for ulTotalRunTime, but this variable is optimized out by the compiler when the optimization level is different from -O0.

The main problem is that this variable is define static inside tasks.c.

I don't know any "trick" to prevent the compiler from optimize out a static variable define in a source file that i don't what to modify (because its part of the RTOS).

I suggest to find a other mode to determent the presents of the Real-time statistic data for a future version of the TAD (for example by trying to access ->ulRunTimeCounter of the Idle Task TCB).

best regards

Martin

0 Kudos
1,450 Views
BlackNight
NXP Employee
NXP Employee

Hi Martin,

thanks for finding that ulTotalRuntime!

I already had to add several updates to the original FreeRTOS kernel sources to deal with compiler and linker optimizations.

There is the desire to have the kernel as compiler independent as possible, but sometimes this is really not feasible.

As for this current issue, removing the 'static' solves the problem for me. Another (and I think better) solution is to use the used attribute:

#if 1 
  PRIVILEGED_DATA static
  #ifdef __GNUC__
  __attribute__((used))
  #endif
  uint32_t ulTotalRunTime = 0UL;   /*< Holds the total amount of execution time as defined by the run time counter clock. */
#else
  PRIVILEGED_DATA static uint32_t ulTotalRunTime = 0UL;   /*< Holds the total amount of execution time as defined by the run time counter clock. */
#endif

I have now added this to our university FreeRTOS port (available on McuOnEclipseLibrary/lib at master · ErichStyger/McuOnEclipseLibrary · GitHub ). If you are interested: that port deals as well with the -lto (Link time optimization) of the GNU tool chain, search for configLTO_HELPER

Thanks,

Erich

0 Kudos
1,449 Views
MartinHo
Contributor IV

Hi Daniel,

Thanks for Your answer is there any documentation what debug information is needed by the FreeRTOS TAD?

Because in some application of mine I cannot compile with -O0 (the code gets to big to fit into the flash).

Regards

Martin

0 Kudos
1,449 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Martin:

FreeRTOS TAD depends on some debug information about the kernel to properly show the information.

If this information is missing,  it will not work properly.

Regards

Daniel

0 Kudos