PIO Unified Debugger

All the Espressif ESP32 boards seem to not be supported, but it should be a relatively easy thing since they use OpenOCD and their own customized GDB from a Crosstools-NG build.

Make for a win there, guys.

https://github.com/espressif/openocd-esp32

https://esp-idf.readthedocs.io/en/v2.0/openocd.html

We have just released new PIO Core+ v0.8.11 with a support for custom debugging configuration. Please run pio update command.

See

  • PlatformIO IDE for Atom, Menu: “PlatformIO > Upgrade PlatformIO Core”. Be sure that you use minimum 3.4.0b3 version
  • Open PlatformIO IDE Terminal and type
pio platform uninstall atmelsam
pio platform install atmelsam --with-package=uploader
  • Create Adafruit M0 based project, open “platformio.ini” and update its content to:
[env:adafruit_feather_m0_usb]
platform = atmelsam
board = adafruit_feather_m0_usb
framework = arduino
debug_tool = custom
debug_server =
  $PLATFORMIO_HOME_DIR/packages/tool-openocd/bin/openocd
  -f
  $PLATFORMIO_HOME_DIR/packages/tool-openocd/scripts/interface/cmsis-dap.cfg
  -c
  set CHIPNAME at91samd21g18; set ENDIAN little; set telnet_port 0
  -f
  $PLATFORMIO_HOME_DIR/packages/tool-openocd/scripts/target/at91samdXX.cfg

See details about SWCLK & SWDIO pins

Now, press “Debug” button on toolbar.

Which problems do you have? What is your board?

Could you explain problem in detail?

With blackmagic probe I’ve got some python code I currently use in .gdbinit to auto-select the correct com port so I don’t have to set it manually anywhere, I would be happy to contribute it.

Before I switched to the blackmagic I could not get my frdm-kl25z mbed board working at all with the onboard cmsis debugger. There was no console outputs from the the debugging engine being used behind the scenes to see what the progress was and the error notification that eventually popped up was very obscure - sorry I don’t remember what it was now.

I definitely appreciate the end goal of zero-configuration and having debugging that just works, but in the mean time (especially for beta releases) it’d be great if there was an option to display the openocd / gdb console(s) output when starting debugging, if for no other reason than displaying progress of the debugger connecting.
Currently I hit the debug button, it runs the compiler again (wasting a few seconds as it figures out it doesn’t need to compile anything) and then it just looks like it’s doing nothing at all while the debug engine is silently starting in the background. Eventually I’m at a debug highlight in the code, or there’s a final obscure error message in a notification popup.

Hi

I followed the steps above and get:

Error launching PIO Debugger
Error: Flushed due to previous errors

What errors ? Where did i set up to use my Ateml ICE as the debug interface?

Thanks

Please create in the root of a project file named openocd.cfg with the next content:

interface cmsis-dap
# example: cmsis_dap_vid_pid 0x1a2b 0x3c4d
cmsis_dap_vid_pid %INSERT_VID% %INSERT_PID%
# uncomment if you have more than 1 probe
# $cmsis_dap_serial %SERIAL_NUNBER%
set CHIPNAME at91samd21g18
set ENDIAN little
set telnet_port 0

and platformio.ini

[env:adafruit_feather_m0_usb]
platform = atmelsam
board = adafruit_feather_m0_usb
framework = arduino
debug_tool = custom
debug_server =
  $PLATFORMIO_HOME_DIR/packages/tool-openocd/bin/openocd
  -f
  $PROJECT_PATH/openocd.cfg
  -f
  $PLATFORMIO_HOME_DIR/packages/tool-openocd/scripts/target/at91samdXX.cfg

Where is openpcd located? I cannot find where it is installed?

I have created that file but still have the same Error launching PIO Debugger.

[env:adafruit_feather_m0_usb]
platform = atmelsam
board = adafruit_feather_m0_usb
framework = arduino
upload_port = com29
debug_tool = custom
debug_server =
$PLATFORMIO_HOME_DIR/packages/tool-openocd/bin/openocd
-f
$PLATFORMIO_HOME_DIR/packages/tool-openocd/scripts/interface/cmsis-dap.cfg
-c
set CHIPNAME at91samd21g18; set ENDIAN little; set telnet_port 0
-f
$PLATFORMIO_HOME_DIR/packages/tool-openocd/scripts/target/at91samdXX.cfg

interface cmsis-dap
# example: cmsis_dap_vid_pid 0x1a2b 0x3c4d
cmsis_dap_vid_pid 0x03EB 0x2141 
# uncomment if you have more than 1 probe
# $cmsis_dap_serial %SERIAL_NUNBER%
set CHIPNAME at91samd21g18
set ENDIAN little
set telnet_port 0

The problem is that you didn’t used new config. Please be creafully, I modified debug_server option in the comment above: -f $PROJECT_PATH/openocd.cfg

P.S: tool-openocd is located in ~/.platformio/packages folder.

I have changed this see below. Still not working.

I am using windows. I cannot seem to find the platformio location?

[env:adafruit_feather_m0_usb]
platform = atmelsam
board = adafruit_feather_m0_usb
framework = arduino
debug_tool = custom
upload_port = com30
debug_server =
  $PLATFORMIO_HOME_DIR/packages/tool-openocd/bin/openocd
  -f
  $PROJECT_PATH/openocd.cfg
  -f
  $PLATFORMIO_HOME_DIR/packages/tool-openocd/scripts/target/at91samdXX.cfg

Found the platformio folder. There is no tool-opencd in there?

Opss… I see that PIO will not install openOCD if you board is based BOSSAC. If we add “debugging” support directly to board, you will not have this issue.

Try to change in your config board = zero and press “Upload” button (also, don’t connect any boards). PIO will download OpenOCD for you.

Cool

Different error now:

Error: .pioinit:1: Error in sourced command file: Remote communication error. Target disconnected.: No error.

Please check PM here

We’ve just released new PIO Core+ v0.8.12 which improves debugging support for the MCUs that have locked flash (Freescale Kinetis, NXP LPC boards ). Could you test development version of NXP LPC?

  • pio update
  • pio platform uninstall nxplpc
  • pio platform install https://github.com/platformio/platform-nxplpc.git

Now, just use generic ARM mbed project and press “Debug” button.

Does it work?

I found following problem with mbed LPC1768:
When starting the debugger I get the message STARTING, after a while (~7s) i get the message EXITED and after another period (~13s) the debugger is in RUNNING mode. So I need to pause the debugger to set my breakpoints. But then it works.
So, after EXITING the debugger shouldn’t run immediately.

Sorry, after updating the nxplpc package it works, but a little slow. I’m using a very simple blinky with a counter and one variable watch, it need 5s per cycle. But yeah it works :grinning:

This is not a problem of PIO Core or even GDB. This issue is linked with on-board CMSIS-DAP interface. I have a few other boards based on CMSIS-DAP and they work very fast. Would be good if you contact with ARM mbed engineer and ask why this board is slow for debugging. Maybe, they will propose new bootloader/firmware.

P.S: Thanks a lot for the feedback. I’ll release NXP LPC development platform with a new mbed v5.4.5.