Debugging on FRDM-K22F with Segger J-Link OpenSDA firmware

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

Debugging on FRDM-K22F with Segger J-Link OpenSDA firmware

3,455 Views
jrychter
Contributor V

I'm getting an error when trying to debug using Segger J-Link OpenSDA firmware on a FRDM-K22F. The message is:

 

120426_120426.png2015-12-26 at 12.13.png

 

But — I am running KDS 3.1.0 and the debug console itself reports v4.98b. The firmware on the FRDM board is JLink_OpenSDA_V2_1_2015-10-13.bin.

Labels (1)
0 Kudos
Reply
7 Replies

2,076 Views
jrychter
Contributor V

/opt/Freescale/KDS_v3/segger/JLinkGDBServerCL -if swd -device MK22FN512xxx10 -endian little -speed 1000 -port 2331 -swoport 2332 -telnetport 2333 -vd -ir -localhostonly 1 -singlerun -strict -timeout 0
SEGGER J-Link GDB Server V5.10n Command Line Version

JLinkARM.dll V5.10n (DLL compiled Feb 19 2016 18:45:10)

-----GDB Server start settings-----
GDBInit file: none
GDB Server Listening port: 2331
SWO raw output listening port: 2332
Terminal I/O port: 2333
Accept remote connection: localhost only
Generate logfile: off
Verify download: on
Init regs on start: on
Silent mode: off
Single run mode: on
Target connection timeout: 0 ms
------J-Link related settings------
J-Link Host interface: USB
J-Link script: none
J-Link settings file: none
------Target related settings------
Target device: MK22FN512xxx10
Target interface: SWD
Target interface speed: 1000kHz
Target endian: little

Connecting to J-Link...
Segmentation fault (core dumped)

and here's all I can get from the resulting core (as there is no debug info):

gdb --core=core --args /opt/Freescale/KDS_v3/segger/JLinkGDBServerCL -if swd -device MK22FN512xxx10 -endian little -speed 1000 -port 2331 -swoport 2332 -telnetport 2333 -vd -ir -localhostonly 1 -sing
lerun -strict -timeout 0
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /opt/Freescale/KDS_v3/segger/JLinkGDBServerCL...(no debugging symbols found)...done.

warning: core file may not match specified executable file.
[New LWP 16400]
[New LWP 16398]
[New LWP 16402]
[New LWP 16401]
[New LWP 16399]
[New LWP 16404]
[New LWP 16403]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `/opt/Freescale/KDS_v3/segger/JLinkGDBServerCL -if swd -device MK22FN512xxx10 -e'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00007fc162667004 in ?? () from /opt/Freescale/KDS_v3/segger/libjlinkarm.so.5
[Current thread is 1 (Thread 0x7fc161ca7700 (LWP 16400))]
(gdb) bt
#0 0x00007fc162667004 in ?? () from /opt/Freescale/KDS_v3/segger/libjlinkarm.so.5
#1 0x8a6b7a0e9a26cedb in ?? ()
#2 0xae1ed2280e59d877 in ?? ()
#3 0x784f2bb270849cd9 in ?? ()
#4 0x70bfb099cf4b8867 in ?? ()
#5 0x2c5fcb03f1eaa5d8 in ?? ()
#6 0xa1689ea8fd802e20 in ?? ()
#7 0x7a0e9a26cedb9110 in ?? ()
#8 0xd2280e59d8778a6b in ?? ()
#9 0x2bb270849cd9ae1e in ?? ()
#10 0xb099cf4b8867784f in ?? ()
#11 0xcb03f1eaa5d870bf in ?? ()
#12 0x00007fc16269005f in JLINKARM_ETB_ReadReg () from /opt/Freescale/KDS_v3/segger/libjlinkarm.so.5
Backtrace stopped: Cannot access memory at address 0x9110a1689ea8fd88
(gdb)

This looks like a real bug in Segger's software. How do I report this other than posting here?

0 Kudos
Reply

2,076 Views
BlackNight
NXP Employee
NXP Employee

Hi Jan,

can you check if there is no J-Link zombi process running (see point 8 in Debugging Failure: Check List and Hints ).

Additionally, you might try to use the latest Segger J-Link software, see Updating Segger Tools in Eclipse Kinetis Design Studio. And check if you have a JLinkGDBServerCL running (kill it), see GDB Client and Server: Unlocking GDB

I hope this helps,

Erich

0 Kudos
Reply

2,076 Views
jrychter
Contributor V

Eric, thanks for your help.

Unfortunately, there were no zombie processes, restarting the machine did not help. I updated Segger J-Link to the latest version, but the message remains the same. I also launched the actual debugger command manually, to see for myself what was happening and:

[21:32] ubuntu-electronics:/opt/Freescale/KDS_3.0.0/segger>/opt/Freescale/KDS_3.0.0/eclipse/../segger/JLinkGDBServerCL -if swd -device MK22FN128xxx10 -endian little -speed 1000 -port 2331 -swoport 2332 -telnetport 2333 -vd -ir -localhostonly 1 -singlerun -strict -timeout 0

SEGGER J-Link GDB Server V5.10f Command Line Version

JLinkARM.dll V5.10f (DLL compiled Dec 22 2015 14:27:31)

-----GDB Server start settings-----

GDBInit file:                  none

GDB Server Listening port:     2331

SWO raw output listening port: 2332

Terminal I/O port:             2333

Accept remote connection:      localhost only

Generate logfile:              off

Verify download:               on

Init regs on start:            on

Silent mode:                   off

Single run mode:               on

Target connection timeout:     0 ms

------J-Link related settings------

J-Link Host interface:         USB

J-Link script:                 none

J-Link settings file:          none

------Target related settings------

Target device:                 MK22FN128xxx10

Target interface:              SWD

Target interface speed:        1000kHz

Target endian:                 little

Connecting to J-Link...

Segmentation fault (core dumped)

[21:33] ubuntu-electronics:/opt/Freescale/KDS_3.0.0/segger>

My guess is that the message is incorrect.

I'm puzzled — this whole setup has worked for me in a number of scenarios, with various FRDM boards. I recently used it to program a FRDM-KL03Z, FRDM-K20, and also my own boards that use a KL03, using a real Segger J-Link device. Earlier on I also used the same environment with a FRDM-KL05Z and FRDM-KL25Z. It's just with the K22F that I'm seeing these problems.

To test and confirm, just after getting the above segfault I connected a FRDM-KL03Z and successfully loaded & debugged an application using the J-Link OpenSDA interface.

Is there a certain combination of firmware that I should be using? What do people use to develop on the FRDM-K22F? It's my first time with this board and so far I found no way of reliably programming it. Segger coredumps, P&E works but is flaky — it sometimes disconnects and loses the device.

Should I be using something different than JLink_OpenSDA_V2_1_2015-10-13.bin? I admit I'm getting lost in all the combinations of OpenSDA, mbed, JLink and P&E…

0 Kudos
Reply

2,076 Views
BlackNight
NXP Employee
NXP Employee

Hi Jan,

Below is what I get when I debug my FRDM-K22F (on Windows).

I see that you are using MK22FN128xxx10 and not MK22FN512xxx10?

SEGGER J-Link GDB Server V5.02k Command Line Version

JLinkARM.dll V5.02k (DLL compiled Nov 13 2015 18:22:26)

-----GDB Server start settings-----

GDBInit file:                  none

GDB Server Listening port:     2331

SWO raw output listening port: 2332

Terminal I/O port:             2333

Accept remote connection:      localhost only

Generate logfile:              off

Verify download:               on

Init regs on start:            on

Silent mode:                   off

Single run mode:               on

Target connection timeout:     0 ms

------J-Link related settings------

J-Link Host interface:         USB

J-Link script:                 none

J-Link settings file:          none

------Target related settings------

Target device:                 MK22FN512xxx12

Target interface:              SWD

Target interface speed:        1000kHz

Target endian:                 little

Connecting to J-Link...

J-Link is connected.

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

Hardware: V1.00

S/N: 621000000

Checking target voltage...

Target voltage: 3.30 V

Listening on TCP/IP port 2331

Connecting to target...Connected to target

Waiting for GDB connection...Connected to 127.0.0.1

Reading all registers

Read 4 bytes @ address 0x00000000 (Data = 0x20000000)

Target interface speed set to 1000 kHz

Resetting target

Halting target CPU...

...Target halted (PC = 0x000023F0)

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, R13= 20000000, MSP= 20000000, PSP= 00000000

R14(LR) = FFFFFFFF, R15(PC) = 000023F0

XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000

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

Reading all registers

Read 4 bytes @ address 0x000023F0 (Data = 0x46204C0B)

Select auto target interface speed (1429 kHz)

Flash breakpoints enabled

Semi-hosting enabled (Handle on BKPT)

Semihosting I/O set to TELNET Client

Read 4 bytes @ address 0x000023F0 (Data = 0x46204C0B)

Downloading 408 bytes @ address 0x00000000 - Verified OK

Downloading 16 bytes @ address 0x00000400 - Verified OK

Downloading 4096 bytes @ address 0x00000410 - Verified OK

Downloading 4096 bytes @ address 0x00001410 - Verified OK

Downloading 4096 bytes @ address 0x00002410 - Verified OK

Downloading 4096 bytes @ address 0x00003410 - Verified OK

Downloading 4096 bytes @ address 0x00004410 - Verified OK

Downloading 4096 bytes @ address 0x00005410 - Verified OK

Downloading 4096 bytes @ address 0x00006410 - Verified OK

Downloading 4096 bytes @ address 0x00007410 - Verified OK

Downloading 4096 bytes @ address 0x00008410 - Verified OK

Downloading 4096 bytes @ address 0x00009410 - Verified OK

Downloading 4096 bytes @ address 0x0000A410 - Verified OK

Downloading 4096 bytes @ address 0x0000B410 - Verified OK

Downloading 4096 bytes @ address 0x0000C410 - Verified OK

Downloading 4096 bytes @ address 0x0000D410 - Verified OK

Downloading 4096 bytes @ address 0x0000E410 - Verified OK

Downloading 400 bytes @ address 0x0000F410 - Verified OK

Downloading 8 bytes @ address 0x0000F5A0 - Verified OK

Downloading 4 bytes @ address 0x0000F5A8 - Verified OK

Downloading 4 bytes @ address 0x0000F5AC - Verified OK

Downloading 404 bytes @ address 0x0000F5B0 - Verified OK

Downloading 36 bytes @ address 0x0000F744 - Verified OK

Read 4 bytes @ address 0x000023F0 (Data = 0x46204C0B)

Resetting target

Halting target CPU...

...Target halted (PC = 0x000023F0)

Read 2 bytes @ address 0x00002234 (Data = 0xF7FE)

Read 2 bytes @ address 0x00002234 (Data = 0xF7FE)

Read 2 bytes @ address 0x00002234 (Data = 0xF7FE)

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, R13= 20000000, MSP= 20000000, PSP= 00000000

R14(LR) = FFFFFFFF, R15(PC) = 000023F0

XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000

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

Reading all registers

Read 4 bytes @ address 0x000023F0 (Data = 0x46204C0B)

Setting breakpoint @ address 0x00002234, Size = 2, BPHandle = 0x0001

Starting target CPU...

...Breakpoint reached @ address 0x00002234

Reading all registers

Read 4 bytes @ address 0x00002234 (Data = 0xF9ECF7FE)

Removing breakpoint @ address 0x00002234, Size = 2

Read 4 bytes @ address 0x1FFF700C (Data = 0x00000000)

Read 4 bytes @ address 0x1FFF700C (Data = 0x00000000)

Reading 64 bytes @ address 0x00002200

Reading 64 bytes @ address 0x00002240

Reading 64 bytes @ address 0x00002280

I hope this helps,

Erich

0 Kudos
Reply

2,076 Views
jrychter
Contributor V

I see that you are using MK22FN128xxx10 and not MK22FN512xxx10?

Yes, I noticed that right after posting. But this makes no difference (I tried).

I envy your results. I wish I was getting this output :-)

Some more checking shows that:

  • starting GDB without the board attached does produce the correct messages:

Connecting to J-Link...

Connecting to J-Link failed. Connected correctly?

GDBServer will be closed...

Shutting down...

Could not connect to J-Link.

Please check power, connection and settings.

  • connecting my board produces:

Connecting to J-Link...

Segmentation fault (core dumped)

  • strace of the gdb process shows it successfully connects to the USB device in /dev, reads 139 bytes, and a while later segfaults.

This seems to be a bug and not something I can fix. No developing on the FRDM-K22F for me, I guess.

0 Kudos
Reply

2,076 Views
jrychter
Contributor V

I forgot to summarize:

  • Segger OpenSDA firmware causes gdb to core dump and doesn't work at all,
  • PEMicro firmware works, but is flaky, and sometimes disconnects and can't find the device anymore,
  • OpenOCD isn't usable either:

/opt/Freescale/KDS_3.0.0/eclipse/../openocd/bin/openocd: error while loading shared libraries: libudev.so.0: cannot open shared object file: No such file or directory

Which means the board is pretty much unusable. I managed to "fix" OpenOCD by symlinking libudev.so.1 to libudev.so.0 (not sure if this is reliable) and it works, but is very slow compared to J-Link.

I'm slightly puzzled: I can't be the only one trying to use this board? Am I the only one using Linux and FRDM-K22F?

0 Kudos
Reply

2,076 Views
jrychter
Contributor V

So, several months later, I tried again, this time also with a newer OpenSDA J-Link firmware (2016-09-16 with md5 6d934842d957831cbe90b426712dcac3). No success.

I can use the FRDM-K22F with PE firmware (it's painfully slow, and has issues, but kind of works), I can use a standalone J-Link, I can use FRDM-KL03Z with J-Link firmware, but trying to use FRDM-K22F with J-Link firmware fails with a segfault and a cryptic error message.

Has anyone succesfully used a FRDM-K22F with J-Link OpenSDA firmware under Linux? It seems this simply does not work.

0 Kudos
Reply