Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Debugging tasks with IAR EWARM

Posted by Christopher Coley on May 10, 2008
I am running into an issue where it looks like a stack is getting corrupted, however I have substantially increased all the stack size to much larger than necessary and still get strange execution.

Basically what is happening is that when I start a task and then break with IAR the call stack shows that a piece of code completely unrelated to the started task is being executed. As best I can tell it appears that it wasn't even started at the top of the function, hence my belief that the stack got corrupted.

I have two tasks running to start off with.

1. Is a debug tasks taking messages from a queue and putting them out a serial port, as such allowing any other task to put messages on that queue for output. It also has an ISR taking serial input and putting it in another queue

2. Is a command line interface that builds up and allows execution of commands using the queue mentioned for the debug task. One of the commands I have implemented is "ps" that uses vTaskList to output the current task list and status. Other commands allow initialization and starting of the other tasks mentioned above.

The output of ps before starting another task. As you can see there is a fair amount of stack available.
Task Stat Pri Free TCB#
CmdLine R 1 616 1
Debug R 1 26 0
IDLE R 0 107 2

When I start another task this strange execution path is taken and I can no longer interact.

Now I understand why the data structures for the queue's, task's etc... are private and from the API everything is void* however this makes debugging painful. Has anyone, or wouldn't it be a good idea, to have debug versions of the structures such that IAR would allow expansion so visability into the kernel would be available. Alternatively has anyone created a plug-in for the IAR tools to make them FreeRTOS aware?


RE: Debugging tasks with IAR EWARM

Posted by Christopher Coley on May 10, 2008
Found my own solution to the problem by doing what I suggested before.

The issue was in the xPortStartScheduler function in port.c. It was assuming that the vector table was at address 0.

vPortStartFirstTask( *((unsigned portLONG *) 0 ) );

We are running from a bootloader and so there is a different stack and vector table so I changed it to.

vPortStartFirstTask( *((unsigned portLONG *) __sfb(".intvec") ) );

This way it gets the startup stack correctly from the active vector table. This would also work by getting the vector table from the Cortex-M3 SCB->ExceptionTableOffset.


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

Version 10.1.0 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers


STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner