Skip to content

Commit b0b6c46

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 b0b6c46

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-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)() {

lib/rp2350/platform_inc.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
-iwithprefixbefore/pico-sdk/src/rp2350/hardware_regs/include
44
-iwithprefixbefore/pico-sdk/src/rp2350/hardware_structs/include
55
-iwithprefixbefore/pico-sdk/src/rp2350/pico_platform/include
6+
-iwithprefixbefore/pico-sdk/src/rp2_common/hardware_rcp/include
67
-iwithprefixbefore/pico-sdk/src/rp2_common/cmsis/stub/CMSIS/Device/RP2350/Include
78
-iwithprefixbefore/pico-sdk/src/rp2_common/hardware_sha256/include
89
-iwithprefixbefore/pico-sdk/src/rp2_common/pico_sha256/include

0 commit comments

Comments
 (0)