@@ -1035,7 +1035,7 @@ static int flash_stm32_xspi_erase(const struct device *dev, off_t addr,
1035
1035
goto erase_end ;
1036
1036
}
1037
1037
}
1038
- #endif
1038
+ #endif /* CONFIG_STM32_MEMMAP */
1039
1039
1040
1040
XSPI_RegularCmdTypeDef cmd_erase = {
1041
1041
.OperationType = HAL_XSPI_OPTYPE_COMMON_CFG ,
@@ -1173,7 +1173,7 @@ static int flash_stm32_xspi_read(const struct device *dev, off_t addr,
1173
1173
{
1174
1174
const struct flash_stm32_xspi_config * dev_cfg = dev -> config ;
1175
1175
struct flash_stm32_xspi_data * dev_data = dev -> data ;
1176
- int ret ;
1176
+ int ret = 0 ;
1177
1177
1178
1178
if (!xspi_address_is_valid (dev , addr , size )) {
1179
1179
LOG_ERR ("Error: address or size exceeds expected values: "
@@ -1186,29 +1186,31 @@ static int flash_stm32_xspi_read(const struct device *dev, off_t addr,
1186
1186
return 0 ;
1187
1187
}
1188
1188
1189
- #ifdef CONFIG_STM32_MEMMAP
1189
+ #if defined( CONFIG_STM32_MEMMAP ) || defined( CONFIG_STM32_APP_IN_EXT_FLASH )
1190
1190
ARG_UNUSED (dev_cfg );
1191
1191
ARG_UNUSED (dev_data );
1192
-
1193
- xspi_lock_thread (dev );
1192
+ /*
1193
+ * When the call is made by an app executing in external flash,
1194
+ * skip the memory-mapped mode check
1195
+ */
1196
+ #ifdef CONFIG_STM32_MEMMAP
1194
1197
1195
1198
/* Do reads through memory-mapping instead of indirect */
1196
1199
if (!stm32_xspi_is_memorymap (dev )) {
1197
1200
ret = stm32_xspi_set_memorymap (dev );
1198
1201
if (ret != 0 ) {
1199
1202
LOG_ERR ("READ: failed to set memory mapped" );
1200
- goto read_end ;
1203
+ return ret ;
1201
1204
}
1202
1205
}
1203
1206
1204
1207
__ASSERT_NO_MSG (stm32_xspi_is_memorymap (dev ));
1205
-
1208
+ #endif /* CONFIG_STM32_MEMMAP */
1206
1209
uintptr_t mmap_addr = STM32_XSPI_BASE_ADDRESS + addr ;
1207
1210
1208
1211
LOG_DBG ("Memory-mapped read from 0x%08lx, len %zu" , mmap_addr , size );
1209
1212
memcpy (data , (void * )mmap_addr , size );
1210
- ret = 0 ;
1211
- goto read_end ;
1213
+ return ret ;
1212
1214
#else
1213
1215
XSPI_RegularCmdTypeDef cmd = xspi_prepare_cmd (dev_cfg -> data_mode , dev_cfg -> data_rate );
1214
1216
@@ -1274,13 +1276,10 @@ static int flash_stm32_xspi_read(const struct device *dev, off_t addr,
1274
1276
xspi_lock_thread (dev );
1275
1277
1276
1278
ret = xspi_read_access (dev , & cmd , data , size );
1277
- goto read_end ;
1278
- #endif
1279
-
1280
- read_end :
1281
1279
xspi_unlock_thread (dev );
1282
1280
1283
1281
return ret ;
1282
+ #endif /* CONFIG_STM32_MEMMAP || CONFIG_STM32_APP_IN_EXT_FLASH */
1284
1283
}
1285
1284
1286
1285
/* Function to write the flash (page program) : with possible OCTO/SPI and STR/DTR */
0 commit comments