Repository navigation
Add support for recovery bootloaders - #7035
Open
playfulFence wants to merge 1 commit into
Open
playfulFence wants to merge 1 commit into
playfulFence wants to merge 1 commit into
Conversation
playfulFence
marked this pull request as ready for review
December 4, 2026 16:15
playfulFence
requested review from
SergioGasquez,
bjoernQ and
bugadani
as code owners
December 4, 2026 16:15
playfulFence
force-pushed
the
bootloader/recovery-bootloader
branch
from
December 4, 2026 16:34
dd6a962 to
83854d3
Compare
This branch has not been deployed
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.
closes #6863
ESP32-C5, ESP32-C61, ESP32-P4, and ESP32-S31 have a recovery bootloader functionality. If the primary bootloader is broken, the ROM loads the recovery bootloader from the flash offset in eFuse. This PR uses it to update the bootloader safely:
BootloaderUpdater::install(staging)checks the new image, copies the current bootloader to the recovery offset, then writes the new image to the primary offset.BootloaderUpdater::restore()copies the recovery bootloader back to the primary offset.BootloaderUpdater::booted_from_recovery()returnstruewhen the ROM started the recovery bootloader.efuse::recovery_bootloader_offset()in esp-hal returns the recovery offset.The image check covers the header, chip ID, chip revision, checksum, and SHA-256. The updater does not burn the eFuse, user should do that manually and following new module documentation.
An AI tool generated a significant part of this change.
Testing
ESP32-C61 v1.0, eFuse set to recovery offset 0x3F0000, ESP-IDF v6.1 bootloader from espflash:
installwrites the new image to 0x0 and the backup to 0x3F0000. Both match the image byte for byte.restorerepairs the primary bootloader.success
damaged bootloader and restoring to the one in recovery.
Changelog
esp-bootloader-esp-idf
bootloader_updater::BootloaderUpdaterupdates the bootloader with the recovery bootloader as a backup (ESP32-C5, ESP32-C61, ESP32-P4, and ESP32-S31).esp-hal
efuse::recovery_bootloader_offset()(ESP32-C5, ESP32-C61, ESP32-P4, and ESP32-S31).