From 8e57090d66244f1ef7c6e0f889b3507029b2cd89 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Thu, 27 May 2021 08:18:03 +0200 Subject: [PATCH] Use real bootloader size when flashing --- radio/src/io/bootloader_flash.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/radio/src/io/bootloader_flash.cpp b/radio/src/io/bootloader_flash.cpp index 09b3fc81b..b39f0f094 100644 --- a/radio/src/io/bootloader_flash.cpp +++ b/radio/src/io/bootloader_flash.cpp @@ -67,6 +67,11 @@ void BootloaderFirmwareUpdate::flashFirmware(const char * filename, ProgressHand POPUP_WARNING(STR_SDCARD_ERROR); break; } + if (count != sizeof(buffer) + && !f_eof(&file)) { + POPUP_WARNING(STR_SDCARD_ERROR); + break; + } if (i == 0 && !isBootloaderStart(buffer)) { POPUP_WARNING(STR_INCOMPATIBLE); break; @@ -74,14 +79,10 @@ void BootloaderFirmwareUpdate::flashFirmware(const char * filename, ProgressHand for (UINT j = 0; j < count; j += FLASH_PAGESIZE) { flashWrite(CONVERT_UINT_PTR(FIRMWARE_ADDRESS + i + j), CONVERT_UINT_PTR(buffer + j)); } - - // TODO: use real bootloader size rather than the maximum size - progressHandler("Bootloader", STR_WRITING, i, BOOTLOADER_SIZE); + progressHandler("Bootloader", STR_WRITING, i, file.obj.objsize); // Reached end-of-file - if (count != sizeof(buffer)) { - break; - } + if (f_eof(&file)) break; #if defined(SIMU) // add an artificial delay and check for simu quit