48 Commits

Author SHA1 Message Date
Tim Gover
9e9a954772 rpi-eeprom-config: Use time.monotonic for timeouts instead of wall clock
See: https://github.com/raspberrypi/rpi-eeprom/issues/790
2025-12-16 12:17:13 +00:00
Lincoln Thurlow
1c92bb9bc3 Fix the error message for config signing
When the user runs rpi-eeprom-config to sign a bootloader image,
if the image is not the correct size, the error message returns
a tautology:

rpi-eeprom-config -c boot.conf -p /tmp/rpi-pubkey.pem \
-o pieeprom.upd /tmp/downloaded-boot.img

ERROR: /tmp/downloaded-boot.img: \
Expected size 62914560 bytes actual size 62914560 bytes

When it should be alerting the user that there are only two
valid values for a bootloader size.  My MR addresses this issue
by returning the acceptable values for the bootloader size in the
image.

./rpi-eeprom-config -c boot.conf -p /tmp/rpi-pubkey.pem \
-o pieeprom.upd /tmp/downloaded-boot.img

ERROR: /tmp/downloaded-boot.img: \
Expected sizes [524288, 2097152] bytes, got actual size 62914560 bytes

Signed-off-by: Lincoln Thurlow <lincoln@isi.edu>
2025-11-11 19:52:32 +00:00
Tim Gover
4ee3f273eb rpi-eeprom-config: Improve No space available error message
Improve the error handler for the case where the new EEPROM config
exceeds the amount of available free space. Display the filename,
new size and space available.

N.B The 2711/pieeprom-2025-08-13.bin restores the free space to a
little of 4KB again.

See: https://github.com/raspberrypi/rpi-eeprom/issues/732
2025-08-18 10:07:37 +01:00
Tim Gover
adb3b9befc rpi-eeprom-config: Remove misleading message about cancelling updates
Flashrom is the default update mechanism on Pi5 and is not
cancellable. Remove this misleading message.
rpi-eeprom-update already has a message which knows about flashrom.
2024-12-12 13:52:31 +00:00
Tim Gover
585ec185f2 rpi-eeprom-config: Increase default timeouts
Increase the delays to compensate for an (unlikely) retry loop
if flashrom reports an error.
2024-12-09 19:12:00 +00:00
Andrew Scheller
f4996a1952 Add missing 'sudo' to rpi-eeprom-config's help-text 2024-10-09 09:31:36 +01:00
Tim Gover
d05f05c94f rpi-eeprom-config: Increase the timeout for flashrom shell-cmd
20 seconds is a little too short for safety with flashrom if every
page has to be erased and re-written. Bump this to 60 seconds
which is probably too long but nothing good will come from
interrupting flashrom.
2024-09-16 10:55:14 +01:00
Andrew Scheller
76b990a894 rpi-eeprom-config: fix rpi-eeprom-dgst typo in usage-text 2024-04-17 10:47:18 +01:00
Tim Gover
afa5822e03 rpi-eeprom-config: Add --debug flag to args 2024-04-17 10:46:10 +01:00
Tim Gover
a2fb4ed28d rpi-eeprom-config: Process bootcode arg with other file replacements
It should be possible to change the config, public key, signature
and signed bootcode in a single operation.
2024-04-17 10:46:10 +01:00
Tim Gover
07bf72a919 tools: Preliminary tool support for signed-boot on 2712
Update rpi-eeprom-config to support replacement of bootcode.bin
with a customer counter-signed version.

Add a new rpi-sign-bootcode script which enables bootcode.bin
to be counter-signed with the customer key.

N.B. Signed boot on 2712 requires newer firmware which is currently
under development and has not been released.
2024-03-27 14:45:28 +00:00
Peter Harper
c478689de0 Add new cacertder option
Allows you to add a custom ca cert to an image.

Note: This option is only relevant for newer (as yet unreleased)
bootloader images that support custom CA certs and reserve a space for
this in the flash image.
2024-03-01 13:26:06 +00:00
Tim Gover
db154d4710 rpi-eeprom-update: Add the option to use flashrom for updates on Raspberry Pi 5
On Raspberry Pi 5 there are dedicated pins for the bootloader SPI
EEPROM. This makes it possible to do immediate updates via flashrom.

The "current" EEPROM config is the EEPROM config at boot rather
than what has just been written to the SPI flash because this is
consistent with current behaviour.

To use flashrom instead of recovery.bin for bootloader updates
set RPI_EEPROM_USE_FLASHROM=1 in /etc/defaults/rpi-eeprom-update

BCM2711
On CM4, Pi4, CM4-S, Pi400 config.txt must be modified to disable
the analog audio driver which shares the GPIO pins used by the
bootloader EEPROM.

dtparam=spi=on
dtoverlay=audremap
dtoverlay=spi-gpio40-45
2023-11-02 16:54:34 +00:00
Tim Gover
9147a1a1c6 scripts: Add support for chip-specific firmware directories
BCM2711 and BCM2712 require different EEPROM firmware and
consequently the binaries have been moved to chip specific
firmware directories.

firmware-2711 / firmware-2712
2023-09-28 16:35:50 +01:00
Tim Gover
214cb6ffd4 rpi-eeprom-config: Make padding more robust.
Make it explicit that a modifiable file is stored withing a
single 4K sector (for erase) and that this includes the 20
byte header.

When modifying a file pad up to the next section instead of
just to an alignment size. This enables future changes to be
more flexible in terms of alignment and padding. Although,
files/sections with different padding requirements will likely
get a different magic.
2022-11-28 12:55:58 +00:00
Tim Gover
d2cbfbc292 rpi-eeprom-config: Add -x option to extract files
For test/debug add an option to extract all of the modifiable files.
2022-11-28 12:55:58 +00:00
Tim Gover
12907d02ff rpi-eeprom-config: Fix calls for reading/replacing bootconf.txt
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.
2021-11-23 11:26:27 +00:00
Tim Gover
3d5ab049d4 rpi-eeprom-config: Update to the same version as raspberrypi/usbboot
Update rpi-eeprom-config to include the secure-boot changes.
2021-11-13 15:50:23 +00:00
Tim Gover
28878ba2c5 rpi-eeprom-config: require python3
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.
2021-10-07 11:11:04 +01:00
Tim Gover
503f1c0055 rpi-eeprom-update: Display a warning when the bootloader is downgraded
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.
2021-05-17 15:21:29 +01:00
Nicolas Saenz Julienne
6fe6f22bad rpi-eeprom-config/update: Exit cleanly when not run on rpi4
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>
2021-02-09 15:22:52 +01:00
Nicolas Saenz Julienne
eeb4a19c7f rpi-eeprom-config: Properly decode sysfs binary files
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>
2021-01-26 13:05:43 +01:00
Nicolas Saenz Julienne
2aa97029fd rpi-eeprom-update: Get bootloader configuration from DT
Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
2021-01-22 19:20:22 +01:00
Tim Gover
d5c564d47c rpi-eeprom-config: Change --edit to use the current EEPROM config
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
2020-11-15 21:36:09 +00:00
Tim Gover
7612907337 Add the timestamp of the update to the pieeprom.sig file.
Add the timestamp to pieeprom.sig for use with a future bootloader
update.

This is not relevant for the VL805 firmware because it is not
configurable.
2020-10-28 07:40:59 +00:00
Tim Gover
718820bceb rpi-eeprom-config: Use decode('utf-8') to convert subprocess txt
This matters on Python3 but not on Python2
2020-10-05 19:35:12 +01:00
Tim Gover
84e4615814 rpi-eeprom-config: Update help for --edit
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.
2020-10-04 09:55:16 +01:00
Tim Gover
e63f3dcfc3 Require 'sudo' for --edit or --apply instead of spawing sudo command 2020-09-30 11:44:10 +01:00
Tim Gover
5ab94e88f2 rpi-eeprom-config: Update --edit to read config from pending updates
Use the config from the pending update if there is one so that it's
possible to make multiple edits before rebooting.
2020-09-28 10:41:20 +01:00
Tim Gover
ca647a6b90 Fix doc comments and ignore package checksums 2020-09-28 10:41:20 +01:00
Tim Gover
ccd8444501 Implement review comments
Update --apply --edit to allow the eeprom image to be specified.
Add some error checking around chmod in rpi-eeprom-update

TODO: Test this on NFS
2020-09-28 10:41:20 +01:00
Tim Gover
55ece6bab5 rpi-eeprom-config: Add --edit for interactive editor style operation 2020-09-28 10:41:20 +01:00
Tim Gover
1fe54409b8 rpi-eeprom-config: Add new option to apply config and update in one operation
* 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
2020-09-28 10:41:20 +01:00
Pyry Kontio
5ae98cbbac Use /usr/bin/env python to make rpi-eeprom-config more portable 2020-07-06 13:51:44 +09:00
andrum99
7e587b8092 rpi-eeprom-config: Pi 4B -> Pi 4 2020-05-12 14:37:52 +01:00
Tim Gover
a987322821 rpi-eeprom-config: Fix padding calculation 2020-01-14 15:29:20 +00:00
Andrew Pattison
95e86d7e59 Fix cap per @lurch 2019-11-22 22:56:28 +00:00
Andrew Pattison
9e8ea44c99 FIx up per @lurch's comments 2019-11-22 22:39:32 +00:00
Andrew Pattison
6bfe0c05c5 Some further corrections 2019-11-22 21:25:25 +00:00
Andrew Pattison
040f4cf507 Fix up help text per @lurch's comments in #57
Operating mode 3 failed to mention that the output file should be specified using the --out parameter.
2019-11-22 21:07:59 +00:00
Andrew Pattison
7d77dc224e Revert mistaken change to parser config 2019-11-22 10:30:08 +00:00
Andrew Pattison
fc6405cfab Correct help text per timg236's comments 2019-11-21 21:49:52 +00:00
andrum99
179d7d7558 rpi-eeprom-config - fix up help text (and therefore also man page)
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.
2019-11-21 18:19:53 +00:00
MilhouseVH
dcdb6e9448 Add Python3 support 2019-10-28 18:56:47 +00:00
Tim Gover
937f722198 rpi-eeprom-config: Increase the configuration size limit to 2024
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.
2019-10-07 08:49:24 +01:00
Tim Gover
1ba58068ea Set unused data to zero if size of config is reduced
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.
2019-09-24 13:39:42 +01:00
Tim Gover
f9a4a6f1ab Fix magic number check 2019-09-12 11:52:04 +01:00
Tim Gover
8bf77cece1 Initial revision
Import the files used for the first beta release.
2019-09-02 11:46:15 +01:00