Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FlashWave STM32 — Web-Based Firmware Updater via ESP32

Crafted with ❤️ by Diwakar


Overview

FlashWave STM32 is a web-based utility that allows you to update the firmware of an STM32 microcontroller over Wi-Fi using an ESP32 as the host. The ESP32 serves a lightweight webpage (accessible from any browser on the same network) where you can upload a .bin firmware file, which is then flashed to the STM32 over UART using the STM32 bootloader protocol.

No USB cable to the STM32 is required — just Wi-Fi.


Web Interface

Once the ESP32 is connected to Wi-Fi and you open the IP address in your browser, the following interface is displayed:

webpage_screenshot

The dashboard shows:

  • Device online status indicator
  • Total size of stored files
  • Max file size limit (200 KB)
  • Files stored count
  • A drag & drop upload area for .bin files
  • A Server path input field with an Upload button
  • A Stored Files section listing previously uploaded files

Serial Log (Wi-Fi Connection)

After flashing the ESP32 and powering it on, the serial monitor confirms Wi-Fi connection and displays the assigned IP address:

serial_log
I (6060) wifi:connected with Iron_man, aid = 1, channel 12, BW20
I (6060) wifi:security: WPA2-PSK
I (7070) WIFI: GOT IP
I (7070) esp_netif_handlers: sta ip: 10.190.220.209, mask: 255.255.255.0, gw: 10.190.220.218
xx -- Initializing SPIFFS -- xx

Copy the IP (e.g., 10.190.220.209) and open it in your browser.


Features

  • 📡 Hosted entirely on the ESP32 (no external server needed)
  • 🌐 Browser-accessible UI with drag & drop file upload
  • 📦 Supports binary firmware files up to 200 KB
  • 🔄 Automatic STM32 reset and boot mode control via GPIO
  • 💾 SPIFFS-based file storage on ESP32
  • 🔒 WPA2-PSK Wi-Fi connection (Station mode)

Hardware Requirements

Component Details
ESP32 Any standard ESP32 dev board
STM32 Any STM32 with UART bootloader support
Connection UART (TX/RX) + RESET + BOOT0 GPIO lines

Pin Configuration

The following GPIO pins on the ESP32 are used to interface with the STM32:

#define TXD_PIN   (GPIO_NUM_17)   // ESP32 TX  → STM32 RX
#define RXD_PIN   (GPIO_NUM_16)   // ESP32 RX  ← STM32 TX
#define RESET_PIN (GPIO_NUM_19)   // ESP32 → STM32 NRST
#define BOOT0_PIN (GPIO_NUM_21)   // ESP32 → STM32 BOOT0

Note: Alternate pin assignments are shown in comments within the source (e.g., GPIO_NUM_1, GPIO_NUM_3, GPIO_NUM_12, GPIO_NUM_2) — update #define values as needed for your board layout.


Project Structure

STM32_FIRMWARE_UPDATE(WEBPAGE)/
├── .devcontainer/
├── .vscode/
├── build/
├── components/
│   ├── stm_flash/
│   │   ├── include/
│   │   │   └── stm_flash.h       # STM32 flasher header
│   │   ├── CMakeLists.txt
│   │   ├── component.mk
│   │   └── stm_flash.c           # STM32 UART bootloader logic
│   └── wifi/
│       ├── CMakeLists.txt
│       ├── connect.c             # Wi-Fi STA connection implementation
│       └── connect.h             # Wi-Fi connection header
├── main/
│   ├── webpage/                  # Static web assets (HTML/CSS/JS)
│   ├── CMakeLists.txt
│   ├── component.mk
│   ├── file_server.c             # HTTP server & file upload handler
│   └── main.c                    # Entry point, Wi-Fi init, server start
├── .gitignore
├── CMakeLists.txt
├── Makefile
├── partitions_example.csv        # Custom flash partition table
├── README.md
├── sdkconfig
└── sdkconfig.old

Getting Started

Step 1 — Configure Wi-Fi Credentials

In main/main.c, set your Wi-Fi SSID and password:

ESP_ERROR_CHECK(wifi_connect_sta("Iron_man", "Hewlett@123", 10000));

Replace "Iron_man" and "Hewlett@123" with your own network credentials.

⚠️ Your laptop/PC and the ESP32 must be connected to the same Wi-Fi network.


Step 2 — Build & Flash the ESP32

idf.py build flash monitor

Step 3 — Get the IP Address

Watch the serial monitor for the assigned IP:

I (7070) esp_netif_handlers: sta ip: 10.190.220.209, mask: 255.255.255.0, gw: 10.190.220.218

Step 4 — Open the Web Interface

Paste the IP into your browser:

http://10.190.220.209

Step 5 — Upload Firmware

  1. Click "Choose a file" or drag & drop your .bin file.
  2. Enter the filename in the Server path field.
  3. Click Upload.
  4. The ESP32 stores the file in SPIFFS, then flashes it to the STM32 via the UART bootloader.

How It Works

[ Browser ] --HTTP--> [ ESP32: file_server.c ]
                             |
                        SPIFFS storage
                             |
                  UART Bootloader Protocol
                  (stm_flash.c)
                             |
                        [ STM32 ]
  1. The ESP32 runs a lightweight HTTP server (file_server.c).
  2. Uploaded .bin files are stored in SPIFFS.
  3. stm_flash.c controls BOOT0 and RESET pins to enter bootloader mode.
  4. Firmware is transferred via UART using the STM32 system bootloader protocol.
  5. STM32 is reset to boot from the new firmware.

Dependencies

  • SPIFFS component (built-in)
  • ESP HTTP Server component (built-in)

License

MIT License — feel free to use, modify, and distribute.


Crafted with ❤️ by Diwakar

About

Web-based STM32 firmware updater hosted on ESP32 over Wi-Fi

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages