From de6a0c2f40cf6f2083d953cb84c203fa5c605aad Mon Sep 17 00:00:00 2001 From: Niklas Hauser Date: Wed, 27 Mar 2024 23:06:31 +0100 Subject: [PATCH] fixup! [flash] STM32G4 flash erase dual bank BKER bit --- src/modm/platform/flash/stm32/flash.cpp.in | 2 +- src/modm/platform/flash/stm32/module.lb | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/modm/platform/flash/stm32/flash.cpp.in b/src/modm/platform/flash/stm32/flash.cpp.in index 15909521f7..870d3bfd93 100644 --- a/src/modm/platform/flash/stm32/flash.cpp.in +++ b/src/modm/platform/flash/stm32/flash.cpp.in @@ -95,7 +95,7 @@ Flash::erase(uint8_t index) %% if dual_bank uint32_t cr = FLASH_CR_STRT | FLASH_CR_PER; uint32_t page = index; - %% set second_bank = 256 if family == "g0" else "(Size/2 >> 11)" + %% set second_bank = "(Size/2 >> 11)" if (FLASH->OPTR & {{dual_bank}} and index >= {{second_bank}}) { page -= {{second_bank}}; diff --git a/src/modm/platform/flash/stm32/module.lb b/src/modm/platform/flash/stm32/module.lb index a9211da37b..400f14b6ca 100644 --- a/src/modm/platform/flash/stm32/module.lb +++ b/src/modm/platform/flash/stm32/module.lb @@ -45,8 +45,9 @@ def build(env): block_shift = 10 elif target.family in ["g0"]: busy_bit = "FLASH_SR_BSY1" - dual_bank = "FLASH_OPTR_DUAL_BANK" - block_shift = "(FLASH->OPTR & FLASH_OPTR_DUAL_BANK ? 11 : 12)" + block_shift = 11 + if target.name[0] in ["b", "c"]: + dual_bank = "FLASH_OPTR_DUAL_BANK" elif target.family in ["g4"]: block_shift = 11 # Only Cat3 devices have dual bank, so g47x or g48x