cancel
Showing results for 
Search instead for 
Did you mean: 

How to Remotely Update Code on STM32 Microcontroller?

dplogiic
Associate II

Hello team,

I am working on a project involving an STM32 microcontroller, and I am looking for guidance on how to implement remote firmware updates. Specifically, I want to be able to update the code on the microcontroller over the air (OTA) without needing physical access to the device.

Could anyone provide a detailed explanation or point me towards relevant resources, documentation, or examples for achieving this? Any tips on best practices for ensuring the update process is secure and reliable would also be greatly appreciated.

 

5 REPLIES 5

What's the "Air" in your system?

Have memory that you can stage/store the firmware update, checking that it is complete and valid before attempting to replace the existing code. Use normal Erase and Write methods. Should be examples in CubeH7.

If using a network, perhaps use HTTP requests to determine if you have current firmware or which to move to next. Use HTTP to fetch .BIN or .HEX, or packaged firmware.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Thank you for the detailed response!

To clarify, I am planning to use "Air" in system (e.g, Wi-Fi, Ethernet, Bluetooth) for the remote firmware update process. 

Could you suggest best practices for efficiently managing the memory used to stage/store the firmware update? I plan to implement checksum verification. Are there any recommended methods or examples for verifying the integrity of the downloaded firmware?

You mentioned using standard erase and write methods and looking at examples in CubeH7. Could you point me to specific examples or documentation within CubeH7 that cover these methods?

I will use HTTP requests to check for and download firmware updates. Any advice on how to structure these requests or handle the download process efficiently would be greatly appreciated.

Simplest way is to store the update on an SD-card and then jump to a bootloader and the bootloader will load the file from the SD-card into flash and then will start the application if it is fully loaded and has a valid CRC. There are many application notes on bootloaders. Perhaps even one that does exactly what you want.

You will need a way for the application to signal to the bootloader to load a file. I like to use the backup memory for that. Also add many checks so that if the loaded program doesn't have a valid CRC the bootloader will not run the program but attempt to load it again. In that case a power cycle during an update won't brick the device.

 

Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.
Not sure what parts you're using
The Reference Manuals go into the details of the FLASH array and programming methods. The source code provides usage examples for the library function. Function source has additional details/comments.
I'd use CRC over "checksums", for security perhaps SHA-256 + ECSDA, depends on how sophisticated you plan on being. Compression and Encryption can also reduce paths to exploitation and abuse.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Andrew Neil
Evangelist III