OTA: upload a custom firmware.bin from the web UI - #175
Open
fl4p wants to merge 2 commits into
Open
Conversation
Builds against framework-espidf 5.5.0 fail with implicit-declaration errors for GPIO_IS_VALID_GPIO and gpio_wakeup_enable in deep_sleep / light_sleep. driver/rtc_io.h no longer pulls in driver/gpio.h transitively on this IDF version.
The existing OTA flow fetches an HTTPS image from a hardcoded GitHub URL, which is unusable when developing patches against a fork. Add a file picker + raw-binary POST upload to the OTA page. Frontend: ota.html grows a "Upload custom firmware" section with file input, a flash button, and an inline progress bar. Submission uses fetch/XHR with the File object as the request body — no multipart parsing on the device side. Backend: src/urihandler/uploadfwhandler.c streams the body in 4 KB chunks straight through esp_ota_write() to the inactive OTA slot, calls esp_ota_set_boot_partition() on success, and schedules a 2-second restart via the existing restartByTimer infrastructure. Lock-aware (redirects to /lock when UI is locked). NVS is not touched, so settings survive.
This was referenced May 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
/otaonly fetches a hardcoded GitHub URL — breaks any workflow that wants to flash a dev build or a fork without USB access.POST /uploadfwaccepts the firmware as the raw request body (no multipart). The handler streams 4 KB chunks straight intoesp_ota_write()on the inactive partition, callsesp_ota_set_boot_partition(), schedules a 2s restart via the existingrestartByTimerinS(). Lock-aware. NVS untouched, settings survive.pages/ota.htmladds a file picker + a confirm-on-click button + an inline progress bar; XHR withContent-Type: application/octet-stream.Tested live: 1.4 MB upload → HTTP 200 in 8.8s → reboot in ~1s → device back on the same IP with all settings.
Complements #176 (edit the OTA URL instead of replacing the path). First commit is a build-fix shared with #174/#176.