@@ -1143,7 +1143,6 @@ static int stm32_ospi_abort(const struct device *dev)
11431143 * to erase the complete chip (using dedicated command) :
11441144 * set size >= flash size
11451145 * set addr = 0
1146- * NOTE: cannot erase in MemoryMapped mode
11471146 */
11481147static int flash_stm32_ospi_erase (const struct device * dev , off_t addr ,
11491148 size_t size )
@@ -1176,6 +1175,13 @@ static int flash_stm32_ospi_erase(const struct device *dev, off_t addr,
11761175 ospi_lock_thread (dev );
11771176
11781177#ifdef CONFIG_STM32_MEMMAP
1178+ #ifdef CONFIG_SOC_SERIES_STM32H7X
1179+ if (stm32_ospi_is_memorymap (dev )) {
1180+ /* No erase : exit directly with ret = 0 */
1181+ LOG_INF ("MemoryMap : no explicit erase" );
1182+ goto end_erase ;
1183+ }
1184+ #endif /* CONFIG_SOC_SERIES_STM32H7X */
11791185 if (stm32_ospi_is_memorymap (dev )) {
11801186 /* Abort ongoing transfer to force CS high/BUSY deasserted */
11811187 ret = stm32_ospi_abort (dev );
@@ -1423,7 +1429,6 @@ static int flash_stm32_ospi_read(const struct device *dev, off_t addr,
14231429
14241430/*
14251431 * Function to write the flash (page program) : with possible OSPI/SPI and STR/DTR
1426- * NOTE: writing in MemoryMapped mode is not guaranted
14271432 */
14281433static int flash_stm32_ospi_write (const struct device * dev , off_t addr ,
14291434 const void * data , size_t size )
@@ -1447,6 +1452,16 @@ static int flash_stm32_ospi_write(const struct device *dev, off_t addr,
14471452 ospi_lock_thread (dev );
14481453
14491454#ifdef CONFIG_STM32_MEMMAP
1455+ #ifdef CONFIG_SOC_SERIES_STM32H7X
1456+ if (stm32_ospi_is_memorymap (dev )) {
1457+ LOG_DBG ("MemoryMapped Write offset: 0x%lx, len: %zu" ,
1458+ (long )(STM32_OSPI_BASE_ADDRESS + addr ),
1459+ size );
1460+ memcpy ((uint8_t * )STM32_OSPI_BASE_ADDRESS + addr , data , size );
1461+
1462+ return 0 ;
1463+ }
1464+ #endif /* CONFIG_SOC_SERIES_STM32H7X */
14501465 if (stm32_ospi_is_memorymap (dev )) {
14511466 /* Abort ongoing transfer to force CS high/BUSY deasserted */
14521467 ret = stm32_ospi_abort (dev );
0 commit comments