Skip to content

Commit 644ebe5

Browse files
danieldegrassecfriedt
authored andcommitted
drivers: mcux_flexspi: Default logging to disabled when XIP is used
Program flow will behave incorrectly (memory and instruction fetches return invalid data) if Flexspi is accessed by the Flexspi driver while being used as XIP memory by the Cortex M7. Set logging to disabled by when XIP mode is used in the memc and flexspi drivers, and warn the user if they attempt to enable it. Fixes #40133 Signed-off-by: Daniel DeGrasse <[email protected]>
1 parent d80eaa3 commit 644ebe5

File tree

5 files changed

+60
-1
lines changed

5 files changed

+60
-1
lines changed

drivers/flash/flash_mcux_flexspi_mx25um51345g.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@
2323
static uint8_t nor_write_buf[SPI_NOR_PAGE_SIZE];
2424
#endif
2525

26+
/*
27+
* NOTE: If CONFIG_FLASH_MCUX_FLEXSPI_XIP is selected, Any external functions
28+
* called while interacting with the flexspi MUST be relocated to SRAM or ITCM
29+
* at runtime, so that the chip does not access the flexspi to read program
30+
* instructions while it is being written to
31+
*/
32+
#if defined(CONFIG_FLASH_MCUX_FLEXSPI_XIP) && (CONFIG_FLASH_LOG_LEVEL > 0)
33+
#warning "Enabling flash driver logging and XIP mode simultaneously can cause \
34+
read-while-write hazards. This configuration is not recommended."
35+
#endif
36+
2637
LOG_MODULE_REGISTER(flash_flexspi_nor, CONFIG_FLASH_LOG_LEVEL);
2738

2839
enum {

drivers/flash/flash_mcux_flexspi_nor.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@
2323
static uint8_t nor_write_buf[SPI_NOR_PAGE_SIZE];
2424
#endif
2525

26+
/*
27+
* NOTE: If CONFIG_FLASH_MCUX_FLEXSPI_XIP is selected, Any external functions
28+
* called while interacting with the flexspi MUST be relocated to SRAM or ITCM
29+
* at runtime, so that the chip does not access the flexspi to read program
30+
* instructions while it is being written to
31+
*/
32+
#if defined(CONFIG_FLASH_MCUX_FLEXSPI_XIP) && (CONFIG_FLASH_LOG_LEVEL > 0)
33+
#warning "Enabling flash driver logging and XIP mode simultaneously can cause \
34+
read-while-write hazards. This configuration is not recommended."
35+
#endif
36+
2637
LOG_MODULE_REGISTER(flash_flexspi_nor, CONFIG_FLASH_LOG_LEVEL);
2738

2839
enum {

drivers/memc/memc_mcux_flexspi.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@
1111

1212
#include "memc_mcux_flexspi.h"
1313

14+
15+
/*
16+
* NOTE: If CONFIG_FLASH_MCUX_FLEXSPI_XIP is selected, Any external functions
17+
* called while interacting with the flexspi MUST be relocated to SRAM or ITCM
18+
* at runtime, so that the chip does not access the flexspi to read program
19+
* instructions while it is being written to
20+
*/
21+
#if defined(CONFIG_FLASH_MCUX_FLEXSPI_XIP) && (CONFIG_MEMC_LOG_LEVEL > 0)
22+
#warning "Enabling memc driver logging and XIP mode simultaneously can cause \
23+
read-while-write hazards. This configuration is not recommended."
24+
#endif
25+
1426
LOG_MODULE_REGISTER(memc_flexspi, CONFIG_MEMC_LOG_LEVEL);
1527

1628
struct memc_flexspi_config {

drivers/memc/memc_mcux_flexspi_hyperram.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,19 @@
1111

1212
#include "memc_mcux_flexspi.h"
1313

14-
LOG_MODULE_DECLARE(memc_flexspi, CONFIG_MEMC_LOG_LEVEL);
14+
15+
/*
16+
* NOTE: If CONFIG_FLASH_MCUX_FLEXSPI_XIP is selected, Any external functions
17+
* called while interacting with the flexspi MUST be relocated to SRAM or ITCM
18+
* at runtime, so that the chip does not access the flexspi to read program
19+
* instructions while it is being written to
20+
*/
21+
#if defined(CONFIG_FLASH_MCUX_FLEXSPI_XIP) && (CONFIG_MEMC_LOG_LEVEL > 0)
22+
#warning "Enabling memc driver logging and XIP mode simultaneously can cause \
23+
read-while-write hazards. This configuration is not recommended."
24+
#endif
25+
26+
LOG_MODULE_REGISTER(memc_flexspi, CONFIG_MEMC_LOG_LEVEL);
1527

1628
enum {
1729
READ_DATA,

soc/arm/nxp_imx/rt/Kconfig.defconfig.series

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,19 @@ config UART_MCUX_LPUART
5252
default y if HAS_MCUX_LPUART
5353
depends on SERIAL
5454

55+
if FLASH_MCUX_FLEXSPI_XIP
56+
57+
# Avoid RWW hazards by defaulting logging to disabled
58+
choice FLASH_LOG_LEVEL_CHOICE
59+
default FLASH_LOG_LEVEL_OFF
60+
endchoice
61+
62+
choice MEMC_LOG_LEVEL_CHOICE
63+
default MEMC_LOG_LEVEL_OFF
64+
endchoice
65+
66+
endif
67+
5568
if COUNTER
5669

5770
config COUNTER_MCUX_GPT

0 commit comments

Comments
 (0)