diff --git a/firmware/hw_layer/flash.c b/firmware/hw_layer/flash.c index 9e3b055199..f716e48b00 100644 --- a/firmware/hw_layer/flash.c +++ b/firmware/hw_layer/flash.c @@ -14,17 +14,6 @@ #include "flash.h" #include -size_t flashSectorSize(flashsector_t sector) { - // sectors 0..11 are the 1st memory bank (1Mb), and 12..23 are the 2nd (the same structure). - if (sector <= 3 || (sector >= 12 && sector <= 15)) - return 16 * 1024; - else if (sector == 4 || sector == 16) - return 64 * 1024; - else if ((sector >= 5 && sector <= 11) || (sector >= 17 && sector <= 23)) - return 128 * 1024; - return 0; -} - flashaddr_t flashSectorBegin(flashsector_t sector) { flashaddr_t address = FLASH_BASE; while (sector > 0) { diff --git a/firmware/hw_layer/stm32f4/mpu_util.cpp b/firmware/hw_layer/stm32f4/mpu_util.cpp index 3dc3ae8215..72124946a1 100644 --- a/firmware/hw_layer/stm32f4/mpu_util.cpp +++ b/firmware/hw_layer/stm32f4/mpu_util.cpp @@ -10,6 +10,7 @@ #if EFI_PROD_CODE #include "mpu_util.h" +#include "flash.h" #include "error_handling.h" #include "engine.h" #include "pin_repository.h" @@ -420,5 +421,16 @@ CANDriver * detectCanDevice(brain_pin_e pinRx, brain_pin_e pinTx) { #endif /* EFI_CAN_SUPPORT */ +size_t flashSectorSize(flashsector_t sector) { + // sectors 0..11 are the 1st memory bank (1Mb), and 12..23 are the 2nd (the same structure). + if (sector <= 3 || (sector >= 12 && sector <= 15)) + return 16 * 1024; + else if (sector == 4 || sector == 16) + return 64 * 1024; + else if ((sector >= 5 && sector <= 11) || (sector >= 17 && sector <= 23)) + return 128 * 1024; + return 0; +} + #endif /* EFI_PROD_CODE */ diff --git a/firmware/hw_layer/stm32f7/mpu_util.cpp b/firmware/hw_layer/stm32f7/mpu_util.cpp index 7813dc7d55..db60df531e 100644 --- a/firmware/hw_layer/stm32f7/mpu_util.cpp +++ b/firmware/hw_layer/stm32f7/mpu_util.cpp @@ -7,6 +7,7 @@ #include "global.h" #include "mpu_util.h" +#include "flash.h" #include "error_handling.h" #include "engine.h" #include "pin_repository.h" @@ -411,3 +412,14 @@ CANDriver * detectCanDevice(brain_pin_e pinRx, brain_pin_e pinTx) { #endif /* EFI_CAN_SUPPORT */ +size_t flashSectorSize(flashsector_t sector) { + // sectors 0..11 are the 1st memory bank (1Mb), and 12..23 are the 2nd (the same structure). + if (sector <= 3 || (sector >= 12 && sector <= 15)) + return 32 * 1024; + else if (sector == 4 || sector == 16) + return 128 * 1024; + else if ((sector >= 5 && sector <= 11) || (sector >= 17 && sector <= 23)) + return 256 * 1024; + return 0; +} +