MK02 stop swd working after flash

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

MK02 stop swd working after flash

跳至解决方案
4,568 次查看
lous
Contributor III

Hi,

I start new project with MK02 (QFN,64K) after I work with KF22 with success.

I use the FRDM KF22 board for swd debug and flash.

I solder my board, attach the swd pins to FRDM board and start to work, with sucess.

After one hour, I add line for set output the PORTC, build and flash. At this moment KDS go crazy, breakpoint not working, various vector break, ... strange.

I use jlink cmd line for erase chip without sucess, after long time to search on internet, I find it's maybe secure chip with mass erase disable.

I try to read register, no sucess, I try to connect, no sucess... Ok maybe I burn the chip :smileysad:

I remove the chip from my board, and solder new. Jlink connect with sucess, I flash same firmware => crash again... ho !

Maybe a hardware bug in my board, so I use new board with only the MK02, VCC/GND from FRDM board and swd lines. and some capacitor for decoupling.

I use jlink, connect with success, and flash again (yes, at this time I don't mind it's the firmware the problem), and ... crash again ! ho seriously :smileyshocked:

So, I can send to you the firmware, but it's simple : init clock, set portA/B/C clock, set xtal pins, and portc to output. nothing more :/

When I solder the new chip on fresh board, the jlink output is :

C:\Freescale\KDS_3.0.0\segger>JLink.exe -speed 500

SEGGER J-Link Commander V4.98b ('?' for help)

Compiled Apr 10 2015 20:16:11

DLL version V5.00c, compiled Jun 11 2015 11:40:27

Firmware: J-Link OpenSDA 2 compiled Jun 11 2015 11:14:45

Hardware: V1.00

S/N: 621000000

VTarget = 3.300V

Info: Found SWD-DP with ID 0x2BA01477

Info: Found Cortex-M4 r0p1, Little endian.

Info: FPUnit: 6 code (BP) slots and 2 literal slots

Info: CoreSight components:

Info: ROMTbl 0 @ E00FF000

Info: ROMTbl 0 [0]: FFF0F000, CID: B105E00D, PID: 000BB00C SCS

Info: ROMTbl 0 [1]: FFF02000, CID: B105E00D, PID: 003BB002 DWT

Info: ROMTbl 0 [2]: FFF03000, CID: B105E00D, PID: 002BB003 FPB

Info: ROMTbl 0 [3]: FFF01000, CID: B105E00D, PID: 003BB001 ITM

Info: ROMTbl 0 [4]: FFF41000, CID: B105900D, PID: 000BB9A1 TPIU

Found 1 JTAG device, Total IRLen = 4:

Cortex-M4 identified.

Target interface speed: 500 kHz

Right after flash the firmware, jlink output this :

C:\Freescale\KDS_3.0.0\segger>JLink.exe -speed 500

SEGGER J-Link Commander V4.98b ('?' for help)

Compiled Apr 10 2015 20:16:11

DLL version V5.00c, compiled Jun 11 2015 11:40:27

Firmware: J-Link OpenSDA 2 compiled Jun 11 2015 11:14:45

Hardware: V1.00

S/N: 621000000

VTarget = 3.300V

Info: Found SWD-DP with ID 0x2BA01477

****** Error: Error while identifying Cortex-M core.

Info: Found SWD-DP with ID 0x2BA01477

No devices found on JTAG chain. Trying to find device on SWD.

Info: Found SWD-DP with ID 0x2BA01477

****** Error: Error while identifying Cortex-M core.

Info: Found SWD-DP with ID 0x2BA01477

No device found on SWD.

Failed to identify target. Trying again with slow (4 kHz) speed.

Info: Found SWD-DP with ID 0x2BA01477

****** Error: Error while identifying Cortex-M core.

Info: Found SWD-DP with ID 0x2BA01477

No devices found on JTAG chain. Trying to find device on SWD.

Info: Found SWD-DP with ID 0x2BA01477

****** Error: Error while identifying Cortex-M core.

Info: Found SWD-DP with ID 0x2BA01477

No device found on SWD.

I think a firmware can't crash chip like this, so I make mistake, but where is it :smileysad:

I have 10+ chip unused and two FRDM-K22F board.

I check with the two FRDM board of courses, same results.

I receive ulink probe in two weeks, maybe opensda have bug ? (I try segger opensda only, pemicro I can't found a cmd line like jlink.exe)

Thanks you for helping

Best regards

0 项奖励
回复
1 解答
3,443 次查看
lous
Contributor III

I found answer about monitor speed auto.

In debugger config, If you set SWD, you can set speed (three times) but last parameters is in config file and can't be set with config gui in Eclipse/KDS.

Must change "ilg.gnuarmeclipse.debug.gdbjtag.jlink.interfaceSpeed" from "auto" to speed in kHz to avoid "monitor speed auto" (found in java class). Even if you set all fields in the KDS/Jlink interface.

And... all works (but old chip is lost..., maybe with jtag I can use again these chip)

So in few point :

SWD Line :

  • add resistor for limit peak at high speed,
  • add capacitor for stable communication (more than 22pf make very low speed but stable).
  • Reset_b is not used for SWD.
  • Do not make too high speed in SWD, if interface (the debugger) can handle these speed because you can crash CPU with unknown state in MCU.

KDS :

  •     Even you have set low speed in interface, you need to change in config file (In your project folder, not in KDS folder). (see upper for line)
  • Double check the gdb command send to jlink (monitor xxxx)

I will post again when I have my jtag probe for check if it's swd make crash mcu when data is bad on lines.

I cross my finger to have a stable solution for work now :smileyhappy:

Best regards and thanks

在原帖中查看解决方案

13 回复数
3,443 次查看
lous
Contributor III

I build another pcb with MK22FN512xxx12 and I have same problem.

After couple of hours, I find the solution.

The CPU have illegal instruction, and reset every time. So I make mass erase, but CPU go to watchdog timeout every time and my JLINK probe can't connect to CPU.

Can identity ID but reset occurs after and JLINK lost communication.

Solution is : 330Ohms resistor in serie on SWDIO line, GND/SWDCLK in direct AND Reset_b on Reset (not TRST) pin on JLINK probe.

Now I can debug at full speed (4Mhz for my probe) without error \o/

So, finally : for SWD communication : 100-330Ohms resistor in serie on SWD IO Line, SWDCLK/Reset_b/VCC (for VTref)/GND. You can ad pullup (10K to VCC) on EZP_CS (NMI pin), depends on the last firmware flashed, can be help. Don't use scope probe in 1x to check, but in 10x (change capacitive line value).

Please Freescale, make a document for how to or FAQ for SWD communication on Kinetis device. I'm not alone with this problem, check google :smileywink:

Best regards and happy dev

0 项奖励
回复
3,443 次查看
phlp
Contributor III

Thanks for the reply Lous. I will see if it solves my problem.

Philip

0 项奖励
回复
3,443 次查看
jeremyzhou
NXP Employee
NXP Employee

Hi Lous,

After had a brief look through the statement above, I guess the root cause of issue is using the Freedom board as programmer seems only to allow to program the

same micro controller.

So I'd like to suggest that you can use one FRDM-K22F board to debug another one, then to confirm that whether the phenomenon you mentioned above can reproduce or not.

Hope it hleps.
Have a great day,
Ping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复
3,443 次查看
lous
Contributor III

I try one more.

I solder new chip on my board, solder SWDIO/SWDCLK/GND/VCC.

And chip live without problem.

@400Khz no drop, no communication problem :

C:\Freescale\KDS_3.0.0\segger>JLink.exe -speed 400

SEGGER J-Link Commander V4.98b ('?' for help)

Compiled Apr 10 2015 20:16:11

DLL version V5.00c, compiled Jun 11 2015 11:40:27

Firmware: J-Link OpenSDA 2 compiled Jun 11 2015 11:14:45

Hardware: V1.00

S/N: 621000000

VTarget = 3.300V

Info: Found SWD-DP with ID 0x2BA01477

Info: Found Cortex-M4 r0p1, Little endian.

Info: FPUnit: 6 code (BP) slots and 2 literal slots

Info: CoreSight components:

Info: ROMTbl 0 @ E00FF000

Info: ROMTbl 0 [0]: FFF0F000, CID: B105E00D, PID: 000BB00C SCS

Info: ROMTbl 0 [1]: FFF02000, CID: B105E00D, PID: 003BB002 DWT

Info: ROMTbl 0 [2]: FFF03000, CID: B105E00D, PID: 002BB003 FPB

Info: ROMTbl 0 [3]: FFF01000, CID: B105E00D, PID: 003BB001 ITM

Info: ROMTbl 0 [4]: FFF41000, CID: B105900D, PID: 000BB9A1 TPIU

Found 1 JTAG device, Total IRLen = 4:

Cortex-M4 identified.

Target interface speed: 400 kHz

I will try to flash when my armgcc while not crash...

But erase from jlink.exe while not hang the swd communication. And power off/on while no affect too.

Stay tuned :smileyhappy:

0 项奖励
回复
3,442 次查看
lous
Contributor III

I able to flash from cmd line (jlink.exe / loadfile) and perform step, halt, reset, ... every fine. But from eclipse, I have always hard_fault with same code (only loop in main with integer increment from 0 to 32). Same speed set in KDS (3.0.0), same jlink dll, ... I don't understand the problem. I try to remove all KSDK/KDS and make fresh install... maybe corrupted dll/exe.

0 项奖励
回复
3,442 次查看
lous
Contributor III

I have installed KSDK and KDS again, after clean.

I rebuild project with only loop in main.

I build, flash, and start with jlink cmd line, every work fine at 400Khz. Same parameters in KDS, fail, sometime HardFault, sometimes NMI, ...

I change NMI in register for disable, add ISR for fault, ... nothing work, for about 1 hour

I can work only with jlink.exe (erase, loadfile, step, go, halt, regs, ...).

After this hour, the cpu crash again, I just see the regs is :

-------------------------------------------------------------------------

PC = FFFFFFFE, CycleCnt = 00000000

R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000

R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000

R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000

R12= 00000000

SP(R13)= FFFFFFFC, MSP= FFFFFFFC, PSP= 00000000, R14(LR) = FFFFFFFF

XPSR = 01000000: APSR = nzcvq, EPSR = 01000000, IPSR = 000 (NoException)

CFBP = 00000000, CONTROL = 00, FAULTMASK = 00, BASEPRI = 00, PRIMASK = 00

FPU regs: FPU not enabled / not implemented on connected CPU.

-------------------------------------------------------------------------

After that, nothing can work with cpu, I need to remove and solder new on board...

(I have add resistor to SWDIO/SWDCLK line, perfect trace on scope, no peak, ...)

I try everything I know, I can't found where is the problem.

Something in KDS debug config make CPU crash, without KDS, cpu work fine... maybe move to keil

Best regards

0 项奖励
回复
3,442 次查看
jeremyzhou
NXP Employee
NXP Employee

Hi Lous,

Thanks for your reply.

I'd like to confirm one thing with you that whether KE02 worked well by using the Jlink.exe, however failed by using the KDS tool when used the FRDM-K22F board for SWD debugger or not.

Do you have any updates when you choose other IDE likes Keil or IAR?

I'm looking forward to your reply.
Have a great day,
Ping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复
3,442 次查看
lous
Contributor III

I have make another test with FRDM-K22F, on KDS when I debug,I set interface to 400Khz... but KDS send to gdb (send to jlinkgdb) one "monitor speed auto" before upload firmware and halt cpu. So at this speed my SWD have error... maybe this is the problem.

I search where is the file with all init params for gdb used by KDS for remove the "monitor speed auto".

Best regards

3,444 次查看
lous
Contributor III

I found answer about monitor speed auto.

In debugger config, If you set SWD, you can set speed (three times) but last parameters is in config file and can't be set with config gui in Eclipse/KDS.

Must change "ilg.gnuarmeclipse.debug.gdbjtag.jlink.interfaceSpeed" from "auto" to speed in kHz to avoid "monitor speed auto" (found in java class). Even if you set all fields in the KDS/Jlink interface.

And... all works (but old chip is lost..., maybe with jtag I can use again these chip)

So in few point :

SWD Line :

  • add resistor for limit peak at high speed,
  • add capacitor for stable communication (more than 22pf make very low speed but stable).
  • Reset_b is not used for SWD.
  • Do not make too high speed in SWD, if interface (the debugger) can handle these speed because you can crash CPU with unknown state in MCU.

KDS :

  •     Even you have set low speed in interface, you need to change in config file (In your project folder, not in KDS folder). (see upper for line)
  • Double check the gdb command send to jlink (monitor xxxx)

I will post again when I have my jtag probe for check if it's swd make crash mcu when data is bad on lines.

I cross my finger to have a stable solution for work now :smileyhappy:

Best regards and thanks

3,442 次查看
phlp
Contributor III

Hi Lous,

I have a similar problem than you had. I wonder if you could help me? Here is my setup and symptoms:

1) I use a Multilink Universal to connect to a custom KL02 board.

2) I use the SWD interface (Vcc, gnd, rst, dio, clk).

3) Most of the time when I flash the KL02 and run it in debug mode, a hard fault occurs - I have not determined its origin yet.

4) The hard fault stops at void __thumb_startup(void). If I continuously press "resume" it will eventually run.

5) Most of the time it will continue to run but if I remove the SWD interface from the PCB and then reconnect it and try to flash the KL02 again, it fails. On a scope the outputs of rst, dio and clk typically is then an undefined state (about 1V). I then have to replace the KL02 but the problem is persistent.

How did you add you resistors (series, parallel)?

Any help will be appreciated since this is driving me nuts!

Thanks

Philip

0 项奖励
回复
3,442 次查看
phlp
Contributor III

Hi all,

Just to let everyone know, I have found my problem. The solder flux expired causing the MCU's to fail!

Till later

Philip

0 项奖励
回复
3,442 次查看
lous
Contributor III

Hi, When I use KDS for build and Jlink.exe for interact with MCU (flash, reset, step, halt, ...) all is ok.

I have good "PC", good instructions and mcu work (I have check only PORTC to output and make blink five led).

If I make a hard fault (like bad ptr), I can deal with it in jlink.exe cmd line (reset, follow step, see error, ...)

But if I use KDS for debug (with jlinkgdb) I have strange behavior, breakpoint work not all time, PC have sometime in the 0xFFFFFFFE range, HardFault without bad firmware, ... very strange.

I suspect something in jlinkgdb init command in KDS may block mcu in random state.

But I can't found the init cmd used in KDS (all cmd sended to gdb server).

All steps described here is with this setup :

FRDM-K22F for SWD flasher, opensda segger firmware inside, SWDIO/CLK VCC/GND lines, Resistor on IO and CLK lines.

At 400Khz no problem (because capacitor on clk line => 22pf).

For now, I have 4 mcu in unknown state, unrecoverable for the moment.

I will try with Keil today (I don't have IAR), for check if the init cmd used in KDS is the problem.

Best regards

0 项奖励
回复
3,442 次查看
lous
Contributor III

Hi,

Thanks for answer.

I try to use one FRDM-K22F to debug another FRDM-K22F. It's work for normal use, and I try to flash the firmware of mk02 on the K22. The cpu crash because is not for this cpu, but for recovery, without reset line, it's impossible, and with reset line I will take more than 50 try for connect with sucess for erase flash.

I think the cpu reset so fast the opensda can't connect and halt cpu. Can you confirm ?

If it's this case, with true swd programmer, it's maybe possible to recover my mk02 because opensda won't use frequency more than 1429KHz if onboard, 100Khz if offboard (another freedom board).

Another problem possible is the power of swd lines, because, in the case of cpu is crashed, if I remove the another FRDM-K22F, and use the onboard opensda, all work well. (I use cable lenght 10cm).

My FRDM to FRDM setup :

PIN FRDM OPENSDASIGNAL FRDM OPENSDASIGNAL FRDM CPUPIN FRDM CPU

J25_4

3.33.3J25_4
J25_14GNDGNDJ25_14
J13_2SWdioSWdioJ13_1
J10_2SWclkSWclkJ10_1
J25_6RSTb RSTb J25_6

Maybe cable lenght, noise (power or signal), but everytime when cpu can't reach with offboard opensda, I can recovery with onboard opensda.

I know swd is noise sensible but for 10cm of cable, another problem no ?

Best regards

0 项奖励
回复