From 9c6cd159805e2f9e9d017d230ab0137e5a9eb3a4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 23 Dec 2019 17:31:15 +1100 Subject: [PATCH] HAL_ChibiOS: ensure bootloader flash is multiple of 32 bytes --- libraries/AP_HAL_ChibiOS/Util.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libraries/AP_HAL_ChibiOS/Util.cpp b/libraries/AP_HAL_ChibiOS/Util.cpp index dfe42a39bd..e839b41463 100644 --- a/libraries/AP_HAL_ChibiOS/Util.cpp +++ b/libraries/AP_HAL_ChibiOS/Util.cpp @@ -178,6 +178,9 @@ bool Util::flash_bootloader() return false; } + // make sure size is multiple of 32 + fw_size = (fw_size + 31U) & ~31U; + const uint32_t addr = hal.flash->getpageaddr(0); if (!memcmp(fw, (const void*)addr, fw_size)) { hal.console->printf("Bootloader up-to-date\n");