From f029819af29e9c6cf4b1b9a360628c6d9030eac1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 26 Nov 2024 09:26:11 +1100 Subject: [PATCH] replace bootloader version in payload when the config client writes the eeprom area automatically replace the version byte with the right version to avoid the extra flash erase/write in update_EEPROM() --- bootloader/main.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bootloader/main.c b/bootloader/main.c index 17a0422..93656dd 100644 --- a/bootloader/main.c +++ b/bootloader/main.c @@ -428,6 +428,16 @@ static void decodeInput() return; } + if (address == EEPROM_START_ADD && payload_buffer_size > 2) { + /* + if the configuration client is writing the eeprom area + then replace the bootloader version byte in the buffer + with the right version. This makes the update_EEPROM() + less likely to need to erase any flash + */ + payLoadBuffer[2] = BOOTLOADER_VERSION; + } + if (!save_flash_nolib((uint8_t*)payLoadBuffer, payload_buffer_size,address)) { send_BAD_ACK(); } else {