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.
This commit is contained in:
Tim Gover
2019-10-05 14:35:00 +01:00
parent f8a8cf11bf
commit 937f722198

View File

@@ -10,6 +10,8 @@ import sys
IMAGE_SIZE = 512 * 1024 IMAGE_SIZE = 512 * 1024
MAX_BOOTCONF_SIZE = 2024
# Each section starts with a magic number followed by a 32 bit offset to the # Each section starts with a magic number followed by a 32 bit offset to the
# next section (big-endian). # next section (big-endian).
# The number, order and size of the sections depends on the bootloader version # The number, order and size of the sections depends on the bootloader version
@@ -55,8 +57,9 @@ class BootloaderImage(object):
hdr_offset, length = self.find_config() hdr_offset, length = self.find_config()
new_config_bytes = open(new_config, 'rb').read() new_config_bytes = open(new_config, 'rb').read()
new_len = len(new_config_bytes) + FILENAME_LEN + 4 new_len = len(new_config_bytes) + FILENAME_LEN + 4
if new_len > length and new_len > 1024: if len(new_config_bytes) > MAX_BOOTCONF_SIZE:
raise Exception('Config is too large') raise Exception("Config is too large (%d bytes). The maximum size is %d bytes."
% (len(new_config_bytes), MAX_BOOTCONF_SIZE))
if hdr_offset + len(new_config_bytes) + FILE_HDR_LEN > IMAGE_SIZE: if hdr_offset + len(new_config_bytes) + FILE_HDR_LEN > IMAGE_SIZE:
raise Exception('EEPROM image size exceeded') raise Exception('EEPROM image size exceeded')