This is an automated email from the ASF dual-hosted git repository.

kasjer 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 2a49b9b51 stm32u5: Fix flash write with cache
2a49b9b51 is described below

commit 2a49b9b51c22462fb80fe1838ad79c0f2a26bc6b
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Mon Jun 22 11:51:45 2026 +0200

    stm32u5: Fix flash write with cache
    
    It turned out that same problem that was seen on
    stm32h5 devices applies to stm32u5.
    After writeing correctly to flash, cache was not
    invalidated and subsequent read from place where
    data was just written returned incorrect data
    from cache.
    It was detected when FCB was used on flash and
    during CRC calculation written data was not
    seed as expected and CRC was never written.
    
    Signed-off-by: Jerzy Kasenberg <[email protected]>
---
 hw/mcu/stm/stm32_common/src/hal_flash.c      | 4 ++--
 hw/mcu/stm/stm32u5xx/include/mcu/stm32_hal.h | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/mcu/stm/stm32_common/src/hal_flash.c 
b/hw/mcu/stm/stm32_common/src/hal_flash.c
index da3191796..a41689bd8 100644
--- a/hw/mcu/stm/stm32_common/src/hal_flash.c
+++ b/hw/mcu/stm/stm32_common/src/hal_flash.c
@@ -94,7 +94,7 @@ stm32_flash_write_linear(const struct hal_flash *dev, 
uint32_t address,
     int rc = 0;
     uint8_t align;
     uint32_t num_words;
-#if defined(STM32H5)
+#if defined(STM32H5) || defined(STM32U5)
     bool icache_enabled = LL_ICACHE_IsEnabled();
 #endif
     align = dev->hf_align;
@@ -153,7 +153,7 @@ stm32_flash_write_linear(const struct hal_flash *dev, 
uint32_t address,
         }
     }
 
-#ifdef STM32H5
+#if defined(STM32H5) || defined(STM32U5)
     if (icache_enabled) {
         LL_ICACHE_Invalidate();
     }
diff --git a/hw/mcu/stm/stm32u5xx/include/mcu/stm32_hal.h 
b/hw/mcu/stm/stm32u5xx/include/mcu/stm32_hal.h
index 946f0997b..23cf80461 100644
--- a/hw/mcu/stm/stm32u5xx/include/mcu/stm32_hal.h
+++ b/hw/mcu/stm/stm32u5xx/include/mcu/stm32_hal.h
@@ -41,6 +41,7 @@ extern "C" {
 #include "stm32u5xx_hal_tim.h"
 #include "stm32u5xx_ll_bus.h"
 #include "stm32u5xx_ll_tim.h"
+#include "stm32u5xx_ll_icache.h"
 #include "stm32u5xx_hal_def.h"
 #include "stm32u5xx_hal_flash.h"
 #include "stm32u5xx_hal_flash_ex.h"

Reply via email to