esp32.diy

OTA Update STM32 Over-the-Air Using ESP32

Oct 13, 2026 · 5 min read

Intermediate 435 stars 87 forks Python MIT Updated 2026-07-21

STM32 Blue Pill with BOOT0 jumper set to position 1 for programming mode

TL;DR This project turns an ESP32 into a wireless flashing tool for STM32Fxx and STM32Gxx microcontrollers. Upload a .bin file through a browser, click flash, and your STM32 gets new firmware without a USB programmer in sight.
What you need
  • ESP32-DevKitC
  • ESP32-WROVER Kit
  • STM32F103C8T6 (Blue Pill)
  • STM32F072C8T6
  • NUCLEO-G431KB (STM32G431KB)
BoardESP32-DevKitC / ESP32-WROVER Kit
Target MCUSTM32Fxx / STM32Gxx series
FrameworkESP-IDF v4.0+
LanguagePython (reference scripts), C (ESP-IDF firmware)
LicenseMIT
DifficultyIntermediate

What You Will Build and Why It Is Useful

When you deploy an STM32 microcontroller inside a product or enclosure, re-flashing it usually means physically connecting a USB-to-serial adapter or ST-Link programmer. This project removes that constraint entirely.

By wiring an ESP32 to an STM32 over UART, you get a self-contained Wi-Fi programmer. The ESP32 hosts a small HTTP file server. You open a browser on any device that shares the same Wi-Fi network, upload a compiled .bin file, and click a flash link. The ESP32 drives the STM32 bootloader protocol (ST application note AN3105) over UART and writes the new firmware. No dedicated programmer hardware is needed after initial setup.

This is especially useful in prototyping rigs, remote sensor nodes, or any situation where physical access to the STM32 is inconvenient. The binary-transfer step is decoupled from the transport layer, so the same flashing code can be driven over MQTT, HTTP client, or WebSockets in production systems.

ESP-IDF menuconfig showing the Example Connection Configuration screen for entering Wi-Fi credentials\2
ESP-IDF menuconfig showing the Example Connection Configuration screen for entering Wi-Fi credentials
Browser-based file server interface showing uploaded .bin files with flash and delete links\2
Browser-based file server interface showing uploaded .bin files with flash and delete links

What You Need

Hardware

Software

Typical use cases

Wireless Firmware Updates

Push new STM32 firmware from a browser without touching a USB programmer or opening an enclosure.

Remote Sensor Node Updates

Update STM32-based sensor nodes deployed in hard-to-reach locations by sharing the same Wi-Fi network.

Prototyping Acceleration

Iterate quickly on STM32 code during development by cutting out the cable-connect, flash, unplug cycle.

Custom OTA Pipeline

Integrate the flashing utility into an MQTT or WebSocket pipeline to build a production-grade OTA system for mixed ESP32 and STM32 products.

How It Works

The ESP32 firmware has two layers:

  1. HTTP file server (/file_serving_stm) — serves a simple web page that lets you upload, list, delete, and flash .bin files stored in SPIFFS (the ESP32's on-chip file system).
  2. STM32 USART bootloader driver (/esp_stm_flash) — when you click the flash link, the ESP32 toggles the STM32 RESET pin (GPIO19) and communicates over UART using the protocol defined in ST application note AN3105. It sends the binary page by page to the STM32's built-in bootloader, which writes the data to flash memory.

The UART connections mirror the STM32 bootloader's default USART pins:

ESP32 GPIO STM32 Pin
GPIO4 (TX) PA10 (RX)
GPIO5 (RX) PA9 (TX)
GPIO19 RESET
GND GND

The STM32 must be placed in boot mode (BOOT0 jumper set to 1) before flashing. After flashing, you return BOOT0 to 0 and press RESET to run the new firmware.

Build and Flash Steps

Step 1 — Wire the boards

Connect the four wires as shown in the table above. Power the ESP32 and STM32 from separate supplies.

Step 2 — Set the STM32 to boot mode

On the Blue Pill, move the BOOT0 jumper to position 1. The exact procedure varies by MCU — consult ST application note AN2606 for your specific part.

Step 3 — Configure Wi-Fi credentials

Open the ESP-IDF project configuration menu and enter your network name and password:

idf.py menuconfig

Navigate to Example Connection Configuration and set:

Step 4 — Compile and flash the ESP32 firmware

From inside the /file_serving_stm directory:

idf.py -p PORT -b BAUD flash

Replace PORT with your serial port (e.g. /dev/ttyUSB0 or COM3) and BAUD with your preferred baud rate.

Step 5 — Find the ESP32 IP address

idf.py -p PORT monitor

Note the IP address printed in the log (for example, 192.168.43.82).

Step 6 — Upload and flash the STM32 binary

  1. Open http://<ESP32-IP>/ in a browser
  2. Use the upload form to send your STM32 .bin file to the server
  3. The uploaded file appears in the list — click its flash link
  4. The ESP32 drives the bootloader protocol; watch the monitor output for progress

Step 7 — Boot the STM32 into the new firmware

Return the BOOT0 jumper to position 0, then press the RESET button on the STM32. The new firmware starts running immediately.

Compatibility, Extensions and Limitations

Compatibility

Verified series: STM32F0, STM32F1, STM32G4, STM32L5. According to ST documentation, the bootloader protocol is also used by STM32F2, F3, F4, F7, G0, H7, L0, L1, L4, U5, WB, and WL — these may work with some customization.

Ideas to extend it

Limitations

Verdict

OTA_update_STM32_using_ESP32 is a practical, well-tested solution for anyone who needs to update STM32 firmware without a dedicated programmer. The wiring is minimal, the web interface is straightforward, and the protocol is grounded in official ST application notes, making it reliable across a broad range of STM32 series. The main friction point is the manual BOOT0 jumper step, but the project itself points you toward automating that with a MOSFET — a worthwhile addition before deploying to production.

Sources

github.comESP32-Musings/OTA_update_STM32_using_ESP32 — repository & README

Facts in this article come from the project's public README and GitHub metadata at the time of writing. Images belong to their respective owners and link back to the original source.