cancel
Showing results for 
Search instead for 
Did you mean: 

How can I use an ESP32 to update the firmware of an STM32 from any family

WPazH
Associate II

Hello, I am designing a device that will have an STM32L4 or maybe an STM32U and will communicate with an ESP32 for internet connectivity. However, at some point, I would like to update the firmware remotely, and have the ESP32 stop executing its conventional software and act as a programmer for the STM32. Is this possible? And if so, where can I find detailed information on how to do it? I hope you can help me, thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
Andrew Neil
Evangelist III

@WPazH wrote:

 Is this possible? 


Yes.

You have 2 choices:

  1. Use the STM32's System bootloader.
    This requires control of the STM32's Reset & BOOT pins.
    There are Application Notes describing the Bootloader protocol and supported interfaces.
  2. Use a custom bootloader.
    As it's custom, you can do it without needing to use the STM32's Reset & BOOT pins, and can use any interface & protocol you like.
    See the In-Application Programming Application Notes for examples.
    3rd-party bootloaders  are available.

 

With an ESP32, you could either have the ESP "push" the update to the STM, or have the STM "pull" the update from the ESP, or the ESP could be purely passive and transparent ...

 

Similar question yesterday:

https://community.st.com/t5/stm32-mcus-boards-and-hardware/how-to-remotely-update-code-on-stm32-microcontroller/m-p/695840

 

#Bootloader #FirmwareUpdate #InApplicationProgramming  #OTA  #IAP

View solution in original post

4 REPLIES 4
PGump.1
Senior

Perhaps another solution could be - using the STM32L4 to download the new firmware into an external EEPROM compatible with AN2606, then cause the SMT32L4 to Reset with the appropriate Boot mode...

Kind regards
Pedro

AI = Artificial Intelligence, NI = No Intelligence, RI = Real Intelligence.
Andrew Neil
Evangelist III

@WPazH wrote:

 Is this possible? 


Yes.

You have 2 choices:

  1. Use the STM32's System bootloader.
    This requires control of the STM32's Reset & BOOT pins.
    There are Application Notes describing the Bootloader protocol and supported interfaces.
  2. Use a custom bootloader.
    As it's custom, you can do it without needing to use the STM32's Reset & BOOT pins, and can use any interface & protocol you like.
    See the In-Application Programming Application Notes for examples.
    3rd-party bootloaders  are available.

 

With an ESP32, you could either have the ESP "push" the update to the STM, or have the STM "pull" the update from the ESP, or the ESP could be purely passive and transparent ...

 

Similar question yesterday:

https://community.st.com/t5/stm32-mcus-boards-and-hardware/how-to-remotely-update-code-on-stm32-microcontroller/m-p/695840

 

#Bootloader #FirmwareUpdate #InApplicationProgramming  #OTA  #IAP

System Bootloader:

Picking an L4 Product Page at random, and going to the 'Documentation' Tab:

https://www.st.com/en/microcontrollers-microprocessors/stm32l412c8.html#documentation

AN2606 STM32 microcontroller system memory boot mode

AN3154 CAN protocol used in the STM32 bootloader

AN4221 I2C protocol used in the STM32 bootloader

AN4286 SPI protocol used in the STM32 bootloader

AN3155 USART protocol used in the STM32 bootloader
AN3156 USB DFU protocol used in the STM32 bootloader

 

In Application Programming:

AN4657 STM32 in-application programming (IAP) using the USART

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

https://github.com/STMicroelectronics/STM32CubeL4/tree/master/Projects/STM32L476G-EVAL/Applications/IAP/IAP_Main

 

Also have a browse through the Knowledgebase - several articles there on bootloaders:

https://community.st.com/t5/stm32-mcus/tkb-p/stm32-mcus-knowledge-base

just one example:

https://community.st.com/t5/stm32-mcus/how-to-program-a-stm32-with-another-stm32-using-embedded/ta-p/612362

 

WPazH
Associate II

Hi @PGump.1  and @Andrew Neil  , your answers were very helpful. I will try to implement the two methods you mentioned, as the ESP32 needs to send the update to two STM32s, and I'm not very sure which method would be more effective. Thank you for the help.