pico-sdk icon indicating copy to clipboard operation
pico-sdk copied to clipboard

multicore_launch_core1 cause debugging to melfunction on RP2040

Open AlexanderHD27 opened this issue 9 months ago • 0 comments

TLDR Breakpoints, in code run on core 1, are ignored after resetting via multicore_reset_core1()

Hi, I'm trying to debug some function on core1. But when I set a breakpoint and start debugging, nothing happens. Only when I pause the execution and then resume it, the breakpoint gets hit.

Details

I have notices this only occurs when I call the multicore_reset_core1(). When I leave this multicore_reset_core1() out and just run multicore_launch_core1(core1_entry); everything works just fine. Also, when this issue occurs, gdb throws this error:

Error: Failed to select multidrop rp2040.dap1
Polling target rp2040.core1 failed, trying to reexamine

This happens when starting to flashing or debugging. This Error goes away when I leave out the multicore_reset_core1()-call.

Thank you in advance. This issue is plaguing me for a good month. I first stubbled on this while using FreeRTOS, but it turned out this is a native sdk/debugger -issue and NOT a problem of FreeRTOS.

Minimal working Example

My setup/Versions:

  • PicoSDK Version: 2.1.0
  • Board: pico_w (also tested on pico)
  • MCU: RP2040
  • Toolchain: 13.3 Rel1
  • OpenOCD: 0.12.0+dev-gebec950-dirty (2024-09-27-16:25)
  • Vscode Version: 1.96.2
  • Vscode Raspberry Pi Pico Version: 0.17.3
  • Host OS: Ubuntu 24.04.1 LTS
  • Debugger: PicoProbe https://www.raspberrypi.com/products/debug-probe/
    • Firmware Version: Debugprobe release v2.2.1

I'm using the VSCode-Plugin to set up the Project.

To reproduce, set a breakpoint at printf("Core 1\n"); and hit F5 to Debug and hit continue. Nothing will happen. Open up a serial-monitor: Both Cores are printing something to serial monitor.

Then comment out multicore_reset_core1();, recompile, Reflash. Debug again and now the breakpoint gets hit.

issue-multicore-debug.cpp:

#include <stdio.h>
#include "pico/stdlib.h"
#include "pico/multicore.h"

void core1_entry() {
    while (true) {
        printf("Core 1\n");
        sleep_ms(250);
    }
}

int main()
{
    stdio_init_all();

    multicore_reset_core1();
    multicore_launch_core1(core1_entry);
    
    while (true) {
        printf("Hello AAA, world!\n");
        sleep_ms(1000);
    }
}

Here is the entire Project Directory for reproduction: issue-multicore-debug.zip

Thank you in advance for helping!

AlexanderHD27 avatar Feb 09 '25 02:02 AlexanderHD27