Skip to content

Commit 0d26c5e

Browse files
Update PSRAM cache flush algorithm (#2563)
New info from RPI engineers give a slightly better/safer method.
1 parent 5b135fa commit 0d26c5e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

cores/rp2040/flash_wrapper.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626

2727
#if defined(PICO_RP2350) && defined(RP2350_PSRAM_CS)
2828
static void __no_inline_not_in_flash_func(flushcache)() {
29-
for (volatile uint8_t* cache = (volatile uint8_t*)0x18000001; cache < (volatile uint8_t*)(0x18000001 + 2048 * 8); cache += 8) {
30-
*cache = 0;
31-
__compiler_memory_barrier();
32-
*(cache - 1) = 0;
33-
__compiler_memory_barrier();
29+
// From https://forums.raspberrypi.com/viewtopic.php?t=378249#p2263677
30+
// Perform clean-by-set/way on all lines
31+
for (uint32_t i = 0; i < 2048; ++i) {
32+
// Use the upper 16k of the maintenance space (0x1bffc000 through 0x1bffffff):
33+
*(volatile uint8_t*)(XIP_SRAM_BASE + (XIP_MAINTENANCE_BASE - XIP_BASE) + i * 8u + 0x1u) = 0;
3434
}
3535
}
3636
#elif defined(PICO_RP2350)

0 commit comments

Comments
 (0)