Skip to main content
Associate II
October 9, 2024
Question

Update from application

  • October 9, 2024
  • 9 replies
  • 2189 views

Hey,

Is it possible to create a seperate space on every microcontroller for a second bootloader and firmware location? To update the firmware live? Or is this only possible on specific series? 

A second firmware location to place the new firmware and to verify the firmware is compleet. The second bootloader should start the new firmware and even copy this to the current firmware. 

Is there an application note or guide for this?

Kind regards,

This topic has been closed for replies.

9 replies

Tesla DeLorean
Guru
October 9, 2024

Yes, but need to keep it small to fit in one or two FLASH pages

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
T.DieAuthor
Associate II
October 9, 2024

Hi Tesla DeLorean,

Why one or two flash pages? Or is this just to make sure there's still flash memory left? 

Kind regards

MM..1
Super User
October 10, 2024

Your question isnt clean info, then reply is simple example. Here is one example of unnamed mcu flash sectors

MM1_0-1728547621669.png

as you can see have 5 area for erase sectors, then this is all limits for your loaders. Too i dont understand why you named secondary . How is primary bootloader function ? 

Andrew Neil
Super User
October 9, 2024

@T.Die wrote:

Is there an application note or guide for this?


Yes!

Application Note AN4657, STM32 in-application programming (IAP) using the USART:

https://www.st.com/resource/en/application_note/an4657-stm32-inapplication-programming-iap-using-the-usart-stmicroelectronics.pdf

https://www.st.com/en/embedded-software/x-cube-iap-usart.html

 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Simon.T
ST Employee
October 10, 2024

Hello @T.Die ,

 

You can have a look on the ST Open bootloader. For STM32C0, a code example is available on the STM32Cube C0 FW, following this GitHub link:  https://github.com/STMicroelectronics/STM32CubeC0/tree/main/Projects/NUCLEO-C031C6/Applications/OpenBootloader

 

If you want to have more detail, there is this knowledge article available here : https://community.st.com/t5/stm32-mcus/how-to-use-the-st-open-bootloader-for-stm32-microcontrollers/ta-p/49896

 

Best regards,

 

Simon

 

 

T.DieAuthor
Associate II
October 13, 2024

Hi all,

Somebody advised me to look at the following project:

https://github.com/jonahswain/stm32g0-bootloader

From what I understand this example creates places for 2 applications and a costum bootloader. 

In the make file I see that there are 3 elf files being created. And if I am correct also 3 files will be uploaded to the microcontroller. This depending on 3 linker scripts. Can this be done in STM32CubeIDE?

Or do I need to adjust the linkerfiles so that there's just one linker file? If so how do I setup the program so that the compiler knows that I want the bootloader on the bootloader linker script place and that the application1 needs to be on the linker script of application1? 

Kind regards

Tesla DeLorean
Guru
October 13, 2024

Typically you'd need a specific linker script for each section of memory the different images are placed.

The MCU is always booting from 0x08000000 for FLASH, the CM0+ parts have SCB->VTOR to relocate the vector table via SystemInit() whereas the CM0 part does not, and there you need to copy the alternate vector table(s) into RAM at 0x20000000 and remap the RAM at ZERO (via SYSCFG ?, or mapping register)

Now all the CM0(+) parts are relatively small, if you start pulling in HAL and math libraries things can disappear very quickly. I don't find 16KB (L011) parts to be adequate, currently using a 32KB (G031) that I can at least fit a 2 or 4KB loader, and ability to stage/recover so as not to brick the device.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
T.DieAuthor
Associate II
October 14, 2024

Hi @Tesla DeLorean ,

Thank you for your feedback. 

Ok, so I need different images with each there own linker script. Is this possible to setup in STM32CubeIDE? Or do you need change the linker script and main file for each build? 

Or would you advise to not do this in STM32CubeIde and run this on a self written make file? 

Kind regards