How to use NXP MCU-Link as debug tool with LPC1769 target?

The MCU-Link by NXP is a low-cost SWD probe that supports the CMSIS-DAP protocol and interfaces to most NXP LPC chips.
How could I set up platformio to use it as a custom debug tool?

I tried setting

debug_tool = cmsis-dap
upload_protocol=cmsis-dap

, but that didn’t work, nothing gets uploaded and debugging doesn’t work.

The target application board isn’t one on the available list of boards in platformio.
It’s an MKS-SGEN 3D printer controller with LPC1769 and an SWD connector.
The code is Marlin firmware with framework=arduino and platform=arduino-lpc176x
and it builds just fine, I just can’t upload and debug with the MCU-Link.

Side note: I was able to do a custom debug setup using an STLink probe, by setting the debug_server to call openocd with a customized board.cfg. This worked, but I picked up one of these MCU-Links and would like to use that instead,

I assume at minimum a custom board.cfg needs to be created?

Could someone describe what other steps need to be taken to get this working?

If that’s true then check if openocd can manually use thast interface and conncect to the chip. Does something like openocd -f interface/cmsis-dap.cfg -f target/lpc17xx.cfg work with the Openocd version found in C:\Users\<user>\.platformio\packages\tool-openocd\bin?

1 Like

Thanks Max, this actually worked! It uploaded and started the debugger.

Now I just have to track some issues with the debugging, cause I keep getting errors like these:

I can set and break at a breakpoint and single step a few times, but “step into” fails and
there are numerous and random errors following that:

“could not read memory at 0xffff0000”
“target was not halted when step was issued”
and
“received SIGINT 0x00000000 isr.vector{}”

When I hit restart or run again, it always breaks on a USART TX routine even though I set no breakpoints! It’s stuck there forever until I close the session and start over again.
Could the problem be that there are a lot of interrupts coming in and the debugger just can’t handle that? (I know that debugging slows things down a bit, so maybe the incoming USART data is too much in a debug environment.)