How to flash a LPC1114 with pyocd or openocd using mcu-link probe?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How to flash a LPC1114 with pyocd or openocd using mcu-link probe?

3,883 次查看
enok
Contributor I

I've been trying for days now to use a mcu-link (not -pro) probe to flash our custom board based on an LPC1114 CPU. I want to use SWD and potentially also debug my code using e.g. gdb. But primarily I just primarily want to erase and program the flash memory.

I find it really difficult to find up-to-date info on how to connect the wires as well as how to set up a working software such as pyocd or openocd. So far I'm not even able to reset the device or erase the flash. pyocd and openocd both detect the mcu-link probe, but there is no successful communication with the device over SWD.

Where is the pinout for the 2x5 pin connector on the MCU-LINK board? Is it identical to Atmel's connectors? I have guessed so, but haven't found any documentation so I'm not sure. And what wires should be connected? GND, SWDIO and SWCLK are obvious, but do I also need to connect RESET and ISP pins, and if so, to which pin on the 2x5 connector?

I followed https://www.nxp.com/document/guide/getting-started-with-the-mcu-link:GS-MCU-LINK and after a surprisingly lengthy registration procedures for even getting access to the firmware download I managed to update the firmware. But which version of firmware should i flash the mcu-link probe with? I found that the version for windows (3.something) differs from the Linux download (V2.264). Where is the release history? I tried both, but none of them seems to work. And what is the "program-JTAG" firmware for? I tried that too and it just rendered the dongle undetectable with lsusb.

And how to make pyocd or openocd work with my CPU and board? I noticed a LPC11XX_32 target for pyocd, but I find no documentation confirming that this is right for my LPC1114? Should I perhaps download some device description "pack"? And do I need to somehow produce a custom "board" pack file myself in addition? If so: is there an instruction or example somewhere?

I'm surprised it is this hard to make the NXP probe MCU-LINK perform basic tasks on the widely spread NXP processor LPC1114. SWD seems like such a simple and standardized way to program Cortex Arms. Am I missing something obvious?

If I forget about SWD, is there any way to use the MCU-LINK probe to program the LPC1114 using ISP? Or is that not possible?

I eventually soldered a generic USB-to-UART (Adafruit MPC2221A) dongle to the LPC1114 board UART pins, flashed it to control the RESET and ISP pins using it's GPIO outputs, compiled a customized lpc21isp binary and was able to program my board with this setup. But surely there must be a way to use the MCU-LINK probe over SWD?

0 项奖励
回复
5 回复数

3,707 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @enok 

 

Recommend using MCUXpresso IDE to debug.

 

BR

Alice

0 项奖励
回复

3,842 次查看
enok
Contributor I

My best attempt with openocd so far:

 

openocd -c "adapter driver cmsis-dap" -f target/lpc11xx.cfg -c "adapter speed 1000"
Open On-Chip Debugger 0.11.0
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
cortex_m reset_config sysresetreq

adapter speed: 1000 kHz

Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: JTAG Supported
Info : CMSIS-DAP: FW Version = 1.10
Info : CMSIS-DAP: Serial# = PVDTRQO1KGVQV
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 0 TDO = 1 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 1000 kHz
Error: Error connecting DP: cannot read IDR
​

 

Hardware reset with pyocd actually seems to work:

 

pyocd reset --target=LPC11XX_32 -f 1M --method hw
echo $?
0

 

Trying to erase the flash requires SWD communication, which fails:

 

pyocd erase --target=LPC11XX_32 -f 115200 --chip -vv
0000375 D Project directory: /home/dinbox/Dinbox/tbb [session]
0000388 D Detaching Kernel Driver of Interface 0 from USB device (VID=1fc9 PID=0143). [pyusb_backend]
0000395 D CMSIS-DAP v1 probe PVDTRQO1KGVQV: protocol version 1.1.0 [dap_access_cmsis_dap]
0000399 D closing interface [pyusb_backend]
0000401 I Target type is lpc11xx_32 [board]
0000412 D Detaching Kernel Driver of Interface 0 from USB device (VID=1fc9 PID=0143). [pyusb_backend]
0000416 D Running task load_svd [sequencer]
0000416 D Running task pre_connect [sequencer]
0000416 D Running task dp_init [sequencer]
0000416 D Running task lock_probe [sequencer]
0000416 D Running task get_probe_capabilities [sequencer]
0000416 D Running task connect [sequencer]
0000425 D Default wire protocol selected; using SWD [dap]
0000427 D Sending deprecated SWJ sequence to select SWD [swj]
0000435 D DP IDCODE read failed; resending SWJ sequence (use dormant=False) [dap]
0000437 D Sending deprecated SWJ sequence to select SWD [swj]
0000445 D DP IDCODE read failed; resending SWJ sequence (use dormant=False) [dap]
0000447 D Sending SWJ sequence to select SWD; using dormant state [swj]
0000460 D DP IDCODE read failed; resending SWJ sequence (use dormant=False) [dap]
0000462 D Sending SWJ sequence to select SWD; using dormant state [swj]
0000475 D DP IDCODE read failed; resending SWJ sequence (use dormant=False) [dap]
0000475 D uninit session <pyocd.core.session.Session object at 0x7f5cdc02b490> [session]
0000477 D closing interface [pyusb_backend]
0000479 C Unexpected ACK value (0) returned by probe [__main__]

 

Any hints?

0 项奖励
回复

3,848 次查看
enok
Contributor I

Thanks! Ok I found the pinout, here it is (below) if anyone else is looking for it:

As for mcuxpresso I think it doesn't support the LPC11xx processors, at least I can't identify any line matching the LPC1114 in this list: https://www.nxp.com/design/software/development-software/mcuxpresso-software-and-tools-/mcuxpresso-i...

enok_0-1684573971513.png

 

0 项奖励
回复

3,817 次查看
ErichStyger
Specialist I

It is supported with 'preinstalled MCUs', if you create a new project:

ErichStyger_0-1684595700515.png

 

0 项奖励
回复

3,861 次查看
ErichStyger
Specialist I

As for the SWD connector pinout of the MCU-Link: have you checked the schematics of the board (available on the MCU-Link web page)? The 2x5 connector is a standard ARM SWD connector with a standard pinout.

As for debugging: I recommend that you first use the NXP provided MCUXpresso IDE, as it comes with the necessary device support for your device. Once you have that working environment, you still can explore pyOCD or OpenOCD, as there you have to find the correct settings yourself, and making small mistakes can make using pyOCD or OpenOCD a challenge. Especially OpenOCD can be a challenge depending on the version of OpenOCD, as the configuration scripts change between the versions. But I'm using OpenOCD with the McuLink (see https://mcuoneclipse.com/2020/12/15/openocd-with-mcu-link/ ). But OpenOCD does only support a few NXP devices.

I have covered pyOCD (see https://mcuoneclipse.com/2023/02/05/debugging-embedded-targets-with-pyocd-and-eclipse/ ) but I cannot comment on using it with the LPC1114 as I have not used that LPC device.

Last but not least: if you are looking for a gdb/command line environment, why not using the LinkServer (see https://mcuoneclipse.com/2023/05/14/linkserver-for-microcontrollers/  ) package? You get gdb server support, command line handling and it is supported by NXP.

I hope this helps,

Erich

0 项奖励
回复