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




Loading

STM32F4 bootloader with freeRTOS+TCP

Posted by unknown49 on December 14, 2016

Hi,

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;

define APPLICATIONSTARTADDRESS 0x8008000

void JumpToNormalApplication(void) {

    volatile uint32_t JumpAddress;
    uint32_t temp;

   // Disable all interrupts
    NVIC->ICER[0] = 0xFFFFFFFF;
    NVIC->ICER[1] = 0xFFFFFFFF;
    NVIC->ICER[2] = 0xFFFFFFFF;

// 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;

    SCB->VTOR = (unsigned long)APPLICATION_START_ADDRESS;

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

} ~~~

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:

#define APPLICATION_START_ADDRESS 0x8008000

to

#define APPLICATION_START_ADDRESS 0x8000000

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