8000 stm32/qspi.c: Workaround for SR set immediately after setting AR. · micropython/micropython@b17e81e · GitHub
[go: up one dir, main page]

Skip to content

Commit b17e81e

Browse files
committed
stm32/qspi.c: Workaround for SR set immediately after setting AR.
* See issue #5441. * This issue is now reproducible with upstream Micropython on the Arduino Portenta H747, QSPI flash PN MX25L12833F.
1 parent f5cdd83 commit b17e81e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

ports/stm32/qspi.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ static inline void qspi_mpu_enable_mapped(void) {
7878
// for the memory-mapped region, so 3 MPU regions are used to disable access
7979
// to everything except the valid address space, using holes in the bottom
8080
// of the regions and nesting them.
81+
// Note: Disabling a subregion (by setting its corresponding SRD bit to 1) means another region
82+
// overlapping the disabled range matches instead. If no other enabled region overlaps the disabled
83+
// subregion, and the access is unprivileged or the background region is disabled, the MPU issues a fault.
8184
uint32_t irq_state = mpu_config_start();
8285
#if MICROPY_HW_QSPI_MPU_REGION_SIZE > 128
8386
mpu_config_region(MPU_REGION_QSPI1, QSPI_MAP_ADDR, MPU_CONFIG_DISABLE(0xFF, MPU_REGION_SIZE_256MB));
@@ -350,6 +353,14 @@ STATIC void qspi_read_cmd_qaddr_qdata(void *self_in, uint8_t cmd, uint32_t addr,
350353
QUADSPI->ABR = 0; // alternate byte: disable continuous read mode
351354
QUADSPI->AR = addr; // address to read from
352355

356+
#if defined(STM32H7)
357+
// Workaround for SR getting set immediately after setting the address.
358+
if (QUADSPI->SR & 0x01) {
359+
QUADSPI->FCR |= QUADSPI_FCR_CTEF;
360+
QUADSPI->AR = addr; // address to read from
361+
}
362+
#endif
363+
353364
// Read in the data 4 bytes at a time if dest is aligned
354365
if (((uintptr_t)dest & 3) == 0) {
355366
while (len >= 4) {

0 commit comments

Comments
 (0)
0