0

I want to debug a Raspberry Pi Pico with another Raspberry Pi Pico but when I try to debug "hello_uart.elf", I receive the following output error:

Reading symbols from /usr/bin/arm-none-eabi-objdump --syms -C -h -w /home/usuario/pico/pico-examples/build/hello_world/usb/hello_usb.elf
Reading symbols from /usr/bin/arm-none-eabi-nm --defined-only -S -l -C -p /home/usuario/pico/pico-examples/build/hello_world/usb/hello_usb.elf
Launching GDB: /usr/bin/arm-none-eabi-gdb -q --interpreter=mi2 /home/usuario/pico/pico-examples/build/hello_world/usb/hello_usb.elf
    Set "showDevDebugOutput": true in your "launch.json" to see verbose GDB transactions here. Helpful to debug issues or report problems
Launching gdb-server: openocd -c "gdb_port 50000" -c "tcl_port 50001" -c "telnet_port 50002" -s ~/pico/openocd/tcl -f /home/usuario/.vscode/extensions/marus25.cortex-debug-1.4.4/support/openocd-helpers.tcl -f interface/picoprobe.cfg -f target/rp2040.cfg
    Please check TERMINAL tab (gdb-server) for output from openocd
Finished reading symbols from objdump: Time: 22 ms
Finished reading symbols from nm: Time: 32 ms
Reading symbols from /home/usuario/pico/pico-examples/build/hello_world/usb/hello_usb.elf...
OpenOCD GDB Server Quit Unexpectedly. See gdb-server output for more details.

LAUNCH.JSON:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Pico Debug",
            "cwd": "${workspaceRoot}",
            "executable": "${command:cmake.launchTargetPath}",
            "request": "launch",
            "type": "cortex-debug",
            "servertype": "openocd",
            // This may need to be arm-none-eabi-gdb depending on your system
            "gdbPath": "/usr/bin/arm-none-eabi-gdb",
            "device": "RP2040",
            "configFiles": [
                "interface/picoprobe.cfg",
                "target/rp2040.cfg"
            ],
            "svdFile": "${env:PICO_SDK_PATH}/src/rp2040/hardware_regs/rp2040.svd",
            "runToEntryPoint": "main",
            // Work around for stopping at main on restart
            "postRestartCommands": [
                "break main",
                "continue"
            ],
            "searchDir": ["~/pico/openocd/tcl"],
        }
    ]
}

SETTINGS.JSON:

{
    // These settings tweaks to the cmake plugin will ensure
    // that you debug using cortex-debug instead of trying to launch
    // a Pico binary on the host
    "cmake.statusbar.advanced": {
        "debug": {
            "visibility": "hidden"
        },
        "launch": {
            "visibility": "hidden"
        },
        "build": {
            "visibility": "hidden"
        },
        "buildTarget": {
            "visibility": "hidden"
        }
    },
    "cmake.buildBeforeRun": true,
    "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
}

I have seen many posts but I still don't find which one is the one I need. Also, could it be possible that if I take out some blank-spaces from the end of the launch.json and/or the settings.json it can give me an error too?

  • Also, I want to say that I am running this on Linux Ubuntu 20.04 and following the instructions on Getting Started as I am trying to debug a Raspberry Pi Pico with another Raspberry Pi Pico – Blanca Tonda Pedraja Jun 14 '22 at 19:00

1 Answers1

2

I had a similar problem with Debian 11 and Visual Studio Code as development machine.

This thread https://github.com/raspberrypi/pico-feedback/issues/203 gives an answer.

This worked for me:

  • Open the folder /etc/udev/rules.d in a terminal.
  • Download the openocd rules with
    sudo wget 
    https://raw.githubusercontent.com/raspberrypi/openocd/rp2040/contrib/60-openocd.rules
    
    Ensure that the file 60-openocd.rules is now in /etc/udev/rules.d.
  • Add group plugdev to your user with
    sudo usermod -a -G plugdev
    
  • Restart linux.

My setup:

  • Debian 11
  • executed pico_setup.sh with manual installation of visual studio code extensions
  • Rebuild OpenOCD with Picoprobe enabled, similar to Getting started with Raspberry Pi Pico, Appendix A with
    cd ~/pico
    sudo apt install automake autoconf build-essential texinfo libtool libftdi-dev libusb-1.0-0-dev
    cd openocd
    ./bootstrap
    ./configure --enable-picoprobe ①
    make -j4
    sudo make install
    
  • Installed binutils-multiarch, idea from https://forums.raspberrypi.com/viewtopic.php?t=333146 with
    sudo apt update
    sudo apt install binutils-multiarch
    cd /usr/bin
    ln -s /usr/bin/objdump objdump-multiarch
    ln -s /usr/bin/nm nm-multiarch
    
  • .vscode files:

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "showDevDebugOutput": "both",
            "name": "Pico Debug",
            "cwd": "${workspaceRoot}",
            "executable": "${command:cmake.launchTargetPath}",
            "request": "launch",
            "type": "cortex-debug",
            "servertype": "openocd",
            // This may need to be arm-none-eabi-gdb depending on your system
            "gdbPath" : "gdb-multiarch",
            //"gdbPath" : "arm-none-eabi-gdb",
            "device": "RP2040",
            "configFiles": [
                "interface/picoprobe.cfg",
                "target/rp2040.cfg"
            ],
            "svdFile": "${env:PICO_SDK_PATH}/src/rp2040/hardware_regs/rp2040.svd",
            "runToMain": true,
            // Work around for stopping at main on restart
            "postRestartCommands": [
                "break main",
                "continue"
            ]
        }
    ]
}

setting.json

{
    // These settings tweaks to the cmake plugin will ensure
    // that you debug using cortex-debug instead of trying to launch
    // a Pico binary on the host
    "cmake.statusbar.advanced": {
        "debug": {
            "visibility": "hidden"
        },
        "launch": {
            "visibility": "hidden"
        },
        "build": {
            "visibility": "hidden"
        },
        "buildTarget": {
            "visibility": "hidden"
        }
    },
    "cmake.buildBeforeRun": true,
    "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"
}
  • You do not need to restart. Doing `sudo systemctl reload udev && sudo udevadm trigger` will reset the device permissions. If you weren’t previously in the *plugdev* group you’ll have to log out and back in or use `sg` though (which is awkward to use). – ntninja Jul 25 '22 at 19:32