The config read/update APIs have been replaced with generic
read/replace 'boot file' APIs in order to support secure-boot.
The previous secure-boot related commits broke the interactive
rpi-eeprom-config --edit/-a options.
Require python3 instead of relying on all distros including
python-is-python3 etc.
The code will still work with python2 but distros which require
python2 will need to maintain that as a downstream patch.
Display a warning if the bootloader version is downgraded. This can
happen when swapping boot-media and the bootloader configuration is
changed from an OS with an old version of the rpi-eeprom package.
Remove the duplicated "update pending" and "to cancel update" messages.
Some users might forcibly install this on a board that isn't an rpi4.
Exit early, and explain why the program can't be run.
Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
The previous implementation was reading the sysfs files as plain text
and encoding them as 'ascii' to remove all the trailing zeros. This is
wrong twofold. To start with, the sysfs file we're querying are binary
files[1], and we're reading it as a string. On top of that we're
benefiting that *some* python implementations of string.encode() will
deal with trailing zeros.
Fix this by marking the files as binary and decoding them as strings
before consuming them.
[1] sysfs files are generally text based, but there is also the option
to output binary data. Our configuration file does the later.
Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Always use the current EEPROM configuration unless there is an
update pending in which case use that to support incremental edits.
Update help and update message to indicate that
'sudo rpi-eeprom-update -r'
may be used to cancel a pending update.
Fix a few comments
Add -E to sudo in the example to preserve the environment.
Remove the redundant escaping of single quotes now that the help is
enclosed in triple quotes.
* Add -a/--apply parameter which provides a one shot image for applying
a new configuration to the latest bootloader image and installs it
via rpi-eeprom-update.
* Print the live configuration if no arguments are specified.
* Add short flags instead of requiring verbose names.
* Make the errors more human readable instead of Exceptions
The current help text for rpi-eeprom-config are unclear. This PR changes them so that the help text matches what the tool does and what each parameter specifies. The man page, automatically derived from the help text, is also fixed.
Update the rpi-eeprom-config tool to accept config files of up to
2024 byte. The config section has a 24byte header so the section is
always <= 2KiB.
This allows a reasonably large user-data section in the config file
accessible via 'vcgencmd bootloader_config' as an alternative to
customer OTP data.
N.B. The vcgencmd uses a single VCHIQ message which is limited to
4092 bytes. Setting a 2KiB limit here gives room for user-data plus
some spare space for future config expansion before an VCHIQ bulk
message or an extra EEPROM 4KiB page is required.
If the size of bootconf.txt is reduced then set the unused data
to all ones instead of leaving garbage at the end. The EEPROM
header contains the actual file but this makes it easier to
verify the image and makes overreads more obvious.