From 3c08483e35df2be08b4e170b8ea6ed2aa555c7f4 Mon Sep 17 00:00:00 2001 From: Florian Loitsch Date: Wed, 12 Jun 2024 10:42:01 +0200 Subject: [PATCH] Pad the config. (#2400) Co-authored-by: Kasper Lund --- tools/firmware.toit | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/firmware.toit b/tools/firmware.toit index bb9b5e993..b486aaea9 100644 --- a/tools/firmware.toit +++ b/tools/firmware.toit @@ -730,9 +730,15 @@ extract-host parsed/cli.Parsed envelope/Envelope --config-encoded/ByteArray: parts.add { "type": "run-image", "from": part-start, "to": bits.size } part-start = bits.size + config-buffer := io.Buffer // Add the size to have a similar layout to the ESP32 binary. - bits.little-endian.write-uint32 config-encoded.size - bits.write config-encoded + config-buffer.little-endian.write-uint32 config-encoded.size + config-buffer.write config-encoded + // Pad the config to 4 KB. This makes it less likely that the header (which includes + // the config-part size) changes for different configurations. + // We use 'N', since that's a NOP in UBJSON. + config-buffer.pad --alignment=(4 * 1024) --value='N' + bits.write config-buffer.bytes parts.add { "type": "config", "from": part-start, "to": bits.size } part-start = bits.size