You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ut...@apache.org on 2019/01/17 04:05:49 UTC
[mynewt-core] branch master updated: Only erase FLASH_BANK_2 when
available
This is an automated email from the ASF dual-hosted git repository.
utzig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
The following commit(s) were added to refs/heads/master by this push:
new 831bc7e Only erase FLASH_BANK_2 when available
831bc7e is described below
commit 831bc7ec28be2bc6ec38ee179cd143ae586a4949
Author: Alvaro Prieto <so...@alvaroprieto.com>
AuthorDate: Tue Jan 15 17:57:43 2019 -0800
Only erase FLASH_BANK_2 when available
Some parts in the STM32L4xx family do not have a FLASH_BANK_2.
(The STM32L432 for example)
This results in a compile error. Added #define to prevent this.
---
hw/mcu/stm/stm32l4xx/src/hal_flash.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/hw/mcu/stm/stm32l4xx/src/hal_flash.c b/hw/mcu/stm/stm32l4xx/src/hal_flash.c
index 7330d59..dba2a69 100644
--- a/hw/mcu/stm/stm32l4xx/src/hal_flash.c
+++ b/hw/mcu/stm/stm32l4xx/src/hal_flash.c
@@ -36,11 +36,16 @@ stm32_mcu_flash_erase_sector(const struct hal_flash *dev, uint32_t sector_addres
if (!(sector_address & (_FLASH_SECTOR_SIZE - 1))) {
eraseinit.TypeErase = FLASH_TYPEERASE_PAGES;
+#ifdef FLASH_BANK_2
if ((sector_address - dev->hf_base_addr) < (_FLASH_SIZE / 2)) {
eraseinit.Banks = FLASH_BANK_1;
- } else {
+ }
+ else {
eraseinit.Banks = FLASH_BANK_2;
}
+#else
+ eraseinit.Banks = FLASH_BANK_1;
+#endif
eraseinit.Page = (sector_address - dev->hf_base_addr) / FLASH_PAGE_SIZE;
eraseinit.NbPages = 1;
rc = HAL_FLASHEx_Erase(&eraseinit, &PageError);