Skip to the content
2 layers177.5 × 87.5 mmOTA PCB, the printed circuit board in 3D

Reliable A/B firmware update foundation for STM32 with an ESP32 transport bridge. Here is the final presentation video showing a demo and explanation of everything in this readme:

Size
177.5 × 87.5 mm
Copper layers
2
Thickness
1.6 mm
Parts
10
Nets
90
Pads
222
Tracks, vias
256, 0
Pours
1
Routed
Yes
KiCad
KiCad 9.0 (file 20241229)
Created
13 May 2026
Updated
6 May 2026

Overview

OTA PCB is an open-source printed circuit board by sameeran-c, from the sameeran-c/STM32_OTA_ABswap repository on GitHub. It is a 2-layer board of 177.5 × 87.5 mm with 10 parts on 90 nets, routed with 256 tracks and 0 vias.

README

README.md

OTA Firmware Update Project

Reliable A/B firmware update foundation for STM32 with an ESP32 transport bridge.
Here is the final presentation video showing a demo and explanation of everything in this readme:

Demo Videos

https://youtu.be/UHACsZe9ke4
https://youtube.com/shorts/yXXsLTlftgA?feature=share

Table of Contents

Project Overview

Purpose

Many embedded products are deployed in places where physical reflashing is slow, costly, or impossible. A failed firmware update can also brick a device if there is no recovery path. This project builds a robust over-the-air (OTA) update pipeline for an STM32 platform to solve this problem.

Functionality

The system utilizes an A/B swap firmware update layout. The design keeps one known-good binary active while writing a new downloaded binary to an inactive slot. This allows updates to be validated before they become permanent. The update download process is concurrent. Main application tasks are not halted while the new binary is fetched.

Key components:

  • A custom STM32 bootloader validates candidate app binaries at boot.
  • The same application is built twice into Slot A and Slot B with specific binary information.
  • OTA update workflow metadata is stored in flash with power-fail-safe writes.
  • An ESP32 transport companion delivers update payloads to the STM32 application over UART.

System Architecture

End-to-end update path:

  1. A new firmware binary file is delivered over the network to the ESP32 bridge (stored at https://github.com/anton2uha/OTAfiles).
  2. HiveMQ sends a fetch request to the ESP32. The ESP32 downloads the binaries to its local flash.
  3. The running STM32 application receives the payload from the ESP32 via UART and writes it to the dormant flash bank.
  4. The application marks the dormant slot as pending and reboots.
  5. The bootloader validates available slots (integrity, CRC) and selects the boot target with the highest version.
  6. The new app image confirms itself after health checks.

Architecture Diagrams

BlockDiagram-System Architecture

BlockDiagram-Process

Hardware Interfaces & Wiring

Gerber files and kicad_pcb files can be found in the /hardware_design_resources dir, for those interested in ordering the hardware to run the OTA.

wiringdiagram.png

ESP32 to STM32 UART Pinout

ESP32STM32
GPIO17 (TX)RX pin (PC5)
GPIO16 (RX)TX pin (PC4)
GNDGND

STM32 Interfaces

  • UART3: OTA data path from ESP32 to STM32 (Pins PC4, PC5).
  • UART4: Debug output path.

ESP32 Interfaces

  • UART0: USB serial to receive new programs via PlatformIO.
  • UART2: Binary transfer path toward STM32 OTA updater.

Basic Setup Instructions

1. ESP32 Bridge Setup

Requirements: VS Code with PlatformIO extension, HiveMQ Cloud account (free tier), and a 2.4GHz WiFi network.

  1. Configure WiFi credentials in ota_esp32/src/main.cpp:
    cpp
    const char* ssid = "your_network";
    const char* password = "your_password";
  2. Configure the server URL and MQTT credentials in ota_esp32/src/main.cpp:
    cpp
    #define MQTT_BROKER "your-cluster.hivemq.cloud"
    #define MQTT_USER   "your_username"
    #define MQTT_PASS   "your_password"
    Update the IP in fetchBinary() and checkForUpdate() to point to your hosted binaries.
  3. Build and upload using PlatformIO. Ensure the ESP32 device is connected via USB. Note: If using WSL, ensure your user is in the dialout group to access /dev/ttyUSB0.

2. STM32 Firmware Setup

Requirements: CMake and ARM GCC toolchain.

  1. Navigate to the OTA directory.
  2. Run the following CMake commands to build the bootloader and the two application slots:
    bash
    cmake --preset Debug -B build/Debug
    cmake --build build/Debug --target OTA_bootloader
    cmake --build build/Debug --target OTA_app_a
    cmake --build build/Debug --target OTA_app_b
  3. Flash the generated .elf or .hex files to the STM32 starting at address 0x08000000 for the bootloader.

Flowcharts

Bootloader FSM

Bootloader Flowchart

UART ESP32 to STM32 Protocol FSM

Arduino State Machine

Current Implementation Status

  • Implemented A/B flash partitioning and custom bootloader runtime.
  • Runtime slot probing with vector checks, manifest checks, CRC checks, and version comparison.
  • Shared app source built into two linked images (Slot A and Slot B).
  • Power-fail-safe metadata persistence with scratch-page journaling.
  • STM32 app-side UART3 framed OTA receive/write pipeline.
  • ESP32 protocol bridge integration.

Repository Layout

  • OTA: STM32 firmware workspace.
  • OTA/README.md: Technical details on file map, flash map, and build/flash details.
  • OTA/PROJECT_HANDOVER.md: Detailed architecture and roadmap.
  • OTA/ota_esp32: ESP32 companion workspace.

Authors

  • Sameeran Chandorkar
  • Jeffrey Hansen
  • Nick Baret
  • Anthony Lesik

Parts

10
QtyValueFootprintReferences
2Conn_01x15_PinConnector_PinHeader_2.54mm:PinHeader_1x15_P2.54mm_VerticalJ4, J5
2Conn_01x15_SocketConnector_PinSocket_2.54mm:PinSocket_1x15_P2.54mm_VerticalJ6, J7
2Conn_01x33_SocketConnector_PinSocket_2.54mm:PinSocket_1x33_P2.54mm_VerticalJ1, J2
1LOGOmy_footprints:U_LOGO_V1G***
1LOGOmy_footprints:ota_symG***
1~my_footprints:stm32F072BSTM32
1~my_footprints:UntitledESP32

Similar boards

  • 2 layers57 × 55.2 mmLogicAnalyzer, the printed circuit board in 3D

    LogicAnalyzer

    gusmanb/logicanalyzer

    24 channel, 100Msps logic analyzer hardware and software

    10 parts5.1kGPL-3.0
  • 2 layers32.2 × 15.4 mmProtector, the printed circuit board in 3D

    Protector

    byrantech/laptop

    anyon_e, a highly integrated, high end, open source laptop. Attempt the impossible.

    10 parts4.3kMIT
  • 2 layers26 × 18 mmConn, the printed circuit board in 3D

    Conn

    yaqwsx/KiKit

    Automation tools for KiCAD

    10 parts2.1kMIT
  • 2 layers44.3 × 30.5 mmLime2-SATA RevA, the printed circuit board in 3D

    Lime2-SATA RevA

    OLIMEX/OLINUXINO

    OLINUXINO is Open Source / Open Hardware, low cost from EUR 24 Linux Industrial grade Single Board Computer capable to operate -25+85C

    10 parts1.5k
  • 2 layers17.8 × 43.2 mmNano Adapter, the printed circuit board in 3D

    Nano Adapter

    VoronDesign/Voron-Hardware

    Cool Hardware designed by the Voron Design group

    10 parts1.1kGPL-3.0
  • 2 layers53.9 × 23.2 mmBuffer, the printed circuit board in 3D

    Buffer

    hoglet67/RGBtoHDMI

    Bare-metal Raspberry Pi project that provides pixel-perfect sampling of Retro Computer RGB/YUV video and conversion to HDMI

    10 parts1kGPL-3.0

Questions

How big is the OTA PCB PCB?

It measures 177.5 × 87.5 mm and has 2 copper layers, 1.6 mm thick.

What parts does the OTA PCB use?

10 parts. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the OTA PCB KiCad files?

From the sameeran-c/STM32_OTA_ABswap repository on GitHub, at the commit this page was made from: the board is OTA/hardware_design_resources/OTA_PCB.kicad_pcb. PCBKit opens the board in the browser, with nothing to install.

Can I use the OTA PCB design in my own project?

Its repository states no licence, so its author keeps all rights: ask sameeran-c before reusing the design.