From 937f7221983a17fcd43a7cf6cc5d4bf4d15d8ac2 Mon Sep 17 00:00:00 2001 From: Tim Gover Date: Sat, 5 Oct 2019 14:35:00 +0100 Subject: [PATCH] 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. --- rpi-eeprom-config | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rpi-eeprom-config b/rpi-eeprom-config index 993793f..ac34921 100755 --- a/rpi-eeprom-config +++ b/rpi-eeprom-config @@ -10,6 +10,8 @@ import sys IMAGE_SIZE = 512 * 1024 +MAX_BOOTCONF_SIZE = 2024 + # Each section starts with a magic number followed by a 32 bit offset to the # next section (big-endian). # 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() new_config_bytes = open(new_config, 'rb').read() new_len = len(new_config_bytes) + FILENAME_LEN + 4 - if new_len > length and new_len > 1024: - raise Exception('Config is too large') + if len(new_config_bytes) > MAX_BOOTCONF_SIZE: + 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: raise Exception('EEPROM image size exceeded')