Quality RTOS & Embedded Software

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


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?


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) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.

Free TCP/IP and file system demos for the RTOS

Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists