@@ -1143,7 +1143,6 @@ static int stm32_ospi_abort(const struct device *dev)
1143
1143
* to erase the complete chip (using dedicated command) :
1144
1144
* set size >= flash size
1145
1145
* set addr = 0
1146
- * NOTE: cannot erase in MemoryMapped mode
1147
1146
*/
1148
1147
static int flash_stm32_ospi_erase (const struct device * dev , off_t addr ,
1149
1148
size_t size )
@@ -1176,6 +1175,13 @@ static int flash_stm32_ospi_erase(const struct device *dev, off_t addr,
1176
1175
ospi_lock_thread (dev );
1177
1176
1178
1177
#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 */
1179
1185
if (stm32_ospi_is_memorymap (dev )) {
1180
1186
/* Abort ongoing transfer to force CS high/BUSY deasserted */
1181
1187
ret = stm32_ospi_abort (dev );
@@ -1423,7 +1429,6 @@ static int flash_stm32_ospi_read(const struct device *dev, off_t addr,
1423
1429
1424
1430
/*
1425
1431
* Function to write the flash (page program) : with possible OSPI/SPI and STR/DTR
1426
- * NOTE: writing in MemoryMapped mode is not guaranted
1427
1432
*/
1428
1433
static int flash_stm32_ospi_write (const struct device * dev , off_t addr ,
1429
1434
const void * data , size_t size )
@@ -1447,6 +1452,16 @@ static int flash_stm32_ospi_write(const struct device *dev, off_t addr,
1447
1452
ospi_lock_thread (dev );
1448
1453
1449
1454
#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 */
1450
1465
if (stm32_ospi_is_memorymap (dev )) {
1451
1466
/* Abort ongoing transfer to force CS high/BUSY deasserted */
1452
1467
ret = stm32_ospi_abort (dev );
0 commit comments