Hello everyone,
I’m seeing a strange debugger-dependent hang on the Raspberry Pi Pico (RP2040) with the embedded runtime.
Observed behaviour
- Works perfectly when:
- Loaded via simple
cpand hardware reset, or - Debugged and I press the hardware reset button after the initial breakpoint.
- Loaded via simple
- Hangs inside
adainit(tasking initialisation) when launched directly via cortex-debug + OpenOCD without a hardware reset.
Call stack at the hang (core0):
fault@0x100049f8
<signal handler called>
system.bb.threads.queues.change_priority
system.bb.interrupts.interrupt_wrapper
system.tasking.environment_task
Core1 sits at a low bootrom address.
Minimal trigger
Adding this single line is enough to trigger the problem (even though it produces a “unit not referenced” warning and is never executed):
with Ada.Exceptions;
Commenting it out (and the whole exception handler block) makes the sketch run reliably under the debugger.
Runtime & target details
- Using
embedded_rp2040 = "^15.3"(Alire) - The same code with
embedded_rp2350 = "^15.3"works fine. - Only the embedded profile is affected because it provides proper exception handling.
What I tried
- Many OpenOCD reset sequences (
reset halt, core0/core1arp_resetin different orders,preLaunchCommands,postRestartCommands). - Removing
runToEntryPoint, breakpoints, etc.
The clean repro is the simple doorbell example (Chapter 7.1) from my tutorial:
Repository branch:
Question
Has anyone else seen the embedded RP2040 runtime’s tasking initialisation fail when Ada.Exceptions is in the closure? Could this be related to how exception handlers or the environment task are registered under the debugger?
I’m happy to supply more logs, try patches, or create a minimal Alire project. Any pointers to the relevant parts of the BB runtime would be very welcome!
Thanks,
Martin