-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Add ESP32 bootloader upgrade capability to OTA update page with JSON API support and ESP-IDF validation #4984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Copilot
wants to merge
28
commits into
main
Choose a base branch
from
copilot/fix-d4f5fc55-f916-458a-9155-deb9bbff6662
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+715
β158
Draft
Changes from 7 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
30fbf55
Initial plan
Copilot 93908e7
Add ESP32 bootloader upgrade functionality with JSON API support
Copilot a18a661
Add esp_flash.h include for ESP32 bootloader flash operations
Copilot c3e1890
Improve bootloader flash implementation with proper erase and write oβ¦
Copilot 042ed39
Fix: Remove static keyword from getBootloaderSHA256Hex() to match decβ¦
Copilot f5f3fc3
Fix: Cast min() arguments to size_t for ESP32-C3 compatibility
Copilot d79b023
Fix: Move bootloader JavaScript to separate script block to avoid Getβ¦
Copilot 62c78fc
Refactor bootloader upload to buffer entire file in RAM before flash β¦
Copilot f4b98c4
Add ESP-IDF bootloader image validation before flash operations
Copilot da1d53c
Enhance bootloader validation to match esp_image_verify() checks compβ¦
Copilot 76bb3f7
Initial plan
Copilot 5f33c69
Fix copilot-instructions.md to require mandatory build validation
Copilot e2b8f91
Reference Hardware Compilation section for common environments list
Copilot 2acf731
Update platformio.ini
wled-compile f0182eb
safety check for bootloop action tracker: bring it back on track if oβ¦
DedeHai 186c4a7
fix low brightness gradient "jumpyness"
DedeHai 1dd338c
Fix blank area issue with Twinkle (#5005)
benjamw 4973fd5
Adding DDP over WS, moving duplicate WS-connection to common.js (#4997)
DedeHai eb80fdf
Game of Life Rework
Brandon502 0391488
Game of Life Optimizations
Brandon502 7e1992f
adding function to check if a backup exists
DedeHai 46ff438
check config backup as welcome page gate
DedeHai 0f06535
Include audioreactive for hub75 examples
netmindz 8e00e71
Include audioreactive for hub75 examples - MOONHUB audio
netmindz 5fb3713
Include esp32 debug build
netmindz acd415c
fix release name for esp32
netmindz c623b82
improve esp32_dev env
netmindz 1afd72c
Initial plan
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's unsafe to erase anything while the upload is incomplete. The bootloader should fit in a buffer in RAM; ensure the data is fully is ready before making any irreversible changes to the flash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I share the concerns that @willmmiles mentions. The bootloader should be buffered first, then validated (correct architecture, version, hash, etc). If everything is good, try to disable any other active task, and write the bootloader to flash.
Without these safety steps, an interrupted or corrupted upload will brick the esp32, and a reflash via USB will be needed to bring it back to life.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a standard part of the IDF that can perform this validation @copilot ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the ESP-IDF provides validation functions through the bootloader support component. Key functions include:
esp_image_verify()- Verifies bootloader image integrity (checks magic bytes, segments, checksums)bootloader_common_check_chip_validity()- Validates the image is for the correct chip architectureesp_image_get_metadata()- Extracts and validates image metadata including segmentsThe proper approach would be:
esp_image_verify()to validate before any flash operationsesp_flash_erase_region()andesp_flash_write()after successful validationThis would require refactoring the current implementation to accumulate all data first rather than streaming writes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please apply these changes @copilot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented in commit 62c78fc (buffering) and the latest commit. The bootloader upload now includes:
Buffering (commit 62c78fc):
Validation (latest commit):
esp_image_format.hinclude for ESP-IDF image validationverifyBootloaderImage()function that validates:This prevents device bricking from incomplete, corrupted, or structurally invalid uploads. Both ESP32 and ESP32-C3 builds compile successfully.