Electronic – OTA Programming of STM32

bluetooth low energyfirmwareflash-memoriesstm32

I am currently using ST32L152RE controller interfaced with BLE CC2640R2F module and 4 MB external flash memory interfaced through spi. I was trying to upgrade the firmware of my st controller using BLE. My approach is to receive firmware using BLE and store it in flash memory, then ask controller to restart and execute the code written in flash memory.

As far as I think there are two possible ways.

  1. I need to copy that code file (binary data) from external flash memory to controller flash memory then reset the controller so that it execute the code written in internal flash.
  2. I will ask the controller to directly execute the binary file or code file from external flash memory. (I have no idea if this will work or not)

I am taking an assumption of possible ways to get the results. Very confused if any of this approach works or not.

Best Answer

If you are using less than 50% of your internal flash (and the new SW is also < 50%) then you could load the new software into the upper part of that memory, test it runs and then copy into the lower half once you're happy.

You would need some sort of bootloader to do this however, I'm sure there are plenty of STM32 guides on how to do this. Your approach of using the external flash memory is fine too, and would allow you to perform a CRC on the new SW image data once it has been transferred over before copying it into your internal flash. I'm not sure if the STM32 will allow you to execute code from the external flash though.

A bootloader is usually a small section of the internal flash which is written to handle all this, but this code needs to be well tested as you can usually only update it back at base (physical connection to a programmer) and not usually OTA.

Guide here

STM guide: STM