Skip to content

feat(ota): firmware update via web (/update page)#358

Open
wendells01 wants to merge 2 commits into
esp32-si4732:mainfrom
wendells01:feat/ota-update
Open

feat(ota): firmware update via web (/update page)#358
wendells01 wants to merge 2 commits into
esp32-si4732:mainfrom
wendells01:feat/ota-update

Conversation

@wendells01

Copy link
Copy Markdown

PR: Over-the-Air (OTA) firmware update via WebUI

Summary

Adds a /update web page that accepts a .bin firmware binary via HTTP POST and applies it using the existing A/B OTA partition scheme. A progress bar is shown on the TFT display during the update.

What was changed

3 files changed, +167 lines, 0 OBD code.

ats-mini/Common.h (+2 lines)

  • Added extern volatile int otaProgress — shared state between Network.cpp (update handler) and Draw.cpp (rendering), tracks progress from -1 (idle) to 100 (complete).

ats-mini/Draw.cpp (+27 lines)

  • At the top of drawScreen(), checks otaProgress >= 0 — if an update is active, the entire screen is replaced with a dedicated OTA screen showing:
    • "OTA UPDATE" title
    • "Do not power off!" warning
    • Progress bar (white border, green fill, proportional)
    • Percentage text centered below
  • This runs in the main loop (no FreeRTOS task needed) — the OTA chunk handler from Network.cpp updates otaProgress, and drawScreen() renders it on the next frame.

ats-mini/Network.cpp (+138 lines)

  • #include <Update.h> — ESP32's OTA library
  • webUpdatePage() — HTML page with a file upload form (accepts .bin only), "Update" nav link on Status/Config/Memory pages
  • /update GET handler — serves the upload form
  • /update POST handler (multi-part body handler):
    • Validation: rejects non-.bin files and binaries smaller than 100KB (safety guard)
    • Chunk streaming: calls Update.write(data, len) for each chunk; tracks progress as percentage via Update.size()
    • Finalization: calls Update.end(true) to apply; reboots on success
    • Error handling: returns a styled error page with the ESP32's error string on failure
    • Display progress: updates the otaProgress global, which drawScreen() reads on every frame

How to use

  1. Build the firmware for your board normally (the .bin will be in the build output)
  2. Open the ATS-Mini web interface at http://<device-ip>/
  3. Click "Update" in the navigation bar, or go directly to http://<device-ip>/update
  4. Select the .bin firmware file (e.g., firmware.ino.esp32s3.bin)
  5. Click "Upload & Update"
  6. The TFT will show the OTA progress screen; wait for completion
  7. The device reboots automatically into the new firmware

ℹ️ Safety: The existing A/B partition scheme ensures the device can roll back to the previous firmware if the update fails. Do not power off during the update.

Compatibility

  • Uses Update.begin(UPDATE_SIZE_UNKNOWN, U_FLASH) — compatible with all ESP32-S3 board profiles (ospi, qspi, lilygo-t-embed)
  • Works with the existing A/B OTA partition scheme (app0/app1 at 3MB each)
  • No changes to the partition table or bootloader

Files NOT modified (for reviewer confidence)

  • No changes to BLE stack, radio tuning, audio path, or any OBD-related code
  • Only 3 files touched, each change self-contained

- New /update upload form at <device-ip>/update
- Binary validation (extension + min size)
- OTA progress bar on TFT display during update
- Uses existing A/B partition scheme (safe rollback)
- Nav links added to Status, Config and Memory pages
…Length

request->contentLength() returns the full multipart form body size (including
boundaries/headers), not the actual firmware binary. Update.begin() rejected the
mismatch with 'Bad Size Given'. Now uses UPDATE_SIZE_UNKNOWN + tracks total
bytes written to validate minimum size at the end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant