Quality RTOS & Embedded Software

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


ARM Cortex-M3 crashed with --use_frame_pointer

Posted by bettermanlu on December 11, 2015

Our current project includes FreeRTOS, and I added --useframepointer to Keil uVision's ARMGCC compiler option. But after loading firmware into STM32F104 chip, then runs it, it crashed. Without --useframepointer, everything is OK. The hard fault handler shows that faultStackAddress is 0x40FFFFDC, which points to a reserved area. Does anyone has any idea of this error? Thanks a lot.


_asm void HardFaultHandler(void) { TST lr, #4 ITE EQ MRSEQ r0, MSP MRSNE r0, PSP B _cpp(HardFaultHandler) } void HardFaultHandler(uint32t *faultStackAddress) {

} ~~~~ I stepped into each line of code, and the crash happened in below function in FreeRTOS's port.c after I called vTaskDelete(NULL);

~~~~ void vPortYieldFromISR( void ) { /* Set a PendSV to request a context switch. */ portNVICINTCTRLREG = portNVICPENDSVSET_BIT; } ~~~~ But seems like this is not the root cause, because when I deleted vTaskDelete(NULL), crash still happened.

ARM Cortex-M3 crashed with --use_frame_pointer

Posted by rtel on December 11, 2015

I'm afraid without reading the compiler documentation, or inspecting the changes to the generated assembler code, I don't know why this would be. The code assumes the compiler generates ARM EABI compliant code, maybe using the frame pointer changes that? Why do you need that compiler option?

ARM Cortex-M3 crashed with --use_frame_pointer

Posted by bettermanlu on December 14, 2015

We'd like to unwind ARM Cortex M3 stack when crash happened, so we need to save FP(Frame Pointer) to the stack. That's why we add --useframepointer to Keil uVision's ARMGCC compiler option.

ARM Cortex-M3 crashed with --use_frame_pointer

Posted by bettermanlu on January 13, 2016

I found that if I comment out the xTimerCreateTimerTask() in vTaskStartScheduler() function, the crash does not happen. Any thoughts? Thanks.

ARM Cortex-M3 crashed with --use_frame_pointer

Posted by bettermanlu on January 13, 2016

My test code for your reference:


include "FreeRTOSConfig.h"
include "FreeRTOS.h"
include "task.h"

void crashTask(void *param) {

unsigned int i = 0;
/* halt the hardware. */
     i += 1;

} void testCrashTask() { xTaskCreate(crashTask, (const signed char *)"crashTask", configMINIMALSTACKSIZE, NULL, 1, NULL);

void HardFaultHandler(unsigned int *faultStackAddress);

/* The fault handler implementation calls a function called HardFaultHandler(). */

if defined(_CCARM)

_asm void HardFaultHandler(void) { TST lr, #4 ITE EQ MRSEQ r0, MSP MRSNE r0, PSP B _cpp(HardFault_Handler) }


void HardFaultHandler(void) { __asm("TST lr, #4"); __asm("ITE EQ"); __asm("MRSEQ r0, MSP"); __asm("MRSNE r0, PSP"); __asm("B HardFault_Handler"); }


void HardFaultHandler(unsigned int *faultStackAddress) { int i = 0; while(1) { i += 1; } }

void nvicInit(void) {

#ifdef  VECT_TAB_RAM  							
NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);  	
NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);  


int main() { nvicInit();



/* For now, the stack depth of IDLE has 88 left. if want add func to here, you should increase it. / void vApplicationIdleHook(void) { / ATTENTION: all funcs called within here, must not be blocked */ //workerProbe(); }

void debugSendTraceInfo(unsigned int taskNbr) { } ~~~~

ARM Cortex-M3 crashed with --use_frame_pointer

Posted by rtel on January 13, 2016

The timer task is a standard task, written in C, so there is nothing special about it that I am aware of. It does however give a big clue as to where you could focus your debugging. See how far you get through the function - it is actually quite small.

ARM Cortex-M3 crashed with --use_frame_pointer

Posted by bettermanlu on January 14, 2016

Seems like SP is corrupted.

Another odd thing is that if I debug it and step into the TimerTask's portYIELDWITHINAPI() function call, then resume the application. It does not crash. So my guess is that this might due to certain time sequence. But I could not find the root cause of it.

Any thoughts? Thanks.

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

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

Latest News

FreeRTOS v10.2.0 is available for immediate download. MIT licensed, and including RISC-V and ARMv8-M (Cortex-M33) demos.

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

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

Cadence Tensilica Cortes

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