8000 ports/rp2: Make split-heap optional. · micropython/micropython@443003d · GitHub
[go: up one dir, main page]

Skip to content

Commit 443003d

Browse files
committed
ports/rp2: Make split-heap optional.
My tests found issues when PSRAM is combined with the existing RAM in a split-heap configuration. Since this option is not enabled by default on RP2 I have changed it to be optional. 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. Signed-off-by: Phil Howard <github@gadgetoid.com>
1 parent 27cdecc commit 443003d

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

ports/rp2/main.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,17 @@ int main(int argc, char **argv) {
117117
mp_stack_set_top(&__StackTop);
118118
mp_stack_set_limit(&__StackTop - &__StackBottom - 256);
119119

120-
gc_init(&__GcHeapStart, &__GcHeapEnd);
121120
#if defined(MICROPY_HW_PSRAM_CS_PIN) && MICROPY_HW_ENABLE_PSRAM
122121
size_t psram_size = psram_init(MICROPY_HW_PSRAM_CS_PIN);
123122
if (psram_size) {
123+
#if MICROPY_GC_SPLIT_HEAP
124+
gc_init(&__GcHeapStart, &__GcHeapEnd);
124125
gc_add((void *)PSRAM_LOCATION, (void *)(PSRAM_LOCATION + psram_size));
126+
#else
127+
gc_init((void *)PSRAM_LOCATION, (void *)(PSRAM_LOCATION + psram_size));
128+
#endif
129+
} else {
130+
gc_init(&__GcHeapStart, &__GcHeapEnd);
125131
}
126132
#endif
127133

ports/rp2/mpconfigport.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@
7373

7474
// Memory allocation policies
7575
#define MICROPY_GC_STACK_ENTRY_TYPE uint16_t
76-
#ifdef MICROPY_HW_ENABLE_PSRAM
77-
#define MICROPY_GC_SPLIT_HEAP (1)
76+
#ifndef MICROPY_GC_SPLIT_HEAP
77+
#define MICROPY_GC_SPLIT_HEAP (0) // whether PSRAM is added to or replaces the heap
7878
#endif
7979
#define MICROPY_ALLOC_PATH_MAX (128)
8080
#define MICROPY_QSTR_BYTES_IN_HASH (1)

0 commit comments

Comments
 (0)
0