Skip to content

Commit 0d8b0ce

Browse files
MichaelBellGadgetoid
authored andcommitted
ports/rp2: Better fix to cache cleaning.
Signed-off-by: Mike Bell <[email protected]>
1 parent 7ee2fe5 commit 0d8b0ce

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

ports/rp2/rp2_flash.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,12 @@ static uint32_t begin_critical_flash_section(void) {
149149

150150
#if defined(MICROPY_HW_PSRAM_CS_PIN) && MICROPY_HW_ENABLE_PSRAM
151151
// We're about to invalidate the XIP cache, clean it first to commit any dirty writes to PSRAM
152-
uint8_t *maintenance_ptr = (uint8_t *)XIP_MAINTENANCE_BASE;
152+
// Use the upper 16k of the maintenance space (0x1bffc000 through 0x1bffffff) to workaround
153+
// incorrect behaviour of the XIP clean operation, where it also alters the tag of the associated
154+
// cache line: https://forums.raspberrypi.com/viewtopic.php?t=378249#p2263677
155+
volatile uint8_t *maintenance_ptr = (volatile uint8_t *)(XIP_SRAM_BASE + (XIP_MAINTENANCE_BASE - XIP_BASE));
153156
for (int i = 1; i < 16 * 1024; i += 8) {
154157
maintenance_ptr[i] = 0;
155-
156-
// Must also invalidate the cache lines to prevent rare hangs
157-
// See: https://forums.raspberrypi.com/viewtopic.php?t=378249)
158-
maintenance_ptr[i - 1] = 0;
159158
}
160159
#endif
161160

0 commit comments

Comments
 (0)