Skip to content

Commit 4ce9d14

Browse files
Invalidate after cleaning the cache line
gmx from the RPI forums came up with this hack and it seems to work! https://forums.raspberrypi.com/viewtopic.php?p=2262371#p2262371
1 parent 88868a5 commit 4ce9d14

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

cores/rp2040/flash_wrapper.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,13 @@
2525
#endif
2626

2727
#if defined(PICO_RP2350) && defined(RP2350_PSRAM_CS)
28-
static volatile uint32_t __wastedsum = 0;
2928
static void __no_inline_not_in_flash_func(flushcache)() {
30-
//for (volatile uint8_t* cache = (volatile uint8_t*)0x18000001; cache < (volatile uint8_t*)(0x18000001 + 2048 * 8); cache += 8) {
31-
// *cache = 0;
32-
//}
33-
uint32_t sum = 0; // Ignored, just to ensure not optimized out
34-
for (volatile uint32_t *flash = (volatile uint32_t *)0x11000000; flash < (volatile uint32_t *)(0x11000000 + 48 * 1024 * 4); flash++) {
35-
sum += *flash;
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();
3634
}
37-
__wastedsum += sum;
3835
}
3936
#elif defined(PICO_RP2350)
4037
static void __no_inline_not_in_flash_func(flushcache)() {

0 commit comments

Comments
 (0)