Quality RTOS & Embedded Software

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


Hardfault when jumping to app from bootloader

Posted by https://www.google.com/accounts on September 3, 2013
Hi All,

I’m using an STM32F407 and IAR EWARM version 6.50.6
I have an old non FreeRTOS boot loader at address 0x08000000 and a FreeRTOS main application at address 0x08010000. I can download via my boot loader and jump to my application fine. Obviously the jump to the main application occurs when the CPU is using the MSP.

My new boot loader now contains FreeRTOS and replaces the old boot loader.
When I attempt to jump from a task in the boot loader to the main application, I get a hard fault.
This happens since the task in the boot loader was using the PSP and this area of SRAM gets initialized when the main application starts causing a function to return to address 0.

I have read other posts and realize I need to be using MSP when I jump to the main application, not the PSP.

I therefore generated an interrupt from within the boot loader task so the CPU was using the MSP and performed the jump.
Before the jump (but from within the IRQ Handler), I stop the FreeRTOS timer, disable all IRQ’s and clear all pending IRQ’s in the NVIC.
I then perform the jump to the main application from within the IRQ Handler.

The jump works fine and the main FreeRTOS based application goes through all its initialization clearing SRAM, creating tasks and queues etc.
I now get a hard fault when “svc 0” is executed within vPortStartFirstTask()
I assume this is caused by the fact that the IRQ_Handler I was executing within the boot loader is still “ACTIVE” as per the NVIC->IABR[].

Can anyone suggest the solution please, or correct my assumptions?


RE: Hardfault when jumping to app from bootloader

Posted by https://www.google.com/accounts on September 4, 2013
Hi All,

I have seen the error of my ways!

The fix to my issue involved:
1. Creating the boot loader task that jumps to the main application with portPRIVILEGE_BIT set
2. __set_CONTROL(0); // Change from PSP to MSP
3. __set_MSP(*(__IO uint32_t*) APP_START_ADDRESS);
4. jumpToApplication()

I hope this post helps others.



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

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

Latest News

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

Version 10.1.1 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