knurling-rs / probe-run

Run embedded programs just like native ones
Apache License 2.0
645 stars 75 forks source link

Can't find room for painting the stack when stack isn't in RAM region #323

Open jonathanpallant opened 2 years ago

jonathanpallant commented 2 years ago

Describe the bug

I fell over a bug in the stack painting stuff working on Neotron. I don't think probe-run can cope when the stack isn't in the RAM region. In my case I have a RAM region for .data/.bss, and two separate stacks, in regions called CORE0_STACK and CORE1_STACK. It tries to fit the painting code into RAM and gets sad when it doesn't fit, when CORE0_STACK is right there empty.

It's annoying because the failure mode isn't "I didn't paint your stack", it's "I exited and refused to take your chip out of reset".

To Reproduce Steps to reproduce the behavior:

Make a project where stack isn't in the RAM region, but is in another region (like STACK). Set __stack_start = ORIGIN(STACK) + LEN(STACK) so cortex-m-rt does the right thing.

Expected and observed behavior

I expected probe-run to flash my chip and start my code.

What it actually says it that it couldn't find the space for the painting code, and exited.

config.toml

See https://github.com/Neotron-Compute/Neotron-Pico-BIOS/tree/12f735402400b421d4e0fb3a3bd717b34fe84a40, but you'll want to make the RAM region smaller to trigger the bug (it has a bunch of padding in it currently).

Probe details

It's an RP2040 with the DapperMime firmware.

Operating System:

Arch Linux.

ELF file (attachment)

Can attach later, or you can build it from above repo.

Additional context

N/A

Urhengulas commented 1 year ago

https://github.com/knurling-rs/probe-run/issues/39 is related, as it is also concerned with multiple ram regions.