Call stack and tracing

nobody wrote on Saturday, September 03, 2005:

I’m working on the '1611 IAR port - I tried getting the trace utility to work - but I was hoping you could give a quick glance at this and reply.  I was wondering if this is a ‘normal’ looking call stack to have while FreeRTOS is running & then issuing a break:

xQueueReceive(0xFFFF,0x1456, 0)

rtel wrote on Saturday, September 03, 2005:


This would not be an unexpected call stack, although the address 0xCCCC look suspicious.

Here are some tips on using the trace utility with IAR.

+ Ensure configUSE_TRACE_FACILITY is #defined to 1.

+ Define a buffer into which the trace will be placed.  Eg char

cBuf[ 4096 ];

+ At some point in the code, maybe on some event, insert a call to vTaskStartTrace() to start the trace.

+ The trace will automatically end when the buffer is full.

+ Pause the debugger, then open up a memory window (select Memory from the View menu).

+ Right click in the Memory pain and select Memory Upload from the pop up menu.

+ You will be prompted for the start address (the address of the first byte within the trace buffer, in this example cBuf) and length of the buffer.  In the Zone drop down box I have always just select Memory.

+ When you click OK you will be prompted for a file name into which the memory dump should be stored.  Choose trace.hex as the file name (the name is important as the trace conversion utility is somewhat crude and does not give you the opportunity to select a file name).

+ A hex file called trace.hex will be stored to your hard disk (unsurprisingly).  The trace utility requires a binary file, so convert the hex into a binary file.  I use hex2bin.exe for this purpose.  See  You should now have a file called trace.bin.

+ Copy tracecon (little endian?) into the directory in which trace.bin is stored and execute it.  This will produce a file called trace.txt.

+ Open trace.txt in Excel (or equivalent).  The binary will pack a load of 0s at the start of the file up to the address at which your buffer was stored.  Delete all the leading zero rows, up to the first valid row which has non zero numbers.  [you can delete the padding from a binary editor if there are too many lines for Excel to play with.  Alternatively you can provide an offset to the hex2bin utility to prevent it packing with zeros].

+ If you now draw a scatter graph of the first two columns you should get a graph as depicted on the FreeRTOS WEB site.

Hope this helps.


btoland wrote on Tuesday, June 19, 2007:


Many thanks for the very useful post!  Got me sorted with the trace.