This project implements a Firmware Over-The-Air (FOTA) update mechanism for STM32 microcontrollers using a custom bootloader. The STM32 communicates with a host (Node-RED) via ESP32 to receive commands from a Node-RED Dashboard. The firmware update file is stored in Firebase and delivered to the STM32 for seamless updates.
Video link: https://youtu.be/6jXGq0C-o00
- User selects a command from the Node-RED Dashboard.
- The ESP receives the command from Node-RED.
- The ESP appends other details to the command, calculates the CRC of the packet, and then sends it to the STM32 bootloader.
- The bootloader receives the packet, calculates its CRC to verify that the packet was received successfully.
- Bootloader performs the operations needed by the command (return data/status to the ESP to be shown in Node-RED)
Firebase [Update File]
|
v
[Node-RED Dashboard] <---> [ESP32] <---> [STM32 Custom Bootloader]
- Firebase hosts the latest firmware update files.
- Node-RED Dashboard provides a user interface to send commands.
- ESP32 acts as a communication bridge between Node-RED and the STM32, and responsible for downloading the update file from firebase storage and transfer it to the STM.
- STM32 runs a custom bootloader to manage FOTA updates and execute commands.
- Upload Application: Upload new firmware from Firebase to the STM32.
- Erase Flash: Erase the STM32 flash memory.
- Jump to Application: Jump from the current application to the newer application.
- Get Chip ID: Retrieve the STM32's chip ID.
- Read Protection Level: Check the current read protection level.
- STM32F4 Microcontroller (e.g., STM32F401)
- ESP32 Module
- Node-RED
- Firebase
For communication between the STM32F4 and ESP32, use the following connections:
STM32F4 | ESP32 |
---|---|
Tx1 (A9) | Rx2 |
Rx1 (A10) | Tx2 |
GND | GND |
Ensure all devices share a common ground to avoid communication issues.
-
Clone the Repository:
git clone https://github.com/yourusername/stm32-fota-esp32
-
Setup Node-RED:
- Install Node-RED: Node-RED Installation Guide
- Import the
Node-RED
flow provided innode-red/flow.json
. - how to use Node-RED with ESP32: https://youtu.be/N4uf23x4vmM?si=OWFQuKNQUvaNG4Lu
-
Flash ESP32:
- Flash the
esp32-fota
firmware using PlatformIO or Arduino IDE.
- Flash the
-
STM32 Bootloader:
- Flash the custom bootloader to the STM32 using STM32CubeProgrammer.
-
STM32 Update file:
- Create update file of stm32 using keil IDE.
- See this video: https://youtu.be/0ZRID81G6LU?si=seCyNwVOUL9CGWVb
-
Firebase Setup:
- Host the firmware update files in Firebase.
- See this video: https://youtu.be/MsZfV0x_G8k?si=pQoq8CVdHGI1mdZX
The following commands can be sent from the Node-RED Dashboard to the STM32 via ESP32:
- Upload Application
- Erase Flash
- Jump to Application
- Get Chip ID
- Read Protection Level
- Text Field to shown the received data/status from STM32.