Skip to main content
Christoph Eschenbach
Associate III
Jun 5, 2018 11:05 AM UTC
Question

Try for fast jumping between bootload and application

Posted on June 05, 2018 at 13:05

Hello there,

i am working with STM32429VI.

For my device i try to implement a simple bootloader which gives me the possibilty for DFU.

DFU works fine and everthing else too.

But I need some feedback if this is a attempt which ain�t gives me problems in the future.

My bootloader:     0x0800 0000 - 0x080 7FFF

Application:          0x800 8000 ...

Since i will have no reset button on my later hardware i want somehow jump back to the bootloader from my application and hold it in the bootloader until i upgraded the application.

For this i reserved a small part from the RAM: 0x2000 0000 - 0x2000 001F

For both the bootloader and the application i set the ram in the linker file to begin at 0x2000 0020.

Inside the small part of the RAM i write a specific value, if the application executes a specific function.(Basically i can send a request from outside to the mcu and it will execute the write function and do a reset).

By this the bootloader starts and reads out the specific value and holds the bootloader mode until the new firmware has been downloaded the value gets reset to default and a system reset is executed. So the bootloader starts again but jumps then to application.

This way I can avoid that the usb is configured all the time as DFU and I have a clean start for the bootloader and the application.

This works fine for now.

My Application is working with freertos and i think that the rtos could mybe access this part of the RAM somehow, but i am not sure. I hope excluding this part of the RAM in the Linker-Files will terminate any excess from the RTOS.

I am not that experienced in writing a bootloader and hope someone can give me a feedback if this is done well or if this can lead to a bunch of problems.

Thank you in advance

Christoph

#dfu #stm32f4 #linker #ram #freertos #stm32f429 #bootloader
This topic has been closed for replies.

9 replies

AvaTar
Senior III
Jun 5, 2018 11:48 AM UTC
Posted on June 05, 2018 at 13:48

By this the bootloader starts and reads out the specific value and holds the bootloader mode until the new firmware has been downloaded the value gets reset to default and a system reset is executed. So the bootloader starts again but jumps then to application.

I'm using a similar method on another Cortex M based device (not ST, sorry ...).

But it seems you didn't consider the 'rainy day' scenario - the firmware update fails consistently, or is corrupted.

Our application has a customer-specific header including a checksum, and the bootloader calculates the checksum over the application each time, and remains in the BL if both values don't match.

You might consider a fall-back variant, which doesn't make things really easier.

My Application is working with freertos and i think that the rtos could mybe access this part of the RAM somehow, but i am not sure. I hope excluding this part of the RAM in the Linker-Files will terminate any excess from the RTOS.

My device uses a more expensive external MRAM, but some thousands of other paramters need to go there as well.

Christoph Eschenbach
Associate III
Jun 5, 2018 5:24 PM UTC
Posted on June 05, 2018 at 17:24

Hello AvaTar,

Our application has a customer-specific header including a checksum, and the bootloader calculates the checksum over the application each time, and remains in the BL if both values don't match.

This is a method i really should consider too. Thanks for the advice.

You might consider a fall-back variant, which doesn't make things really easier.

I have a second flash bank left empty for now where i could store the parent application before upgrading.

Well nothing what we do is really easy and the affort is our experience, which will make thinks easier later.

I really appreciate your information.

Thank you very much for your fast response.

AvaTar
Senior III
Jun 6, 2018 7:33 AM UTC
Posted on June 06, 2018 at 07:33

I have a second flash bank left empty for now where i could store the parent application before upgrading.

Well nothing what we do is really easy and the affort is our experience, which will make thinks easier later.

The only problem - both Flash banks have different addresses, and thus need the application built explicitly for it.

And, as adib said:

I think you also ancounter the problem that getting the new firmware requires to erase the old first.

Because the flashsize exceeds the RAM Size.

You will most likely encounter this problem with every MCU. The new firmware needs to be downloaded and flashed in segments, while the old is erased at once.

taraben
Associate III
Jun 5, 2018 9:40 PM UTC
Posted on June 05, 2018 at 23:40

Hi Christoph,

check this out: MCUBoot

https://www.zephyrproject.org/presentations/zephyr-and-mcuboot-as-foundations-for-secure-iot-products/

 

I think you also ancounter the problem that getting the new firmware requires to erase the old first.

Because the flashsize exceeds the RAM Size.

Think about having an alternative intermediate memory for the application. i.e external SPI flash.

I loaded completely then swap applications.

Some bootloader work with two applications in FLASH but then the application need to become address independent.

my 2ct.

Adib.

--