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


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 ]    [ 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