Questions about how the stack is allocated when using arduino-pico with platformio #2634
Unanswered
JABCanford
asked this question in
Q&A
Replies: 1 comment 4 replies
-
This should answer some questions: arduino-pico/lib/rp2040/memmap_default.ld Lines 256 to 272 in 9cea470 How did you try to use |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've got a few questions about how arduino-pico allocates the stack. I'm working on a project using arduino-pico in platformio, with a custom board based on the Wiznet W5500-EVB, but with some extra hardware (relays, LCD, etc).
I recently had a crash inducing problem with my program which went away when I moved a 100 byte array from being a local variable to a global variable, leading me to try and find out if the stack being full was the cause of my issue.
I tried adding "bool core1_separate_stack = true;" to my program, as I am using both cores, to try and increase the stack size for core 0, as documented by https://arduino-pico.readthedocs.io/en/latest/multicore.html
/. I ran platformio's memory inspector, to see if the stack was being made bigger by adding this, ie core 0 getting all 8k of the scratch memory and core 1 getting 8k from the main SRAM. The inspector seems to show the stack for core 0 occupying the lower half of scratch_y, and the stack for core 1 occupying the lower half of scratch_x. I'm not sure if either the core1_separate_stack flag isn't working, or if platformio's inspector isn't spotting the changes that the flag is causing.
Is there any significance to the word "dummy" in the name ".stack_dummy", beyond that the compiler doesn't know how much space will be used at runtime?
Is the 2k size of ".stack_dummy" a limit, or can the stack use the whole 4k of the scratch by default (in multicore)?
Please forgive anything I'm getting wrong here, this is the first time I've written a large enough arduino-pico program to encounter issues with the stack.
When trying to solve the crashes I was previously having, I wanted to see how much was on the stack at runtime, so wanted to use the "inline int getFreeStack()" function added by a commit from pull #1816 (#1816), but I wasn't able to get this to work in my program, despite having other functions from the rp2040 class such as "idleOtherCore()" work fine. Is this function intended to be user accessible?
As suggested in https://community.platformio.org/t/a-nice-way-to-see-exact-memory-usage/32118, I added -Wl,--print-memory-usage to build_flags: in platformio.ini. This gave me extra output when building:
This also doesn't seem right, as I would have thought that scratch_y should show some usage for the stack for core 0, given that scratch_x is showing usage?
Thank you in advance for any explanations.
Beta Was this translation helpful? Give feedback.
All reactions