Skip to content

Commit c2118cc

Browse files
authored
allow PICO_CORE1_STACK_SIZE=0 (#2058)
1 parent 08bf6a7 commit c2118cc

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/rp2_common/pico_multicore/include/pico/multicore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extern "C" {
2929
* \include multicore.c
3030
*/
3131

32-
// PICO_CONFIG: PICO_CORE1_STACK_SIZE, Minimum amount of stack space reserved in the linker script for core 1, min=0x100, max=0x10000, default=PICO_STACK_SIZE (0x800), group=pico_multicore
32+
// PICO_CONFIG: PICO_CORE1_STACK_SIZE, Minimum amount of stack space reserved in the linker script for core 1 - if zero then no space is reserved and the user must provide their own stack, min=0, max=0x10000, default=PICO_STACK_SIZE (0x800), group=pico_multicore
3333
#ifndef PICO_CORE1_STACK_SIZE
3434
#ifdef PICO_STACK_SIZE
3535
#define PICO_CORE1_STACK_SIZE PICO_STACK_SIZE

src/rp2_common/pico_multicore/multicore.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@ bool multicore_fifo_pop_timeout_us(uint64_t timeout_us, uint32_t *out) {
6666
return true;
6767
}
6868

69+
#if PICO_CORE1_STACK_SIZE > 0
6970
// Default stack for core1 ... if multicore_launch_core1 is not included then .stack1 section will be garbage collected
7071
static uint32_t __attribute__((section(".stack1"))) core1_stack[PICO_CORE1_STACK_SIZE / sizeof(uint32_t)];
72+
#endif
7173

7274
static void __attribute__ ((naked)) core1_trampoline(void) {
7375
#ifdef __riscv
@@ -153,11 +155,15 @@ void multicore_launch_core1_with_stack(void (*entry)(void), uint32_t *stack_bott
153155
}
154156

155157
void multicore_launch_core1(void (*entry)(void)) {
158+
#if PICO_CORE1_STACK_SIZE > 0
156159
extern uint32_t __StackOneBottom;
157160
uint32_t *stack_limit = (uint32_t *) &__StackOneBottom;
158161
// hack to reference core1_stack although that pointer is wrong.... core1_stack should always be <= stack_limit, if not boom!
159162
uint32_t *stack = core1_stack <= stack_limit ? stack_limit : (uint32_t *) -1;
160163
multicore_launch_core1_with_stack(entry, stack, sizeof(core1_stack));
164+
#else
165+
panic("multicore_launch_core1() can't be used when PICO_CORE1_STACK_SIZE == 0");
166+
#endif
161167
}
162168

163169
void multicore_launch_core1_raw(void (*entry)(void), uint32_t *sp, uint32_t vector_table) {

0 commit comments

Comments
 (0)