No, you will need a SWD debugger of some kind for this, e.g. a JLink or STLink or BMP. Without that, one would need a GDB stub running as part of the firmware to communicate with the GDB client on the PC, but no such implementation exists to my knowledge.
Thank you Max for your response.
I have ordered STLink. Is there any tutorial where I can setup STLink with PIO and SKR 1.4Turbo using Marlin? Please note that SKR 1.4 Turbo is LPC1769 based.
Sadly a few have tried as can be in read this thread, but none succeded finally.
In theory all it needs is that a SWD probe, like an ST-Link, is connected to the target microcontroller via the SWD connections (SWDIO, SWDCLK, GND), then OpenOCD should be able to establish a connection to it for flashing + debugging, at which point it is ‘just’ a matter of teaching PlatformIO to do the correct OpenOCD invocations.
I’ll read up on the thread again and prepare an example with which some things can be tried.
Thank you Max.
Yes, this thread is there but i think “teaching PlatformIO to do the correct OpenOCD invocations” is little bit murky to me.
I will be looking forward for your example. Meanwhile I am waiting for my STLINK.
I think folks from Bigtreetech or Marlin should also share how they use to debug when developing SKR 1.4Turbo
I’ve read up on the thread and decided to do some updates to the example and my forked version of the nxp platform code. For me it now looks like building works, and upload and debug is attempted with the right commandds (it uses pyocd at the moment).
Please try and clone the example GitHub - maxgerhardt/pio-nxp-lpc1769-arduino-test: Simple project for testing Arduino support on the NXP LPC1769 chip using a custom platform., then build and upload it. The project is preconfigured for the
cmsis-dap (that an ST-Link is compatible with) type upload and debugging. Let’s get a normal upload + LED blinky working first.
Sidenote: If PyOCD says that it can’t find a connected debug probe and you’re using Windows, you will need to install libusb for Python (copying of a
libusb-1.0.dll file in the Python installation directory).
Sidenote 2: The SWD pins on the board can be found per this.
Will try the example. It will take few days for the STLINK to ship. Will update once I try.
I was wondering, since the SKR 1.4T board is already talking to the PC(Windows) thru USB, there should be some way to use the USB interface directly (instead of going thru the STLINK) to activate the debugging.
For SWD connection with SKR 1.4Turbo, please confirm if I only need to connect SWDIO, GND and SWCLK pins of STLINK-V2(pin 7,8,9) with SKR 1.4Turbo only?
Never mind, i was able to figure it out.
pin 1 of STLINK to 3.3V of SKR 1.4 Turbo
pin 7 to SWDIO
pin 8 to GND
pin 9 to CLK
pin 15 to RST.
Max, I was able to get your “pio-nxp-lpc1769-arduino-test” working in debug mode.
Let me know what all modifications to make to get the debug working for Marlin FW.
Actually, creating a forked platform versions and adding cmsis-dap support via the Python code may have been overkill. The board already declares cmsis-dap debugging support via pyOCD, so the should do the same as my modified platform.
Just try and change to the Marlin envirnoment for your LPC1769 board with the switcher and press the debug button. It should start to invoke PyOCD. Does that just work?
In fresh Marlin repo from git, I added below lines in platformio.ini in [common_LPC].
debug_tool = cmsis-dap
;debug_tool = custom
openocd -f ../scripts/interface/stlink.cfg -f ../scripts/target/lpc17xx.cfg
The debug is launching but it fails to put a break point.
PlatformIO Unified Debugger → Redirecting...
PlatformIO: debug_tool = cmsis-dap
PlatformIO: Initializing remote target…
GNU MCU Eclipse 64-bit Open On-Chip Debugger 0.10.0+dev-00462-gdd1d90111 (2019-01-18-11:42)
Licensed under GNU GPL v2
For bug reports, read
Info : auto-selecting first available session transport “hla_swd”. To override use ‘transport select ’.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 10 kHz
Info : tcl server disabled
Info : telnet server disabled
Info : clock speed 10 kHz
Error: read version failed
.pioinit:13: Error in sourced command file:
Remote communication error. Target disconnected.: Success.
What happens if you do not modify it in any way and just press the debug button? It should use
I first tried with how you asked. So, I opened my Marlin project in the same Visual Studio Code(thru PIO) where “pio-nxp-lpc1769-arduino-test” was launched in debug mode. Then I switched to Marlin project and clicked debug. The breakpoint happened in “pio-nxp-lpc1769-arduino-test” instead of happening in Marlin.
I am not fully aware of how “switcher” works and could be making some mistake while I switch between projects.