This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Cannot debug NXP KL8x using J-link SWD

We are using a custom board based on NXP Kinetis MKL81Z128VMC7 and SEGGER J-link for programming and debugging.J-link is connected to the target using 10-pin connector as below
Pin1: VCC
Pin3 and 5: GND
Pin2: SW_DIO (10k pull-up used)
Pin4: SW_CLK (10k pull-down used)
Pin10: Reset (10k pull-up used)

IDE: Keil µVision V5.17.0.0 Toolchain: MDK-Lite Version: 5.17

After the project is built successfully, when I press F8 to download the code into flash. I get below error message (at the end)

* JLink Info: Device "MKL82Z128XXX7" selected.

JLink info:
------------
DLL: V6.18a, compiled Aug 11 2017 17:53:19
Firmware: J-Link V10 compiled Jul 28 2017 08:59:01
Hardware: V10.10
S/N : 600103509
Feature(s) : RDI, FlashBP, FlashDL, JFlash, GDB

* JLink Info: Executing InitTarget()
* JLink Info: Found SW-DP with ID 0x0BC11477
* JLink Info: AP map detection skipped. User manually configured AP map.
* JLink Info: AP[0]: AHB-AP (IDR: Not set)
* JLink Info: AP[1]: CUSTOM-AP (IDR: Not set)
* JLink Info: AP[0]: Core found
* JLink Info: AP[0]: AHB-AP ROM base: 0xF0002000
* JLink Info: CPUID register: 0x410CC601. Implementer code: 0x41 (ARM)
* JLink Info: Found Cortex-M0 r0p1, Little endian.
* JLink Info: FPUnit: 2 code (BP) slots and 0 literal slots
* JLink Info: CoreSight components:
* JLink Info: ROMTbl[0] @ F0002000
* JLink Info: ROMTbl[0][0]: F0000000, CID: B105900D, PID: 001BB932 MTB-M0+
* JLink Info: ROMTbl[0][1]: F0001000, CID: B105900D, PID: 0008E000 MTBDWT
* JLink Info: ROMTbl[0][2]: E00FF000, CID: B105100D, PID: 000BB4C0 ROM Table
* JLink Info: ROMTbl[1] @ E00FF000
* JLink Info: ROMTbl[1][0]: E000E000, CID: B105E00D, PID: 000BB008 SCS
* JLink Info: ROMTbl[1][1]: E0001000, CID: B105E00D, PID: 000BB00A DWT
* JLink Info: ROMTbl[1][2]: E0002000, CID: B105E00D, PID: 000BB00B FPB
ROMTableAddr = 0xF0002000
* JLink Info: Executing AfterResetTarget()
* JLink Info: Executing AfterResetTarget()

Target info:
------------
Device: MKL82Z128xxx7
VTarget = 2.509V
State of Pins:
TCK: 0, TDI: 0, TDO: 0, TMS: 1, TRES: 1, TRST: 0
Hardware-Breakpoints: 2
Software-Breakpoints: 8192
Watchpoints: 2
JTAG speed: 15000 kHz

Full Chip Erase Done.
Programming Done.
Contents mismatch at: 0000001CH (Flash=00H Required=AFH) !
Contents mismatch at: 0000001DH (Flash=00H Required=D1H) !
Contents mismatch at: 0000001EH (Flash=00H Required=FEH) !
Contents mismatch at: 0000001FH (Flash=00H Required=DFH) !
Verify Failed!
Error: Flash Download failed - "Cortex-M0+"

It appears that I can program the flash but can't read it back, thus verification fails.
If can ignore the error and proceed with debugging but then get "hardfault_handler" error and can't debug.

I have specifically selected SWD interface to the MCU but not sure why it's showing as if I am using JTAG.

I can also program the MCU using J-flash outside of the IDE but can not get the debuggign working!Help please.