Skip to content

USB & OTA Bootloader Firmware with Custom STM32 Board Design and Integrated Wi-Fi!

Notifications You must be signed in to change notification settings

SurajSonawane2415/USB-OTA-Bootloader-Integrated-Custom-STM-Board

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 

Repository files navigation

Forks Stargazers Issues LinkedIn


Logo

USB OTA Bootloader Integrated Custom STM Board

USB & OTA Bootloader Firmware with Custom STM32 Board Design and Integrated Wi-Fi!
Explore the docs »

View Outcomes · Report Bug · Request Feature · Send a Pull Request

Table of Contents

About The Project

The project involves developing a custom STM32 board with integrated USB and Over-the-Air (OTA) bootloader capabilities, featuring an onboard ESP32 Wi-Fi module. Users can flash firmware onto the STM32 microcontroller either through USB using DFU mode or wirelessly via Wi-Fi for remote updates. The USB bootloader ensures secure and validated firmware updates, while the OTA bootloader simplifies wireless updates without requiring physical access. The custom PCB is designed around the STM32F103 microcontroller, optimized for seamless USB and Wi-Fi communication. The onboard ESP32 enables the board to be used in various Wi-Fi-based projects, including IoT applications and remote monitoring systems. This makes the board highly versatile for developers working on embedded and network-connected systems.

Project Workflow

  • Implemented USB Bootloader: Developed a USB bootloader using DFU mode for firmware updates via USB.

  • Implemented OTA Bootloader: Developed an OTA bootloader using the onboard ESP32 Wi-Fi module, enabling wireless firmware updates.

  • Custom STM Board Design: Designed a custom PCB for the STM32F103 microcontroller in KiCad, optimized for USB and Wi-Fi communication.

  • Currently Manufacturing and Testing: The board is in the manufacturing stage. After that, I will proceed with assembly and testing.

STM32 USB DFU Bootloader

usb1

The USB DFU Bootloader is a custom firmware update solution designed for STM32 microcontrollers, leveraging the USB Device Firmware Upgrade (DFU) protocol for standardized and efficient firmware updates. It initializes the USB peripheral and handles DFU control and data transfer requests through a dedicated state machine. The bootloader is placed in the flash memory's beginning and checks for boot conditions to decide whether to enter DFU mode or execute the main application. A post-build script for STM32CubeIDE automates firmware uploading using STM32CubeProgrammer, ensuring streamlined deployment and updates. This implementation supports reliable firmware management and easy upgrades in a standardized manner.

  • USB DFU bootloader sequence:

usb2

STM32 OTA Bootloader

Logo

The STM32 OTA Bootloader enables firmware updates over UART using an ESP32 as the host for over-the-air (OTA) updates. The custom bootloader on the STM32 receives the new firmware from the ESP32, writes it to flash memory (128 KB in size), and verifies the integrity using a verifyFlashedData function to ensure data accuracy.

The ESP32 communicates with the STM32 via UART, transferring the firmware in chunks and triggering a reboot once the transfer is complete. Error handling is implemented to prevent booting corrupted firmware, ensuring the system only runs verified updates. The bootloader also carefully manages flash memory, avoiding conflicts with existing data.

This implementation allows remote firmware updates without physical access, making it ideal for field-deployed systems requiring periodic updates.

STM32 Custom Development Board

The custom development board is built around the STM32F103RBT6 microcontroller, featuring a 64-pin LQFP package and an Arduino shield-compatible layout. It incorporates an ESP32-WROOM-32D module for dual-core Wi-Fi and Bluetooth communication. The board features protection diodes for over-voltage and reverse polarity protection, along with a slider switch for boot mode selection (enabling easy access to boot0/boot1 for flashing or debugging). It also includes a 32.768kHz crystal for real-time clock (RTC) functionality, and an 8MHz crystal for the main system clock, ensuring precise timing. Additionally, sensor ports, power regulation circuits, and GPIO breakout headers enhance its functionality, making it ideal for high-performance embedded applications.

Project Outcomes

STM32 USB DFU Bootloader:

  • Firmware uploaded via STM32CubeIDE with custom USB DFU bootloader:

Logo

STM32 OTA Bootloader:

  • Wi-Fi AP for OTA firmware upload:

Logo

  • HTTPS file server for secure uploads:

Logo

  • OTA Output:

Logo

STM32 Custom Development Board:

  • Final PCB design image:

Logo

Features

  • Arduino Shield Compatibility: Standard headers for easy integration with Arduino-compatible shields and peripherals.
  • Integrated OTA Bootloader: Supports Wireless over-the-air firmware updates enabled via the onboard ESP32 module.
  • Integrated USB Bootloader: Supports firmware flashing via USB, eliminating the need for external programmers.
  • Onboard Wi-Fi Module: ESP32-WROOM-32D module for seamless integration with Wi-Fi-based projects.

Hardware and Software Used

Hardware:

  • STM32F103RBT6: Main microcontroller with 64-pin configuration.
  • ESP32-WROOM-32D: Onboard Wi-Fi module for OTA updates and wireless communication.

Software:

  • STM32CubeIDE: IDE for developing and debugging STM32 applications.
  • STM32CubeProgrammer: Tool for programming and managing firmware updates via USB.
  • libopencm3: Open-source library for STM32 peripheral control.
  • dfu-util: Tool for performing USB Device Firmware Upgrade (DFU) on STM32.
  • Batch Script: Automates firmware flashing with STM32CubeIDE.

Contributor

Acknowledgements

Special thanks to Prof. Sidharth Tallur for his guidance and support throughout my internship at WEL Lab, IIT Bombay. I also extend my sincere gratitude to Mr. Mahesh Bhanganagare, Mr. Ankur Agrawal, Mr. Maheshwar Mangat, and Mr. Amit Shetye for their guidance, resources, and creating a supportive environment that greatly helped my learning and growth.

Resources

About

USB & OTA Bootloader Firmware with Custom STM32 Board Design and Integrated Wi-Fi!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published