Skip to content

feat: firmware update via Web UI (OTA upload, URL download, UF2, rollback)#3

Open
iu3qez wants to merge 7 commits intomainfrom
worktree-firmware-update
Open

feat: firmware update via Web UI (OTA upload, URL download, UF2, rollback)#3
iu3qez wants to merge 7 commits intomainfrom
worktree-firmware-update

Conversation

@iu3qez
Copy link
Copy Markdown
Owner

@iu3qez iu3qez commented Mar 3, 2026

Summary

  • Add complete firmware update capability to the Web UI: OTA upload from browser, OTA download from remote URL, UF2/ROM bootloader reboot for USB flashing
  • Automatic rollback if network stack (STA or AP) doesn't come up within configurable timeout after OTA
  • New Firmware.svelte page with drag-and-drop upload, URL input, progress bar, rollback and confirm buttons

Changes

  • api_firmware.c (new) — 6 HTTP handlers: status, upload, URL download, rollback, UF2 reboot, confirm
  • Firmware.svelte (new) — Full firmware management UI page with CRT terminal theme
  • main.c — OTA rollback confirmation based on network activity (STA connected or AP started)
  • parameters.yaml — New ota_confirm_timeout_s parameter (default 60s, range 10-300s)
  • types.ts / api.ts — FirmwareStatus type and 6 API client methods
  • CMakeLists.txt — Added esp_http_client, app_update, keyer_usb dependencies
  • sdkconfig.defaults — Allow HTTP for OTA (CONFIG_ESP_HTTPS_OTA_ALLOW_HTTP=y)

Design docs

  • docs/plans/2026-03-03-firmware-update-design.md
  • docs/plans/2026-03-03-firmware-update-plan.md

Test plan

  • Flash via Web UI upload (.bin file)
  • Flash via URL download (HTTP server)
  • Verify rollback: flash bad firmware, confirm auto-rollback after timeout
  • Verify manual confirm via /api/firmware/confirm
  • Verify UF2 reboot enters ROM bootloader
  • Verify rollback button reverts to previous partition
  • Verify 409 Conflict when two OTA operations attempted simultaneously
  • Verify progress bar updates during upload and download

🤖 Generated with Claude Code

iu3qez added 7 commits March 3, 2026 22:54
…rollback, UF2

Implements 6 HTTP handlers in api_firmware.c:
- GET /api/firmware/status: version, partition, OTA state, progress
- POST /api/firmware/upload: chunked binary OTA via httpd_req_recv
- POST /api/firmware/url: async OTA download via esp_http_client task
- POST /api/firmware/rollback: mark app invalid and reboot
- POST /api/firmware/uf2: enter USB UF2 bootloader mode
- POST /api/firmware/confirm: mark running app as valid
After WiFi and VPN initialization, check if the running firmware is
pending OTA verification. If so, poll for network connectivity (STA
connected or AP mode) up to a configurable timeout. On success, mark
the firmware valid; on timeout, reboot to trigger automatic rollback
to the previous firmware.
- Remove racy ota_init_once(); add api_firmware_init() called from webui_init()
- Add Content-Length check at start of upload handler
- Add URL length and scheme validation in URL download handler
- Add 10s stall protection in download task (zero_count > 100)
- Move OTA rollback check after webui_start() for web-based confirmation
- Bump max_uri_handlers from 32 to 40
- Disable upload/download buttons in frontend when OTA is busy
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