Quality RTOS & Embedded Software

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




Loading

AVR32UC3A Ethernet Port - Stack Issues

Posted by S M on March 6, 2008
I am writing an application based on the Ethernet Interface demo app for FreeRTOS, and am having trouble with what I think is a stack overflow issue.

When my code is linked, memory is allocated as follows:

0x7448 to 0xEFFF for the heap
0xF000 to 0xFFFF for the stack

On startup, my code initializes the power manager on the AVR32, and initializes external SRAM and a couple ADCs.

It then calls vStartEthernetTask, which starts the ethernet task included in the demo app, but modified to handle the data that I send to it over ethernet (a few switch statements, nothing major).

Up until this point, the stack point is in the 0xFFxx range, as it should be, as not much has happened yet.

The next call is to vTaskStartScheduler(), which is where the problem is. By tracing this call using the JTAG MkII debugger, I see that the code calls xPortStartScheduler() in port.c. This then calls portRESTORE_CONTEXT(), which is defined in portmacro.h to be a bunch of assembly code (I'm not really sure what it does).

As soon as portRESTORE_CONTEXT() executes, the stack pointer jumps way down into the 0x7exx range, obliterating a bunch of the heap. The code continues to run fine for a while (the stack pointer stays in the same 0x7exx area) but eventually I get data_address or bus_read (or similar) errors, which I am assuming are due to the heap being corrupted.

Any ideas why the stack gets so massive when initializing the scheduler?

Thanks

RE: AVR32UC3A Ethernet Port - Stack Issues

Posted by Dave on March 6, 2008
I don't know about avr32 specifics but what you describe is what I would expect to see.

When you create a task the stack used by the task is allocated from the heap. Remember that each task has its own stack. Once the first task is started the stack pointer should be pointing some place within your heap.

RE: AVR32UC3A Ethernet Port - Stack Issues

Posted by S M on March 6, 2008
That makes sense. Thanks.


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




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

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

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