I have an ESP8266 WiFi module, flashed with esp-link firmware (which makes ESP8266 act as a transparent wifi-to-usart bridge).
I would like to be able to flash firmware wirelessly using this module into STM32F4. Specifically, I would like to send a command via USART "Let's Start the flashing process" in the middle of the execution of the stm32 program.
I am completely new to the topic, so I have searched on the internet how flashing is usually done.
ST recommends to write my own boot loader program, which will be installed at 0x8000000, move the original application program (and its interrupt vector table) to, for example, 0x8001000, and in the boot loader wait for some event, like a pressed button, to trigger the firmware flashing process.
This is not what I need: I would like to start flashing right after a special "trigger" command has been received over usart.
The idea that I have is, upon receiving such command, move the firmware flashing code into SRAM, jump to this code, completely erase the STM32 flash, then send a command via USART that we are ready to flash the new firmware, the PC will respond with the firmware size, and now the STM32 will synchronously wait for the firmware data on the USART, writing it into the flash memory as we receive new pages over the USART connection. Interrupts/DMA will not be used, as the code in SRAM must be as simple as possible. Then, after the last piece of the firmware has been written to flash, call NVIC_SystemReset(), the application should start normally.
Do you think this would be the optimal way to perform the task? Are there any pitfalls in this implementation I should be aware of, or is there a better/easier approach?
Thanks for any help!