Merged
Conversation
45465e4 to
d5bc5f7
Compare
This will be used to discriminate against boards in installer and updater scripts.
This helps prevent the dangerous situation where you could write the wrong firmware to the wrong board. While writing the firmware for another family of board is likely not an issue, writing a firmware that looks valid enough to the boot rom for the board is likely to put the user in a pickle. Fixes Tow-Boot#3
This barely changes the behaviour compared to previously. The goal here is to minimize the changes when looking at the upcoming fallback logic.
This is done by splitting the write in a head and tail of the firmware. We first remove the SPI Flash from the boot chain by making it invalid (zeroing out the start). Then we write the end of the firmware. Finally we write the "head". Hopefully any unexpected failure (e.g. sudden power loss) happens before the head is written, this way the user is not "bricked".
d5bc5f7 to
d1130c4
Compare
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.
This brings some changes to the way SPI flashing is done.
Prevent flashing to the wrong board
(Fixes #3)
In this somewhat breaking change, the script will fail if the
$board_identifiervariable doesn't match a build-time hardcoded constant. This constant is coincidentally the identifier used in the attrset for the board. Though it could have been different if we desired so. The main thing to know is that this identifier will stay the same for the same board, allowing scripts to distinguish between boards.Flashing anyway
The easiest method is to drop to the shell (using ESC or CTRL-C during boot) and using
env set board_identifier XYZwhereXYZis the name of the board you want to flash to.Saved environment missing
$board_identifierWhile unlikely as the last stable version did not manage environment, and this will land on the same release as #34, here's the problem.
You might have a saved environment without
$board_identifierset. The fix is simple, useenv default board_identifierto reset that specific variable, andto save the environment.env saveHardened flashing scheme
(Fixes #28)
The idea is to first brick the SPI-installed firmware in a way the Boot ROM will not recognize. This means that if the installation is failing in an uncontrolled manner, the user should be able to recover using an alternate boot method (e.g. SD card or eMMC).
Then, after bricking, flash almost all of the new firmware. Then flash the missing bit.
By writing the "magic number" the Boot ROM looks for last, we harden ourselves from accidental partial writes. E.g. if there was sudden power loss.