Skip to content

Developed a bootloader for the ESP32 microcontroller to enable flashing of multiple firmware versions and navigation between them using switches.

Notifications You must be signed in to change notification settings

SurajSonawane2415/multi-firmware-esp

Repository files navigation

Multi-Firmware-ESP

Developed a bootloader for the ESP32 microcontroller to enable flashing of multiple firmware versions and navigation between them using switches.

Table of Contents

Demonstrations

WhatsApp.Video.2024-04-04.at.01.57.19_b6041939.1.mp4

About the project

Project Workflow

  • Understanding bootloader:, Clarified my theories on bootloaders in embedded systems and how they work.
  • Look deep inside OTA code of ESP-IDF (master branch) to understand how it switches between firmware versions.
  • Implemented an OTA (Over The Air) update mechanism for ESP32, enabling firmware updates/uploads over WiFi from anywhere.
  • Developed a custom bootloader to select a particular firmware from multiple firmware options using switches(GPIO).
  • Implemented ESP-Serial-Flasher to flash firmware from the Master ESP to the second ESP, Over The Air (OTA) via WiFi from anywhere.
  • Currently, I am developing a OTA firmware update/upload mechanism to load multiple firmware in ESP at the bootloader stage to eliminate the need for a master ESP.

File Structure

👨‍💻Multi-Firmware-ESP
├ 📂 OTA_UPDATE_ESP32 //Contains code to flash firmware from the Master ESP to the second ESP, Over The Air (OTA) via WiFi.
| ├ 📂frontend
| |  └📄index.html
| └ 📂main
|   |   ├ 📂include
|   |   |  └📄flasher.h   
|   |   ├ 📄CMakeLists.txt
|   |   ├ 📄component.mk
|   |   ├ 📄favicon.ico
|   |   ├ 📄fileserver.c
|   |   ├ 📄flasher.c 
|   |   └ 📄main.c 
|   ├ 📄CMakeList.txt
|   ├ 📄Makefile
|   ├ 📄partitions_example.csv //custom partition table
|   └ 📄sdkconfig.defaults
├ 📂Components //Contains all the header and source files of esp-serial-flasher library   
├ 📂 custom_bootloader // contains custom bootloader code (Multi firmware ESP) to select a particular firmware from multiple firmware options using switches(GPIO).
|  ├ 📂 bootloader_override
|    ├ 📂bootloader_components // contains custom bootloader code
|    ├ 📂main
|    ├ 📄CMakeList.txt
|    ├ 📄Makefile
|    └ 📄sdkconfig
└ 📄README.md //Documentation of project
  • An embedded bootloader is a piece of software that takes a system from a power-up state to a usable state. To be more specific, it is the code that runs from the moment you press the power button, till the point in time where it reaches the main function in your code.

image

image

  • The OTA update mechanism allows a device to update itself based on data received while the normal firmware is running (for example, over Wi-Fi or Bluetooth.).
  • OTA requires configuring the Partition Tables of the device with at least two OTA app slot partitions (i.e., ota_0 and ota_1) and an OTA Data Partition. The Partition table defines the flash layout on ESP32.
  • image

Future Scope

  • Implement Over The Air Updates (OTA) Firmware update in bootloader stage to eliminate need of Master ESP for flashing the multiple firmwares into ESP.

Getting Started

Prerequisites

To download and use this code, the minimum requirements are:

  • ESP_IDF
  • Windows 7 or later (64-bit), Ubuntu 20.04 or later

Installation

Clone the project by typing the following command in your Terminal/CommandPrompt:

 `git clone --recursive https://github.com/SurajSonawane2415/multi-firmware-esp.git`

Navigate to the project folder: cd multi-firmware-esp

Usage

PART-1: ESP Serial Flasher (Over The Air)

To flash firmware from the Master ESP to the second ESP, Over The Air (OTA) via WiFi.

  • Hardware connection : Table below shows connection between two ESP32 devices.
ESP32 (master) ESP32 (second esp)
IO26 IO0
IO25 RESET
IO4 RX0
IO5 TX0

Once the requirements are satisfied, you can easily download the project and use it on your machine. After following the above steps, use the following commands to:

Navigate to the OTA_UPDATE_ESP32 folder: cd OTA_UPDATE_ESP32

To activate the IDF: get_idf

To configure wi-fi: idf.py menuconfig

  • Example Connection Configuration
    • WiFi SSID - Set wifi SSID
    • WiFi PASSWORD - Set wifi Password

To build the code: idf.py build

To flash the code: idf.py -p (PORT) flash monitor

PART-2: Custom Bootloader (Multi firmware ESP)

To use a custom bootloader (Multi firmware ESP) to select a particular firmware from multiple firmware options using switches(GPIO).

Navigate to the folder: cd custom_bootloader/bootloader_override

To activate the IDF: get_idf

To build the code: idf.py build

To flash the partition table: idf.py -p (PORT) partition-table-flash

To flash the custom bootloader: idf.py -p (PORT) bootloader-flash monitor

Resources

Contributor

Suraj Sonawane

Acknowledgements

SRA VITI for providing us with required resources and Special thanks to my mentors Moteen Shah and all the seniors at SRA, VJTI for their constant support and guidance throughout the project.

License

MIT License

About

Developed a bootloader for the ESP32 microcontroller to enable flashing of multiple firmware versions and navigation between them using switches.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published