Quality RTOS & Embedded Software

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


STM32F4 bootloader with freeRTOS+TCP

Posted by unknown49 on December 14, 2016


I am working on a project that requires a us to push updates to our embedded board. We have already developed the API for getting the updates from the server and storing it in Flash.

We know need a bootloader that automatically applies that update by overwriting flash with the binary file. Can anyone provide help on doing this. I am hoping that someone may have already implemented a bootloader this.

We have a basic idea on how to write the bootloader but not sure what required on freeRTOS side, since RTOS won't be starting at the resert vector (0x8000000)

STM32F4 bootloader with freeRTOS+TCP

Posted by heinbali01 on December 14, 2016

For which platform / MCU are you developing?

Both your application as well as your bootloader can run FreeRTOS. Each program has its own interrupt table and its own copy of the kernel. The compiler will make sure that your main() will get called, and that function will start the FreeRTOS kernel. It sounds like your bootloader will need some code to read the binary image and to program the application flash.

STM32F4 bootloader with freeRTOS+TCP

Posted by dibosco on December 14, 2016

I've done bootloaders for the STM32F4. The vital thing is to reset the VTOR register to point to the new vector table and clear and disable all interrupts before you jump to the new app as well as stopping the sys tick - the latter has really stumped me in the past. I had a situation where I was jumping to the new app, the sys tick timer went off and was trying to jump to the next thread before any threads were initialised!

This kind of thing works well for me going from a run to complete or from FreeRTOS.


typedef void (*pFunction)(void); pFunction JumpToApplication;


void JumpToNormalApplication(void) {

    volatile uint32_t JumpAddress;
    uint32_t temp;

   // Disable all interrupts

// Clear pendings NVIC->ICPR[0] = 0xFFFFFFFF; NVIC->ICPR[1] = 0xFFFFFFFF; NVIC->ICPR[2] = 0xFFFFFFFF;

// Stop sys tick temp = SysTick->CTRL; temp &= ~0x02; SysTick->CTRL = temp;


     JumpAddress = *(volatile unsigned long*) (APPLICATION_START_ADDRESS + 4);
     Jump_To_Application = (pFunction) JumpAddress;

} ~~~

This is for going from bootloader to the new, updated, application. For going the other way (if relevant) use the same type of thing, but change:




Please note that the APPLICATIONSTARTADDRESS will change depending on how big the bootloader is. I've managed to fit a USART one into a very small amount of flash; USB and Ethernet versions obviously take a lot more space. Only you'll be able to know - when you've finished the bootloader. Remember to check for page sizes. Some devices have larger page sizes at different parts of memory. I can never remember without checking the manuals whether it's the SAM devices or STM32 that don't have the same page sizes all the way through memory.

If you need any functions for writing the actual code to flash from inside the bootloader I can send you that.

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

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


FreeRTOS and other embedded software careers at AWS.

Latest News

FreeRTOS kernel V10.0.1 is available for immediate download. Now MIT licensed.

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