cancel
Showing results for 
Search instead for 
Did you mean: 

FOTA using UART bluetooth

Svish.2
Associate II

I am using an STM32F302CB MCU, I intend to program my device remotely via a mobile app connected with the embedded system through a BT( UART connected).

What I understood:-

1.) The ST bootloader can be used to flash the MCU by sending some commands to UART.

2.) Use my own bootloader for the same.

Questions:-

1.) Can I use the internal bootloader to have multiple version of firmware i.e. the existing firmware does not gets overwritten? If yes, how?

2.) If I download the firmware update to a separate flash location using my existing application and then reset from software to start the bootloader, what is the procedure then to update the firmware so that the MCU starts from the new firmware update?

3.) What exactly does it mean to writing a bootloader that can do this task for me? Is it a normal program that goes along with my main application?

4.) In any case, do I need to make changes in my linker file and the vector table?

Thanks and Regards

5 REPLIES 5
TDK
Guru

> 1.) Can I use the internal bootloader to have multiple version of firmware i.e. the existing firmware does not gets overwritten? If yes, how?

Yes, the bootloader can store whatever you want on the chip. Programs should not share any flash pages. Bootloader details are in AN2606.

To store new firmware, you'll need to:

  • erase the pages of flash it's going to occupy
  • write the new firmware to those pages of flash.

> 2.) If I download the firmware update to a separate flash location using my existing application and then reset from software to start the bootloader, what is the procedure then to update the firmware so that the MCU starts from the new firmware update?

If you have your own custom bootloader, you'll have to put logic in there to decide which program to start. The program at 0x08000000 will start by default, so this is where you'll need to put your bootloader.

> 3.) What exactly does it mean to writing a bootloader that can do this task for me? Is it a normal program that goes along with my main application?

It's a normal program you create which is run when the chip boots up. So it needs to be at 0x08000000. Since it's your own program, you can put whatever logic in there you want to decide how to proceed and which program to run. It will be a separate program from your main application.

> 4.) In any case, do I need to make changes in my linker file and the vector table?

Yes. Your program won't be running from 0x08000000, so you'll need to update the linker appropriately. Change the flash origin to the new location.

If you feel a post has answered your question, please click "Accept as Solution".

Thanks @TDK​  for a quick response, so I will do the following, please correct me if I miss anything:-

1.) Once I get a notification for a firmware update on my main application(BT connected - UART), I will save the update to a separate flash location( preferably upper half of the usable memory).

2.) Once all check sum is verified and data has been saved, I will do a software reset, which will invoke my bootloader( 0x08000000), which will identify if there is a new update and run the new application.

(i) I will write the program start address( app A or app B) at a certain flash location( separate from all other pages), read it from my bootloader and proceed to run the application. Will this do the trick for me?

3.) This means that my bootloader (0x08000000) will just check the memory address stored in flash, and run the desired application. Now do I still need to change the linker files, and how will that action be done once the update has been received? Or should it be done beforehand?

Now if I use ST internal bootloader, will the procedure remain same?

PS:- My MCU has a total 128KB flash, each page 2KB - I plan to proceed this way >> 2KB - bootloader >> Next 64KB - main application(less than 32KB actual size) >> 2KB flash for EEPROM variables( some calib vars and memory location of current app to be used) >> Remaining for firmware update.

Many Thanks

TDK
Guru

Sounds like that'll work to me.

Yes, you need to update the linker to create a program that runs at something other than 0x08000000.

If you feel a post has answered your question, please click "Accept as Solution".

Thanks @TDK​ for your inputs, with your inputs and a bit help from the STM support, I was able to implement the FOTA for my STM32F302CB controller. The application is working really well. I have added the bootloader for application selection and included the firmware download facility in the applications itself.

Thanks

SMask.1
Associate II

Hello Svish,

Is this work the same Bootloader application for STM32 L0 series.

Thanks

Swapnil maskar.