From e3e6040101e1ccdaacc81bb5993cd9e30f2ef884 Mon Sep 17 00:00:00 2001 From: Matthias Blankertz Date: Wed, 20 Aug 2025 19:56:13 +0200 Subject: [PATCH] rp2: Increase micropython stack allocation We were running out of stack for micropython, and the core1 code doesn't need 4k. So shift the allocation so that micropython has 6k and core1 has 2k. Adjust the linker script since it didn't support splitting SCRATCH_X between the two stacks. Signed-off-by: Matthias Blankertz --- ports/rp2/CMakeLists.txt | 4 ++-- ports/rp2/memmap_mp_rp2040.ld | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ports/rp2/CMakeLists.txt b/ports/rp2/CMakeLists.txt index ee4777b23..ed7202fb5 100644 --- a/ports/rp2/CMakeLists.txt +++ b/ports/rp2/CMakeLists.txt @@ -587,8 +587,8 @@ target_compile_definitions(${MICROPY_TARGET} PRIVATE LFS1_NO_MALLOC LFS1_NO_DEBUG LFS1_NO_WARN LFS1_NO_ERROR LFS1_NO_ASSERT LFS2_NO_MALLOC LFS2_NO_DEBUG LFS2_NO_WARN LFS2_NO_ERROR LFS2_NO_ASSERT PICO_FLOAT_PROPAGATE_NANS=1 - PICO_STACK_SIZE=0x1000 - PICO_CORE1_STACK_SIZE=0x1000 + PICO_STACK_SIZE=0x1800 + PICO_CORE1_STACK_SIZE=0x800 PICO_MAX_SHARED_IRQ_HANDLERS=8 # we need more than the default PICO_PROGRAM_NAME="MicroPython" PICO_NO_PROGRAM_VERSION_STRING=1 # do it ourselves in main.c diff --git a/ports/rp2/memmap_mp_rp2040.ld b/ports/rp2/memmap_mp_rp2040.ld index a53573839..ffd4824e6 100644 --- a/ports/rp2/memmap_mp_rp2040.ld +++ b/ports/rp2/memmap_mp_rp2040.ld @@ -250,7 +250,7 @@ SECTIONS __GcHeapEnd = ORIGIN(RAM) + LENGTH(RAM); /* Define memory for the C stack */ - __StackOneTop = ORIGIN(SCRATCH_X) + LENGTH(SCRATCH_X); + __StackOneTop = ORIGIN(SCRATCH_X) + SIZEOF(.stack1_dummy); __StackTop = ORIGIN(SCRATCH_Y) + LENGTH(SCRATCH_Y); __StackOneBottom = __StackOneTop - SIZEOF(.stack1_dummy); __StackBottom = __StackTop - SIZEOF(.stack_dummy);