Skip to content

Commit 256ac2a

Browse files
ananglcarlescufi
authored andcommitted
[nrf fromtree] drivers: flash: nrf_qspi_nor: Prevent CPU hang when XIP is re-enabled
Add a simple non-XIP transaction before deactivating the QSPI after a XIP transaction is performed. This prevents a CPU hang from occuring when another XIP transaction is attempted after the QSPI is activated again. Signed-off-by: Andrzej Głąbek <[email protected]> (cherry picked from commit fb1d078)
1 parent 2e8ea12 commit 256ac2a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/flash/nrf_qspi_nor.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,6 +1359,18 @@ void z_impl_nrf_qspi_nor_xip_enable(const struct device *dev, bool enable)
13591359
#endif
13601360
if (enable) {
13611361
(void)nrfx_qspi_activate(false);
1362+
} else {
1363+
/* It turns out that when the QSPI peripheral is deactivated
1364+
* after a XIP transaction, it cannot be later successfully
1365+
* reactivated and an attempt to perform another XIP transaction
1366+
* results in the CPU being hung; even a debug session cannot be
1367+
* started then and the SoC has to be recovered.
1368+
* As a workaround, at least until the cause of such behavior
1369+
* is fully clarified, perform a simple non-XIP transaction
1370+
* (a read of the status register) before deactivating the QSPI.
1371+
* This prevents the issue from occurring.
1372+
*/
1373+
(void)qspi_rdsr(dev, 1);
13621374
}
13631375
dev_data->xip_enabled = enable;
13641376

0 commit comments

Comments
 (0)