Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions cores/rp2040/RP2040Support.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ extern RP2040 rp2040;
extern void main1();
extern "C" char __StackLimit;
extern "C" char __bss_end__;
extern "C" uint32_t __scratch_x_start__;
extern "C" uint32_t __scratch_y_start__;
extern "C" void setup1() __attribute__((weak));
extern "C" void loop1() __attribute__((weak));
extern "C" bool core1_separate_stack;
Expand Down Expand Up @@ -477,12 +479,12 @@ class RP2040 {
*/
inline int getFreeStack() {
const unsigned int sp = getStackPointer();
uint32_t ref = 0x20040000;
uint32_t ref = (uint32_t)&__scratch_x_start__;
if (setup1 || loop1) {
if (core1_separate_stack) {
ref = cpuid() ? (unsigned int)core1_separate_stack_address : 0x20040000;
ref = (uint32_t)(cpuid() ? core1_separate_stack_address : &__scratch_x_start__);
} else {
ref = cpuid() ? 0x20040000 : 0x20041000;
ref = (uint32_t)(cpuid() ? &__scratch_x_start__ : &__scratch_y_start__);
}
}
return sp - ref;
Expand Down