Skip to content

Commit ba43958

Browse files
Gadgetoidgigapod
andcommitted
ports/rp2: Configure heap for PSRAM.
PSRAM will be used exclusively if MICROPY_GC_SPLIT_HEAP == 0, it will be added to RAM if MICROPY_GC_SPLIT_HEAP == 1, and the system will fall back to RAM only if it's not detected. Due to the size of PSRAM, GC stack was overflowing and causing the GC to scan through the entire memory pool. This caused noticable slowdowns during GC. Increase the stack from 256 to 4096 bytes to avoid overflow and increase the stack entry type size to accomodate 8MB+ PSRAM. Changes: ports/rp2/mpconfigport.h: Make split-heap optional and enable by default. Increase GC stack entry type to uint32_t. Raise GC stack size. Co-authored-by: Kirk Benell <[email protected]> Signed-off-by: Phil Howard <[email protected]>
1 parent 46dcc6f commit ba43958

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

ports/rp2/mpconfigport.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,15 @@
8686
#endif
8787

8888
// Memory allocation policies
89+
#if MICROPY_HW_ENABLE_PSRAM
90+
#define MICROPY_GC_STACK_ENTRY_TYPE uint32_t
91+
#define MICROPY_ALLOC_GC_STACK_SIZE (1024) // Avoid slowdown when GC stack overflow causes a full sweep of PSRAM-backed heap
92+
#else
8993
#define MICROPY_GC_STACK_ENTRY_TYPE uint16_t
94+
#endif
95+
#ifndef MICROPY_GC_SPLIT_HEAP
96+
#define MICROPY_GC_SPLIT_HEAP MICROPY_HW_ENABLE_PSRAM // whether PSRAM is added to or replaces the heap
97+
#endif
9098
#define MICROPY_ALLOC_PATH_MAX (128)
9199
#define MICROPY_QSTR_BYTES_IN_HASH (1)
92100

0 commit comments

Comments
 (0)