Topic : FreeRTOS on STM32 problem workaround

Forum : ARM

Original Post
Post Information Post
October 27, 2010 - 1:38pm
Guest

Hi,

FYI

If you are using FreeRTOS on STM32 and using Ride default startup file from CMSIS version 3.1.0 or even 3.1.2 (supplied as source code) you may have problems depending on how lucky you are. I am using heap_2 memory model and the heap gets corrupted at start of first task. The FreeRTOS code is correct but it fetches the stack pointer from the NVIC table. And this is hardcoded to 0x20000400 which happens to be in the middle of FreeRTOS heap (or in your datastructures otherwise).

In CMSIS version 3.4.0 (at least) this has been changed to point to end of RAM instead which solves this problem. To use this version in Ride instead; Disable LD Linker|Startup|Use Default Startup and add the appropriate startup_stm32f10x_xx.s file to the project instead.

g_pfnVectors:
.word Initial_spTop // Hardcoded to 0x20000400

3.4.0:
g_pfnVectors:
.word _estack

It is the FreeRTOS port.c function vPortStartFirstTask() that references the default stack entry.