cancel
Showing results for 
Search instead for 
Did you mean: 

Update/re-program STM32F722 Firmware via UART

Juanjo97
Associate II

Hello everyone,

I have a project where I use a main baseboard that connects to an STM32F722 microcontroller via a UART interface. My goal is to achieve updating the program running on the STM32F722 without requiring any user intervention. In other words, I want to perform firmware updates remotely and automatically from the main baseboard, without the need to toggle switches or change jumpers.

I have come across information about In-Application Programming (IAP), but most methods I've found require the user to change a jumper or a switch to put the microcontroller into boot mode. I am looking for a solution that doesn't involve any manual intervention.

I am seeking guidance on how to tackle this challenge. Is there a way to achieve this remote and automatic update via UART without requiring the user to make hardware changes? What steps or tools are required to carry out this process safely and efficiently?

Any advice, previous experiences, or direction you can provide would be greatly appreciated, as I am a bit lost on this topic and am accustomed to working with development boards where updating is more straightforward.

Thank you in advance for your assistance!

7 REPLIES 7
TDK
Guru

Connect the UART to a system bootloader-supported interface and jump to the bootloader when you want to program the device. See AN2606 for supported interfaces and AN3155 for UART bootloader commands.

https://www.st.com/resource/en/application_note/an2606-stm32-microcontroller-system-memory-boot-mode-stmicroelectronics.pdf

https://www.st.com/resource/en/application_note/an3155-usart-protocol-used-in-the-stm32-bootloader-stmicroelectronics.pdf

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

> I am looking for a solution that doesn't involve any manual intervention.

With a custom update solution in your firmware, you can switch to the update mode from your application anytime. (yes, using the IAP stuff).  Consider that newly updated firmware can fail or hang. Think about recovery scenarios (revert to previous firmware or download another version).  Consider what if the whole user firmware becomes corrupt or erased (*), provide the "worst case" recovery path.

 

The only idea I've come up with is to partition the Flash into two sections, one for storing the normal program and another for holding the update mode at a different memory address. I'll enter this update mode when I receive specific data through UART. Once there, I will overwrite the Flash memory containing the normal program with the received information. However, I believe what I'm trying to do is quite common, and I have a feeling that I might be reinventing the wheel.

Most of us have done it for these and other processors. The use of Loaders presumably part of Embedded Engineering courses at this point.

So how do you propose to initiate this process? Do you have some network connectivity where you can periodically query a server, say HTTP, to determine if there is new firmware, and provide it. Or a cellular connection where you can initiate an update process via an SMS

Other than this you need to facilitate the update in your current user-interface or connection tools on your Host Platform.

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

Yes, it's certainly done many times before. You can look at OpenBL and the X-CUBE-IAP-USART package for example.

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

 

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

It's much simpler than that. The initial PC board sends a message to the STM32 board (via UART or USB, still to be determined) to enter update mode, and then the initial board sends the new firmware for it to update. That's my idea. Is this possible?

But this entire process has to be invisible to the user. In the end, there are two different pieces of code: one on the PC that acts as the master and sends a message to the STM32F722 (via UART or USB) when it needs to enter update mode. The STM32F722 enters update mode, and the PC sends it the new program for updating. I'm looking for the simplest way to achieve this.

A lot of things are possible, ST's IAP examples tend to be the most common, a loader and an app, the loader always boots, and then hand control to the app if it is intact and valid, otherwise provide for means of recover / update

Using the ISP methods, ie ROM System Loader, via BOOT0 / RESET pins, and a UART, and implementing the protocol described in AN3155 the Arduino MKR WAN1300 can push updates to an STM32L072CZ residing in a Murata LoRa module, from an ATMEL SAMD. See   https://github.com/arduino-libraries/MKRWAN/tree/master/examples/MKRWANFWUpdate_standalone

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