HW setup with an LPC-Link2 in CMSIS-DAP mode
If you have an LPC-Link2 lying around, you can use it to debug/develop on the PineTime dev kit.

First, you need to flash a CMSIS-DAP firmware on the LPC-Link2. NXP has these.

If you're using the wires provided with the PineTime, then you will need to populate the J6 location on the LPC-Link2; it's the only one which expects a pin header. I fitted a 9-pin right-angle header.

Then you have to properly match the PineTime SWD pinout to the J6 header pins. Gnd goes to pin 8, Vcc to pin 1, SWDIO to pin 2 and SWDCLK to pin 3.

Last, you have to put jumpers on both JP1 and JP2 of the LPC-Link2. JP1 will make it boot on its internal firmware and thus act as a CMSIS-DAP probe; JP2 will power the SWD signal buffers. If you forget JP2, OpenOCD will recodgnize the probe but not the PineTime.

Then you need a configuration file for OpenOCD. This file should contain the following:

source [find interface/cmsis-dap.cfg]
source [find target/nrf52.cfg]
telnet_port 4444

Name this file appropriately -- I named mine pinetime-lpc-link2-cmsis-dap.cfg.

Now run OpenOCD. In Linux, I run

openocd -f pinetime-lpc-link2-cmsis-dap.cfg -c init

At this point, if your PineTime still contains the factory firmware, it will be access-protected, i.e. you cannot read from it or write to it yet. You'll know it's the case if OpenOCD says "Error: Could not find MEM-AP to control the core".

If your PineTime is access-protected, you'll have to unprotect it before you can program it. This will remove the factory firmware, but it will have to go at some point, right? So open a second terminal, connect to OpenOCD using for instance

telnet localhost 4444

Now issue the following command:

dap apreg 1 0x0c

If the value displayed is 0x00000000 then your PineTime is indeed access-protected, and you can unprotect it by issuing

dap apreg 1 0x04 0x01



to which OpenOCD should eventually display

nrf52.cpu: hardware has 6 breakpoints, 4 watchpoints

... and that is the sign that your PineTime is unprotected and now ready to be reprogrammed!

Messages In This Thread
HW setup with an LPC-Link2 in CMSIS-DAP mode - by aaribaud - 10-28-2019, 03:51 PM

Forum Jump:

Users browsing this thread: 1 Guest(s)