Skip to content

Breakpoints not working on Pi Pico/ Pi Pico 2 #5346

@MarcA711

Description

@MarcA711

Steps to reproduce

I build the rp/wifi_blinky.rs and rp235x/blinky_wifi.rs examples using cargo build --bin wifi_blinky --release . I then try to debug the program in VS Code with this launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "probe-rs-debug",
            "request": "launch",
            "name": "probe-rs Test",
            "cwd": "${workspaceFolder}",
            // "connectUnderReset": true,
            // "chip": "RP235x",
            "chip": "RP2040",
            "flashingConfig": {
                "flashingEnabled": true,
                "haltAfterReset": true
            },
            "coreConfigs": [
                {
                    "coreIndex": 0,
                    "programBinary": "./examples/rp/target/thumbv6m-none-eabi/release/wifi_blinky"
                }
            ]
        }
    ]
}

Flashing works and the debugger starts. Also, the debugger halts the execution right after the beginning. After I continue the program execution, the LED starts blinking.
Now I set a breakpoint in one of the lines within the loop using VS Code:

info!("led on!");
control.gpio_set(0, true).await;
Timer::after(delay).await;
info!("led off!");
control.gpio_set(0, false).await;
Timer::after(delay).await;

However, the execution does not halt.

When I manually set a breakpoint in the loop using cortex_m::asm::bkpt(); the code execution halts but VS Code opens the file /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/cortex-m-0.7.7/asm/inline.rs and marks the line

    asm!("bkpt", options(nomem, nostack, preserves_flags));

as being currently executed rather than the corresponding line in the wifi_blinky.rs file.

  1. When I use a STM32H743 (also connected to the picoprobe) and the corresponding blinky example, everything works as expected.
  2. When I build a binary using the Pico C/C++ SDK and flash is using probe-rs, everything works as expected as well.

That's why I think that the problem is the binary and debug info produced by Rust/ embassy-rs rather than the picoprobe or probe-rs.

What I have also tried:

  1. Switch to the nightly toolchain.
  2. Modifying the [profile.release] section of the Cargo.toml to:
[profile.release]
codegen-units = 1
debug = 2
debug-assertions = false
incremental = false
lto = 'fat'
opt-level = 3
overflow-checks = false

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions