How to use effeciatly Trace with FreeRTOS

Hello all,

I am using Trace with FreeRTOS.
I am declaring a queue as a global variable, and I am using void vCreatQueue in the main after MX_xxxx_Init for init.
I have a problem with the trace when I do it this way.
Trace stuck in HardFault_Handler function. Apparently, the queue variable should be declared before the vTraceEnable(TRC_START).

This is frustrating for me because I have to change all my code and, I think this is not an efficient way to use Trace!

Thank you in advance for your help,
S.Tarik

I’m not clear if you mean declare the queue variable or create the queue before vTraceEnable() is called - but I don’t think there is such a restriction in either case. Take a look at some of the examples in the download that integrate trace as a reference. For example:


( https://github.com/FreeRTOS/FreeRTOS/tree/master/FreeRTOS/Demo/WIN32-MSVC )

Thank you, Richard,
The example project “WIN32-MSVS”, confirms that all queues must be declared after vTraceenable(…).
In this example, another function is called after the vTraceEnable(), in this function the Queues is instantiated and used.

    indent preformatted text by 4 spaces
int main( void )
{
	/* This demo uses heap_5.c, so start by defining some heap regions.  heap_5
	is only used for test and example reasons.  Heap_4 is more appropriate.  See
	http://www.freertos.org/a00111.html for an explanation. */
	prvInitialiseHeap();

	/* Initialise the trace recorder.  Use of the trace recorder is optional.
	See http://www.FreeRTOS.org/trace for more information. */
	**vTraceEnable( TRC_START );**

	/* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top
	of this file. */
	#if ( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 )
	{
		**main_blinky();**
	}
	#else
	{
		/* Start the trace recording - the recording is written to a file if
		configASSERT() is called. */
		printf( "\r\nTrace started.\r\nThe trace will be dumped to disk if a call to configASSERT() fails.\r\n" );
		printf( "Uncomment the call to kbhit() in this file to also dump trace with a key press.\r\n" );
		**uiTraceStart();**

		**main_full();**
	}
	#endif

S.Tarik

Which hardware platform are you using? Would you please share your code snippets for both working and non-working case?

Thanks.

Hello,
I am using the stm32f429 discovery board from ST.
I contact TraceAnalyzer for support and I ask them the same question. Their answer was this.

vTraceEnable should not be called after vCreateQueue, it should be called before.

First you need to have your clock initiated then you can call vTraceEnable. And vTraceEnable must be called before any calls to FreeRTOS it made.

Best regards
Fredrik

One thing I am 100% sure of is if you declare a queue before vtraceenable, trace would not work.

My c code after:

/* USER CODE BEGIN 1 */

/* USER CODE END 1 */

/* MCU Configuration--------------------------------------------------------*/

/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();

/* USER CODE BEGIN Init */
#if ( configUSE_TRACE_FACILITY == 1 )

vTraceEnable(TRC_START);

#endif

#if STATIC_TASK
xSemaphore = xSemaphoreCreateBinaryStatic(&xSemaphoreBuffer);
#endif
/* USER CODE END Init */

/* Configure the system clock */
SystemClock_Config();

/* USER CODE BEGIN SysInit */

/* USER CODE END SysInit */