I have simple test project:
platformio.ini:
[env:pico]
platform = raspberrypi
board = pico
framework = arduino
upload_protocol = jlink
debug_tool = jlink
debug_build_flags = -O0 -ggdb3 -g3
main.cpp:
void setup()
{
Serial.begin(115200);
}
void loop()
{
Serial.write(“hello!\n”);
delay(1000);
}
It works when I do “Upload and Monitor”, but when I start debug session it is connecting to the target correctly, but firmware doesn’t run correctly. It hits my breakpoint, but when stepping forward or continuing execution it hits nonexistent breakpoint on internal main.cpp file of arduino framework (which should be executed prior to my code - does the pico reboots?) and I lose control over debugging. Here is debug console output - debug_console - Pastebin.com
Any ideas?
Seems like an ancient issue.
opened 09:16PM - 06 Feb 22 UTC
help wanted
I can fine upload and run it blink.cpp and others
Debug starts and breaks at … setup
Call Stack "dump"
setup @ 0x10000902 (c:\Users\hs\Documents\PlatformIO\Projects\RP2040_1\src\main.cpp: 6)
@ 0x60582020 (Unknown Source: 0)
Data from DEBUG CONSOLE
```
Temporary breakpoint 1, setup () at src \ main.cpp: 66
pinMode (LED_BUILTIN, OUTPUT);
Reading 64 bytes @ address 0x20041F00
WARNING: Failed to read memory @ address 0x60582020
WARNING: Failed to read memory @ address 0x60582020
```
If I put BreakPoint in the loop it stops Sometimes once) I almost never, if i make a manual break after a while
```
-> Reading 64 bytes @ address 0x10000900 Read 2 bytes @ address 0x10000920 (Data = 0x2100)
Call Stack "dump"
@ 0x00000030 (Unknown Source: 0)
<signal handler called> @ 0xfffffff9 (Unknown Source: 0)
@ @ 0x1400000c (Unknown Source: 0)
?? @ 0xfffffffe (Unknown Source: 0)
```
DEBUG CONSOLE after Break manual pause
```
Program
received signal SIGTRAP, Trace / breakpoint trap.
Removing breakpoint @ address 0x10000920, Size = 2
Removing breakpoint @ address 0x10000920, Size = 2
Read 4 bytes @ address 0x00000030 (Data = 0xE7FDBF30)
Read 2 bytes @ address 0x00000030 (Data = 0xBF30) 0x00000030 in ?? ()
Read 4 bytes @ address 0x20041EFC (Data = 0xB1000000)
Reading 64 bytes @ address 0x20041EC0
Read 4 bytes @ address 0x1400000C (Data = 0xFFFFFFFF)
Read 2 bytes @ address 0x1400000C (Data = 0xFFFF)
WARNING: Failed to read memory @ address 0xFFFFFFFE
WARNING: Failed to read memory @ address 0xFFFFFFFE
```
Debugger Segger J-LINK EDU
platformio.ini
```ini
[env: pico]
platform = raspberrypi
board = pico
framework = arduino
build_type = debug
upload_protocol = jlink
debug_tool = jlink
debug_init_break = tbreak setup
```
test code
```cpp
#include <Arduino.h>
// the setup function runs once when you press reset or power the board
void setup () {
// initialize digital pin LED_BUILTIN as an output.
pinMode (LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop () {
digitalWrite (LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay (1000); // wait for a second
digitalWrite (LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay (1000); // wait for a second
}
```
Please see
https://community.platformio.org/t/debug-pico-rp2040-some-who-have-success-with-it/25865/2
KR Henrik
Maybe try the workaround with this
opened 06:19PM - 06 May 21 UTC
closed 02:08AM - 07 Jul 21 UTC
Currently, PlatformIO only seems to support `cmsis-dap and raspberry-swd` debug … options. `jlink` and `stlink` do not appear to be supported.
`SEGGER` have updated their J-Link probe firmware to support Pico uploads (flash to QSPI) and debugging, see https://www.segger.com/products/debug-probes/j-link/ for `Release Notes`.
I've been able to debug a Pico using a combination of `VSCODE + cmake + Picoprobe` and the `PlatformIO Debugger`. In addition, a Pico `elf` can be debugged using a `SEGGER Educ Mini probe & Ozone Debugger` combination.
I'm not sure what changes are required in PlatformIO Debugger to work but the Raspberry Pico probe needed `OpenOCD` to be built with the Picoprobe driver, as detailed in the Raspberry Pi documentation at https://datasheets.raspberrypi.org/pico/getting-started-with-pico.pdf.
It would be highly productive if we can have an out-of-the-box `jlink` (and `stlink`) support for `RP2040 Pico` upload & debug.
I'm available to assist with any testing required to support this feature request.
Your efforts to provide a complete PlatformIO support for the RP2040 are much appreciated by all of us in the `PlatformIO` and `Raspberry Pi` communities. Thanks you.
Thanks! Workaround in second github issue works - basically after starting the debug I need to hit restart arrow. After that debugging works.