This is an automated email from the ASF dual-hosted git repository.
jerzy 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 494057320 hw/mcu/stm32f3: Fix flash write
494057320 is described below
commit 4940573209f2e7d2758a2ea24b159a7903201f45
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Sat Jun 29 16:14:30 2024 +0200
hw/mcu/stm32f3: Fix flash write
STM32_HAL_FLASH_INIT macro was empty unlike all other
implementations leaving embedded flash locked.
stm32_mcu_flash_erase_sector() unlocked flash before erase
and locked it afterwards.
Erase flash worked but write did not since write is
done in common stm32 code that assumed that flash is
unlocked.
Now flash is unlocked at the start and not locked during
erase.
Signed-off-by: Jerzy Kasenberg <[email protected]>
---
hw/mcu/stm/stm32f3xx/include/mcu/stm32_hal.h | 5 ++++-
hw/mcu/stm/stm32f3xx/src/hal_flash.c | 2 --
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/hw/mcu/stm/stm32f3xx/include/mcu/stm32_hal.h
b/hw/mcu/stm/stm32f3xx/include/mcu/stm32_hal.h
index f6f231a31..03149901a 100644
--- a/hw/mcu/stm/stm32f3xx/include/mcu/stm32_hal.h
+++ b/hw/mcu/stm/stm32f3xx/include/mcu/stm32_hal.h
@@ -83,7 +83,10 @@ struct stm32_hal_spi_cfg {
#include "stm32f3xx_hal_def.h"
#include "stm32f3xx_hal_flash.h"
#include "stm32f3xx_hal_flash_ex.h"
-#define STM32_HAL_FLASH_INIT()
+#define STM32_HAL_FLASH_INIT() \
+ do { \
+ HAL_FLASH_Unlock(); \
+ } while (0)
#define FLASH_PROGRAM_TYPE FLASH_TYPEPROGRAM_HALFWORD
#define STM32_HAL_FLASH_CLEAR_ERRORS() \
do { \
diff --git a/hw/mcu/stm/stm32f3xx/src/hal_flash.c
b/hw/mcu/stm/stm32f3xx/src/hal_flash.c
index 9cb1813d7..b4d8be293 100644
--- a/hw/mcu/stm/stm32f3xx/src/hal_flash.c
+++ b/hw/mcu/stm/stm32f3xx/src/hal_flash.c
@@ -32,11 +32,9 @@ stm32_mcu_flash_erase_sector(const struct hal_flash *dev,
uint32_t sector_addres
erase.PageAddress = sector_address;
erase.NbPages = 1;
- HAL_FLASH_Unlock();
if (HAL_OK == HAL_FLASHEx_Erase(&erase, &errorPage)) {
rc = 0;
}
- HAL_FLASH_Lock();
return rc;
}