From 6fc1ff225e316c9a67902159f3347f30e53ec644 Mon Sep 17 00:00:00 2001 From: balanceTWK Date: Tue, 10 Sep 2019 20:22:03 +0800 Subject: [PATCH] stm32:L4:flash: support erasing pages on bank 2 Reviewed-by: Karl Palsson (fixed code style) --- lib/stm32/l4/flash.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/stm32/l4/flash.c b/lib/stm32/l4/flash.c index 16007ee6..b8df4521 100644 --- a/lib/stm32/l4/flash.c +++ b/lib/stm32/l4/flash.c @@ -160,6 +160,9 @@ void flash_erase_page(uint32_t page) /* page and bank are contiguous bits */ FLASH_CR &= ~((FLASH_CR_PNB_MASK << FLASH_CR_PNB_SHIFT) | FLASH_CR_BKER); + if (page > 255) { + FLASH_CR |= FLASH_CR_BKER; + } FLASH_CR |= page << FLASH_CR_PNB_SHIFT; FLASH_CR |= FLASH_CR_PER; FLASH_CR |= FLASH_CR_START;