Can the LPC-Link2 work with the K66?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can the LPC-Link2 work with the K66?

2,931 Views
robinwhittle
Contributor II

I plan to use MCUXpresso with the Teensy 3.6, which has an MK66FX1M0VMD18 microcontroller.  Normally it is not possible to connect a debug probe to it, but by resetting the little 16 pin USB loader microcontroller (MKL02Z32VFG4) I understand it can be done.  [1] and [2] show how - with Serial Wire Debugging data and clock signals becoming available.

In a thread in this forum [3] it was suggested that the LPC-Link2 [4] could be used with a K66 in the final product.  Most of that discussion centered on using the FRDM-K66 which has an inbuilt debug probe, which only works on its own K66. 

I guess it would be possible to develop my firmware on a FRDM-K66, with suitable wires to a DIP header which matches the pinout of the Teensy 3.6, and then trust that the resulting hex file (or whatever form the object code could be put in) would work fine when loaded into the Teensy via its USB flash writing arrangements.  However . . . the K66 in the FRDM-K66 is a different chip to that in the Teensy 3.6 (2MB flash rather than 1MB), and the Teensy uses two 16MHz and 32.768kHz crystals [5], while the FRDM-K66 uses one 12MHz crystal.  In principle the FRDM-K66 could be modified to function like a Teensy 3.6, but the microcontroller is a different model, and I guess I would need to recompile with a different device's headers to generate a valid hex file.  These are all complications I would like to avoid.

The list of supported devices at [4] does not include any K66 or similar devices.  All those listed are LPC devices.  Yet the advice in [3] comes from an NXP technical specialist.

I understand that the LPC-Link2 can be programmed with firmware which makes it behave, to the USB connection, in different ways, including like debug probes from Segger and P&E.  However, I think (I have read dozens of web pages today, and I can't remember which one is relevant here) that the firmware from NXP which makes it behave according to CMSIS-DAP (which I only vaguely understand the meaning of), gives it the greatest capabilities.  (Those may require access to more K66 pins than purely the debug data and clock pins, such as for tracing, which I know almost nothing about, except that it would be highly valuable.)

I understand that I could use various debug probes which cost (for commercial development) $500 to $2k+, from P&E and Segger.  I also understand that I could create my own debug probe with FOS firmware and a Teensy 3.2 [6].  This would work with FOS OpenOCD [7] and so could be used with GDB in general. 

Initially I thought I would simply get a debug probe and run it with a GDB server using my favourite IDE (Codelite) on Linux with a cross-compiler and cross-GDB-debugger.  Then I learned that a carefully crafted IDE such as MCUXpress would have many advantages when working with these highly complex devices (2,250 page reference manuals etc.), such as generating code to configure the chip, examples, and I think some register display and/or trace capabilities.

So if I could use MCUExpress with the inexpensive LPC-Link2, then this would be great.  The IDE and debug probe would both be from NXP and I wouldn't have to integrate disparate systems.

This is a long question for an answer which is probably "No.", but I wanted to outline what I understand so far.


[1] https://mcuoneclipse.com/2017/04/29/modifying-the-teensy-3-5-and-3-6-for-arm-swd-debugging/
[2] https://medium.com/@mattmatic/preparing-teensy-3-6-for-swd-b014b0ce2999

[3] What debugger i-face should I use with FRDM-K66F in MCUXpresso IDE 

[4] LPC-Link2|NXP 

[5] Teensy and Teensy++ Schematic Diagrams 

[6] GitHub - myelin/arduino-cmsis-dap: CMSIS-DAP USB-SWD/JTAG adapter firmware for Pro Micro and Teensy ... 

[7] Open On-Chip Debugger 

Labels (1)
5 Replies

2,039 Views
BlackNight
NXP Employee
NXP Employee

Hi Robin,

Yes, the LPC-Link2 works without any problems for me with the Teensy 3.5/3.6 based on the hardware modifcation described in Modifying the Teensy 3.5 and 3.6 for ARM SWD Debugging | MCU on Eclipse .

To connect with a LPC-Link2 works the same way, only that I use a SWD/JTAG cable adapter (e.g. one from Adafruit):

pastedImage_1.png

The steps are documented with pictures in Debugging the Teensy 3.6 with Eclipse MCUXpresso IDE and CMSIS-DAP LPC-Link2 | MCU on Eclipse .

I hope this is useful for you, and Happy New Year!

Erich

2,039 Views
robinwhittle
Contributor II

Here is how I soldered to pad 15 of the KL02Z.  Grounding this pin should reset the KL02Z and so free the debug pins so we can use them.  The heat to complete the joint was conducted through the single strand of wire I used to make the connection – so it was not necessary to touch the pad itself with a soldering iron.

PJRC (Teensy) Forum 

0 Kudos

2,039 Views
robinwhittle
Contributor II

Hi Erich,

Thanks for confirming that the LPC-Link2, with CMIS-DAP firmware, running under MCUXpress can be used with the suitably-modifed Teensy 3.6. 

As a newbie stumbling into the exceedingly complex field of ARM debugging, Google kept directing me to quite a few of your beautiful articles.  It seems you created this new one, with the answer to my question, in the last day or so.  Thanks very much for all your work! 

Greetings from sunny Daylesford, Victoria, Australia.

Robin

0 Kudos

2,039 Views
robertboys
Contributor IV

Hello

I can provide some insight into CMSIS-DAP.

It is a free Arm protocol for creating a debug adapter/probe.  It can be used to develop an on-board adapter such as NXP OpenSDA (which has a P&E or a CMSIS-DAP mode) and many others.  It is often renamed and not called CMSIS-DAP.  It is widely adopted - LPC-Link2 is CMSIS-DAP compliant as is Kinetis Open-SDA if in CMSIS-DAP mode.

Debuggers that support CMSIS-DAP include Keil uVision, IAR workbench and many others.

CMSIS-DAP normally connects to the target's two SWD connections:  SWDIO and SWDCLK.  It can also work on JTAG but this is not a requirement.

The latest version of CMSIS-DAP supports Serial Wire Viewer (SWV).  The first version of CMSIS-DAP which is the most common today, did not.

Sources and examples are found on GitHub:  CMSIS_5/CMSIS/DAP/Firmware at develop · ARM-software/CMSIS_5 · GitHub 

The LPC-Link2 example is provided.

If you can access a processor's SWD signals, you should have no problem connecting a LPC-LINK2 to it.  I suspect a LPCLINK2 will work with any manufacturer's Coretx-M processor.

Using the free eval version of Keil MDK provides an easy test to see if you are connected properly.  I am sure other tools also provide this test.

If you select CMSIS-DAP and it works with a given debug adapter (such a Keil ULINK2) then it is CMSIS-DAP compliant even if they don't tell you.

I hope this helps.

Bob Boys

freezing in Ontario, Canada

2,039 Views
robinwhittle
Contributor II

Hi Bob,

Thanks very much for your explanation!

I found some information about SWV, the SWO pin and the Instrumentation Trace Macrocell (ITM) [1].  This is supported by the K66 [2 page 169 and later].  The free version of MCUXpress supports it to some degree, with more capabilities for the Pro version [3 page 1].  According to this, the term Serial Wire Viewer and "SWO Trace" are used to refer to the same thing.  There's more info about it here [4], which I am likewise yet to read.

The JTAG_TDO/TRACE_SWO solder ball K6 on the Teensy 3.6 only goes to the KL02Z pin 9.  From Erich Styger's photo [5] (I don't yet have a Teensy 3.6) I can see the track to this pin goes through a via.  So it should be straightforward to solder a wire to the via in order to connect the LPC-Link2.  I plan to reset the KL02Z without soldering heroics by using conductive epoxy to bond a little strand of copper wire between its pin 15 (reset) and pin 3 (an input) which is already connected to the DE pad.  Then, grounding the DE pad should reset the KL02Z.  I can't find detailed documentation for the LPC-Link2, but I assume it can receive this SWO signal.

It will be a few weeks before I have the bits and hook it all up.  I will write to this thread once I have explored the debugging capabilities.  The real time viewing capability, and the ability to use printf() to write arbitrary data to one of the 32 channels of this viewing stream, and have the IDE do something meaningful with it, sounds brilliant - and beyond what can be done even with native debug of x86-64 or anything else I know of.  Its amazing what ARM, NXP and other manufacturers have made these tiny devices do - on a fraction of a watt.

[1] Cortex-M debugging: Introduction to Serial Wire Viewer (SWV) event- and data tracing 

[2] https://www.nxp.com/docs/en/reference-manual/K66P144M180SF5RMV2.pdf 

[3] https://www.nxp.com/docs/en/quick-reference-guide/MCUXpresso_IDE_SWO_Trace.pdf 

[4] ARM Information Center CoreSight Components Technical Reference Manual  Chapter 10. Serial Wire Viewer

[5] https://mcuoneclipse.files.wordpress.com/2017/04/kl02z-removed-from-teensy.png from Modifying the Teensy 3.5 and 3.6 for ARM SWD Debugging | MCU on Eclipse

0 Kudos