Segger J-Link Debugging Problem

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

Segger J-Link Debugging Problem

Jump to solution
32,103 Views
nirvanauscn
Contributor III

On OSX by using the same FRDM-K22F board and Onboard OpenSDA/J-Link, with KDS 3.2 I can debug w/o problem, but with MCUXpresso 10 I can't. It seems MCUX doesn't provide proper commands to arm-none-eabi-gdb.

I tried the suggestion to delete existing debug configuration and recreate one from Quickstart panel as the following discussion, but it didn't help:

Cannot debug FDRM-K64F via J-link. 

See the attachment jlink_setting.png for the debugger setup.

J-Link GDB server connected successfully to the board, and started listening to localhost port 2331.

But arm-none-eabi-gdb didn't send the following command (existed in KDS):

target remote localhost:2331

and as a result MCUX aborts the debugging, shows a misleading message of "Cannot get Jtag device".

Here's the gdb trace:

280,936 2-gdb-version

280,937 ~"GNU gdb (GNU Tools for ARM Embedded Processors) 7.12.0.20161204-git\n"

280,938 ~"Copyright (C) 2016 Free Software Foundation, Inc.\n"

280,938 ~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is fre\

e software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitt\

ed by law.  Type \"show copying\"\nand \"show warranty\" for details.\n"

280,938 ~"This GDB was configured as \"--host=x86_64-apple-darwin10 --target=arm-none-eabi\".\nType \

\"show configuration\" for configuration details."

280,938 ~"\nFor bug reporting instructions, please see:\n"

280,938 ~"<http://www.gnu.org/software/gdb/bugs/>.\n"

280,938 ~"Find the GDB manual and other documentation resources online at:\n<http://www.gnu.org/soft\

ware/gdb/documentation/>.\n"

280,938 ~"For help, type \"help\".\n"

280,938 ~"Type \"apropos word\" to search for commands related to \"word\".\n"

280,938 2^done

280,938 (gdb) 

280,939 3-environment-cd /Users/xxx/tmp/workspaces/mcuxpresso/frdmk22f_hellodemo_apps_hello_worl\

d

280,940 3^done

280,940 (gdb) 

280,940 4-gdb-set breakpoint pending on

280,941 4^done

280,941 (gdb) 

280,942 5-enable-pretty-printing

280,942 5^done

280,942 (gdb) 

280,943 6-gdb-set python print-stack none

280,943 6^done

280,943 (gdb) 

280,944 7-gdb-set print object on

280,944 7^done

280,944 (gdb) 

280,944 8-gdb-set print sevenbit-strings on

280,945 8^done

280,945 (gdb) 

280,945 9-gdb-set charset ISO-8859-1

280,946 9^error,msg="Cannot convert between character sets `UTF-32' and `ISO-8859-1'"

280,946 (gdb) 

280,946 10-gdb-set dprintf-style gdb

280,947 10^done

280,947 (gdb) 

280,947 11-gdb-set auto-solib-add on

280,947 11^done

280,947 (gdb) 

280,950 12-gdb-exit

280,951 12^exit

If I do everything from the command line, by providing "target remote localhost:2331", etc to arm-none-eabi-gdb, debugging is fine.

 

Also KDS's GDB Client Setup is more flexible than MCUX GDB Client Settings.

KDS has Other options, plus commands, while in MCUX there is no place to enter commands and options.

See kds.png.

Any suggestions how to address this?

Thanks

Labels (1)
1 Solution
21,701 Views
BlackNight
NXP Employee
NXP Employee

The gdb error "Unknown remote qXfer reply: OK" seems to be related to a timeout of GDB. So maybe your machine somehow is not as fast than others, then it causes the problem (I think). At least I have found it in a OpenOCD post (OpenOCD - Open On-Chip Debugger / Mailing Lists ).

I don't have a Mac, but if it works for KDS, but not for MCUXpresso, I suggest to have a look at the start parameters for GDB. On KDS you can find them in the arm-none-eabi-gdb properties inside the Debug view (see Eclipse and GDB: Process Properties, Arguments and GDB Traces | MCU on Eclipse ). For example I have this:

C:\nxp\KDS_3.2.0\eclipse\../segger/JLinkGDBServerCL -if swd -device MK64FN1M0xxx12 -endian little -speed 1000 -port 2331 -swoport 2332 -telnetport 2333 -vd -ir -localhostonly 1 –s

The paramters in MCUXpresso you can find in the console view:

pastedImage_11.png

Executing Server: C:\Program Files (x86)\SEGGER\JLink_V614b\JLinkGDBServerCL.exe  -nosilent -swoport 2332 -select USB -telnetport 2333 -endian little -noir -speed auto -port 2331  -vd -device MK64FN1M0xxx12 -if SWD  -nohalt -reportuseraction

What you might try is to use the monitor sleep command (see Workaround for “Error in final launch sequence: Cannot execute this command without a live selected ... ):

pastedImage_19.png

Maybe this helps?

Erich

View solution in original post

21 Replies
21,373 Views
ryanshuttlewort
Contributor IV

Hello all.  I am having the very same issue with the MIMXRT1050-EVK but under Linux, please see this post.  I have tried the suggestions above without success, i.e. green/blue buttons, 'monitor sleep 500', changing the gdb version etc.  As mentioned in a previous post I can load and debug from the (Linux) command line using the very same settings and back-end tools that the IDE is using, copied from the IDE console views. 

I would appreciate it if someone could review my post and make suggestions as to what could be wrong.

Thanks. 

0 Kudos
Reply
21,397 Views
lpcxpresso_supp
NXP Employee
NXP Employee

First of all - can you confirm whether you have ever managed to debug your board using MCUXpresso IDE? Even just once?

Anyway, an update as to where we have got to with our investigations into your issue.

Generally, we cannot replicate your problem - on a variety of Mac machines of different types, vintages and OS versions (and note that most of the IDE team actually have Macs on their desks for both development and testing work).

We have seen a couple of failures that appear to match your situation. When it has failed, it generally appears that the gdb traces show an unexpected OK from the SEGGER gdb server...

195,232 13^error,msg="Unknown remote qXfer reply: OK"

which then kills the debug session as you have seen. But we have not found a way of replicating the issue in a repeatable way. 99.9% of the time it just works fine. And when it fails, the next attempt just works.

A couple of things I have noticed...

  • Periodically, we have seen the OpenSDA J-Link dismounted by the Mac (from the Mac OS "Disk not ejected properly" message) and it automatically reenumerates again as the OpenSDA Bootloader. If this happens, then the next debug session obviously fails. I don't see how this can be anything the IDE is doing can be triggering though - I've seen it when the IDE isn't actually doing anything. Anyway in this situation, the board has to be unplugged and replugged in, so that it comes back up as the OpenSDA J-Link probe.  It might be worth keeping an eye on how your Mac is handling your board : using  the "USB prober" utility if you have it, otherwise using the terminal command : system_profiler SPUSBDataType

  • We aren't seeing any prompt to accept the license terms for using the OpenSDA J-Link on Mac either. We will follow up on this with SEGGER.

One thing you could try, temporarily, is to change the GDB version that is used by the IDE for debugging. By default, MCUXpresso IDE uses GDB7.12 (and this is required for some of the IDE's debug functionality). But we do also ship GDB7.10 too.

You can try using GDB7.10 instead by going to the IDE Preferences (under the MCUXpresso IDE menu entry on Mac):

  • Preferences -> MCUXpresso IDE -> Debug options (misc)

and changing "arm-none-eabi-gdb" to "arm-none-eabi-gdb-7.10" (without the " characters).

Note that you will need to delete your project's launch configurations, and allow the Quickstart Panel debug option to recreate them after doing this.

Note: We would recommend undoing this gdb change if it doesn't help you.

It would also be interesting if you could confirm whether (temporarily) reprogramming the OpenSDA probe on your board with DAP-Link (CMSIS-DAP) firmware and then with P&E firmware allows successfully debugging from MCUXpresso IDE or not. Download from http://www.nxp.com/opensda.

Use of an external probe would also be an interesting test, if you have access to one.

I would also suggest trying different USB cables, different USB ports on your Mac, and potentially a powered hub too (or using a direct USB port on your Mac if you are currently using a hub).

Regards,

MCUXpresso IDE Support

21,397 Views
phantomgz
Contributor III

follow your guide, I have success launch j-link debugger. thanks.

but I'm running in Window10, "arm-none-eabi-gdb-7.10" should be "arm-none-eabi-gdb-7.10.exe".

another thing, the blue debug icon on my MCUXpresso IDE is gray, I can not click it, I have to start debug on Quickstart panel.

21,702 Views
BlackNight
NXP Employee
NXP Employee

The gdb error "Unknown remote qXfer reply: OK" seems to be related to a timeout of GDB. So maybe your machine somehow is not as fast than others, then it causes the problem (I think). At least I have found it in a OpenOCD post (OpenOCD - Open On-Chip Debugger / Mailing Lists ).

I don't have a Mac, but if it works for KDS, but not for MCUXpresso, I suggest to have a look at the start parameters for GDB. On KDS you can find them in the arm-none-eabi-gdb properties inside the Debug view (see Eclipse and GDB: Process Properties, Arguments and GDB Traces | MCU on Eclipse ). For example I have this:

C:\nxp\KDS_3.2.0\eclipse\../segger/JLinkGDBServerCL -if swd -device MK64FN1M0xxx12 -endian little -speed 1000 -port 2331 -swoport 2332 -telnetport 2333 -vd -ir -localhostonly 1 –s

The paramters in MCUXpresso you can find in the console view:

pastedImage_11.png

Executing Server: C:\Program Files (x86)\SEGGER\JLink_V614b\JLinkGDBServerCL.exe  -nosilent -swoport 2332 -select USB -telnetport 2333 -endian little -noir -speed auto -port 2331  -vd -device MK64FN1M0xxx12 -if SWD  -nohalt -reportuseraction

What you might try is to use the monitor sleep command (see Workaround for “Error in final launch sequence: Cannot execute this command without a live selected ... ):

pastedImage_19.png

Maybe this helps?

Erich

21,387 Views
michaelcress
Contributor II

This also worked for me. Thank you for sharing.

To anyone who comes across this in the context of MCUXpresso, you can find this screen by Right-Clicking on project->Debug As->Debug Configurations. Then click the Debugger tab and enter "monitor sleep 500" within the "Run Commands" box as Erich has highlighted above.

0 Kudos
Reply
21,398 Views
nirvanauscn
Contributor III

Erich, you're always so willing and able to help.

I'm able to debug now in MCUXpresso.

Thanks!

0 Kudos
Reply
21,398 Views
lpcxpresso_supp
NXP Employee
NXP Employee

If you are seeing problems using J-Link on Windows 10, please can you post full details into a new and separate thread - ensuring that you provide as much detail as possible - so that we can investigate separately to the "FRDM-K22 OpenSDA J-Link on Mac OS issue" being investigated in this thread.

As well as a full description of the problem you are seeing, please make sure you include

  • Host computer details
  • J-Link version
  • Target MCU and board
  • GDB traces log
  • JLinkServer log

Regards,

MCUXpresso IDE Support

21,398 Views
nirvanauscn
Contributor III

I'm finally able to debug via MCUXpresso.

Here's one hint hopefully useful for your troubleshooting green bug button debugging issue.

I compared command line arguments passing to JLink GDB Server, the only difference is, the blue button path provides the correct K22F onboard JLink S/N, while the green button path hardcoded it with:

-select USB=123456

Thanks all again for the help!

21,398 Views
lpcxpresso_supp
NXP Employee
NXP Employee

It would be extremely helpful if you could clarify exactly how you solved your issues?

And with regards to the green button, as stated above and in the documentation - we generally do not recommend using it. It is a standard Eclipse button and does not (currently at least) integrate into the MCUXpress IDE auto-probe detection and launch configuration creation system. This is why we recommend using the Quickstart Panel's Debug option (inherited from LPCXpresso IDE).

Regards,

MCUXpresso IDE Support

0 Kudos
Reply
21,398 Views
lpcxpresso_supp
NXP Employee
NXP Employee

So at the point you see the server shut down, I see the connection succeeding. One obvious other thing in the log is that I see you are using quite an old version of the SEGGER OpenSDA firmware (Oct 2015). I would suggest downloading and installing the latest version for the FRDM-K22 (from Feb 2017), which you can find via http://www.nxp.com/opensda. This is the version I've been using here.

Regards,

MCUXpresso IDE Support

21,397 Views
nirvanauscn
Contributor III

I still get the same error after upgrading the OpenSDA firmware to the most recent version:

Connecting to J-Link...

J-Link is connected.

Device "MK22FN512XXX12" selected.

Firmware: J-Link OpenSDA 2 compiled Feb 28 2017 19:27:57

Hardware: V1.00

0 Kudos
Reply
21,397 Views
BlackNight
NXP Employee
NXP Employee

Hi Nirvana,

have you downloaded and installed as well the latest SEGGER J-Link software from SEGGER - The Embedded Experts - Downloads - J-Link / J-Trace  (V6.14b is currently the latest) too?

Erich

21,397 Views
nirvanauscn
Contributor III

Erich, yes I'm using V6.14 (comes with MCUXpresso installation), in the JLink log I posted above:

JLinkARM.dll V6.14 (DLL compiled Feb 23 2017 17:31:36)

0 Kudos
Reply
21,397 Views
BlackNight
NXP Employee
NXP Employee

Hi Nirvana,

ah, sorry, I have missed that.

One thing to note or check: using the SEGGER firmware on a FRDM (or Tower) board pops up a dialog at least once every day. Could it be that you don't see that dialog? See that dialog on SEGGER - The Embedded Experts - OpenSDA / OpenSDA V2 .

If you don't see that dialog, it could be that this is your problem (It works on my Windows machine, and I don't have a Mac to try that). Maybe you could get that dialog to acknowledge (with the check mark) if you run any of the Segger tools and connect to your board? Then that dialog should show up too.

I hope this helps,

Erich

21,397 Views
nirvanauscn
Contributor III

Erich, thanks for pointing that out, but I never see that dialog on Mac :-(

(I assume the JLink/USB driver is already installed).

The frustration part is that, with the same K22F board, KDS works fine, but not MCUXpresso. May be I should wait till its next release.

0 Kudos
Reply
21,398 Views
nirvanauscn
Contributor III

I tried all the suggestions (blue bug icon to launch, cleanup workspace and recreate the app, follow UG chapter 9, chapter 3.8 - 3.10, etc), but sadly nothing helped.

I'm in OSX 10.11.6 (El Capitan). Here's the new error message when started debugging.

Error in final launch sequence

Failed to execute MI command:

-target-select remote localhost:2331

Error message from debugger back end:

Unknown remote qXfer reply: OK

Unknown remote qXfer reply: OK

It still seems there is communication problem between GDB server and client.

Again everything works fine under KDS 1.3 with KSDK 2.0 with the same K22F board.

0 Kudos
Reply
21,399 Views
lpcxpresso_supp
NXP Employee
NXP Employee

Hi, could you please send  the J-Link sever log? you can find it on the console view, by selecting the J-Link sever console (see attached screenshot):

Screen Shot 2017-03-28 at 10.34.35.png

Ciao,

MCUXpresso IDE Support

21,399 Views
nirvanauscn
Contributor III

Here's the log:

Executing Server: /Applications/SEGGER/JLink/JLinkGDBServer  -nosilent -swoport 2332 -select USB=621000000 -telnetport 2333 -endian little -noir -speed auto -port 2331  -vd -device MK22FN512xxx12 -if SWD  -nohalt -reportuseraction

SEGGER J-Link GDB Server V6.14 Command Line Version

JLinkARM.dll V6.14 (DLL compiled Feb 23 2017 17:31:36)

-----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:      yes

Generate logfile:              off

Verify download:               on

Init regs on start:            off

Silent mode:                   off

Single run mode:               off

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:        auto

Target endian:                 little

Connecting to J-Link...

J-Link is connected.

Device "MK22FN512XXX12" selected.

Firmware: J-Link OpenSDA 2 compiled Oct  6 2015 19:31:42

Hardware: V1.00

S/N: 621000000

Checking target voltage...

Target voltage: 3.30 V

Listening on TCP/IP port 2331

Connecting to target...Found SWD-DP with ID 0x2BA01477

Found SWD-DP with ID 0x2BA01477

AP-IDR: 0x24770011, Type: AHB-AP

AHB-AP ROM: 0xE00FF000 (Base addr. of first ROM table)

Found Cortex-M4 r0p1, Little endian.

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

CoreSight components:

ROMTbl 0 @ E00FF000

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

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

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

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

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

Found SWD-DP with ID 0x2BA01477

Found SWD-DP with ID 0x2BA01477

AP-IDR: 0x24770011, Type: AHB-AP

AHB-AP ROM: 0xE00FF000 (Base addr. of first ROM table)

Found Cortex-M4 r0p1, Little endian.

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

CoreSight components:

ROMTbl 0 @ E00FF000

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

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

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

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

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

Connected to target

Waiting for GDB connection...Connected to 127.0.0.1

Server has been shut down.

0 Kudos
Reply
21,399 Views
lpcxpresso_supp
NXP Employee
NXP Employee

We aren't seeing any issues here - though I am currently using an external J-Link connected to my FRDM-K22 board.

Please can you:

  1. Terminate your debug session (if the IDE thinks it is still active)
  2. Disconnect your board from your Mac
  3. Delete all .launch files in your project, plus the Debug / Release folders
  4. Check in Activity Monitor and make sure none of the following processes are running (and if they are, kill them)...

arm-none-eabi-gdb

redlinkserv

JLinkGDBServer

Then reconnect your board to your Mac, select your project in the Project Explorer View, and go down to the QuickStart Panel and click on the "Debug <projectname>" button.

Compare what you see with the MCUXpresso IDE User Guide (chapter 9, as well as the SEGGER specific information in sections 3.8 -> 3.10).

Can you also confirm what version of Mac OSX you are using? (I'm on 10.12.3).

Regards,

MCUXpresso IDE Support

21,398 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi

There is defect in MCUXpresso green debug button if use Jlink as interface.

From my test, if use green debug button with Jlink, It will generate incorrect launch file, that results the fail connection with Jlink. This is a known issue and this will be fixed in next release.

With current MCUXpresso 1.0, to work with Jlink, I suggest use blue debug button as below. From my test, there is no issue with it.

pastedImage_1.png

Currently I don't have a K22 board in hand. If you want, please let me know. I can create a video for you when I get a board tomorrow.


Have a great day,
Jennie Zhang

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