Intimating new firmware start address to bootloader

Considering a microcontroller(in my case STM32L4 series) once the new firmware image is written into the flash, how the new start address of the application can be intimated to the bootloader?

-------------Problems Reply------------

Normally the bootloader should know the sector where the application has been written. If this is not case then there are two options:
1. When you write the firmware image to a particular sector - record in flash in a known sector the firmware sector i.e in a known sector write a struct bootloaderInfo that records the sector address of the firmware and any other info that is useful for the bootloader e.g a CRC for the firmware image, a firmware version etc. The bootloader can read this struct (its always in a known sector) and from that know where the sector where the firmware is to run.
2. The bootloader could scan flash sectors looking for the firmware image. This is not really recommended but would work. A sector with a valid firmware image will have a. a valid stack pointer and b. a valid reset vector. They could be tested with the following macros:

#define IS_VALID_STACK_POINTER(address) (((*(volatile uint32_t*)address) & STACK_POINTER_RANGE) == SRAM_BASE)

#define IS_VALID_RESET_VECTOR(sectorAddress) \
(((*(uint32_t*)(sectorAddress+4)) & 0x8FF0000 ) == sectorAddress)

Once the application address in known the bootloader can jump to it in the normal way:

uint32_t JumpAddress = *(__IO uint32_t*)(sector + 4);
pFunction JumpToApplication = (pFunction)JumpAddress;
// Initialize user application's Stack Pointer:
__set_MSP(*(__IO uint32_t*)sector);

Category:boot Views:1 Time:2018-08-08

Related post

Copyright (C), All Rights Reserved.

processed in 0.253 (s). 11 q(s)