This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF52 DK JLink debugging in ubuntu

Hi.

Quest to get the toolchain working under ubuntu continues.

I've done the eclipse and jlink config as explained in the nrf51 linux tutorial (with of course keeping mind that I should use 52 packages). I can make build under eclipse, but I cannot attach the device for debugging.


Message from Eclipse:

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

JLinkARM.dll V5.10u (DLL compiled Mar 17 2016 19:06:19)

-----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:                 nRF52
Target interface:              SWD
Target interface speed:        1000kHz
Target endian:                 little

Connecting to J-Link...
Connecting to J-Link failed. Connected correctly?
GDBServer will be closed...
Shutting down...

**************************

lsusb shows SEGGER device:

Bus 004 Device 002: ID 8087:8000 Intel Corp. 
Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 002: ID 8087:8008 Intel Corp. 
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 138a:0017 Validity Sensors, Inc. Fingerprint Reader
Bus 001 Device 002: ID 058f:9540 Alcor Micro Corp. AU9540 Smartcard Reader
Bus 001 Device 010: ID 046d:c52e Logitech, Inc. MK260 Wireless Combo Receiver
Bus 001 Device 027: ID 1366:1015 SEGGER 
Bus 001 Device 006: ID 5986:0268 Acer, Inc 
Bus 001 Device 005: ID 8087:07dc Intel Corp. 
Bus 001 Device 014: ID 1199:a001 Sierra Wireless, Inc. 
Bus 001 Device 009: ID 0557:2221 ATEN International Co., Ltd Winbond Hermon
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

**************

dmesg:

[4510002.975124] usb 1-2: USB disconnect, device number 26
[4510003.007271] FAT-fs (sdb): unable to read boot sector to mark fs as dirty
[4510004.480854] usb 1-2: new high-speed USB device number 27 using xhci_hcd
[4510004.609642] usb 1-2: config 1 interface 1 altsetting 0 bulk endpoint 0x83 has invalid maxpacket 64
[4510004.609646] usb 1-2: config 1 interface 1 altsetting 0 bulk endpoint 0x4 has invalid maxpacket 64
[4510004.610019] usb 1-2: New USB device found, idVendor=1366, idProduct=1015
[4510004.610021] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[4510004.610023] usb 1-2: Product: J-Link
[4510004.610024] usb 1-2: Manufacturer: SEGGER
[4510004.610025] usb 1-2: SerialNumber: 000682343799
[4510009.615033] cdc_acm 1-2:1.0: ttyACM1: USB ACM device
[4510009.615719] usb-storage 1-2:1.3: USB Mass Storage device detected
[4510009.615849] scsi host17: usb-storage 1-2:1.3
[4510010.615899] scsi 17:0:0:0: Direct-Access     SEGGER   MSD Volume       1.00 PQ: 0 ANSI: 4
[4510010.616151] sd 17:0:0:0: Attached scsi generic sg2 type 0
[4510010.616352] sd 17:0:0:0: [sdb] 21829 512-byte logical blocks: (11.1 MB/10.6 MiB)
[4510010.616534] sd 17:0:0:0: [sdb] Write Protect is off
[4510010.616536] sd 17:0:0:0: [sdb] Mode Sense: 0b 00 00 08
[4510010.616701] sd 17:0:0:0: [sdb] No Caching mode page found
[4510010.616703] sd 17:0:0:0: [sdb] Assuming drive cache: write through
[4510010.619531]  sdb:
[4510010.620405] sd 17:0:0:0: [sdb] Attached SCSI removable disk
[4510010.833404] systemd-hostnamed[7429]: Warning: nss-myhostname is not installed. Changing the local hostname might make it unresolveable. Please install nss-myhostname!

*******************************

To me it looks like it's a problem with the Jlink device being detected as SCSI device. I found an issue from '13 with 51 series board under linux with similar problem.

Any ideas how to solve this?

  • Do you set the correct device name in the debugger tab configuration ? Could you try with nRF52832_xxAA ?

    See the supported device names: www.segger.com/jlink_supported_devices.html

    You should also check the udev rules, see gnuarmeclipse.github.io/.../

  • Hi,

    Since the Segger debugger includes a "drag and drop" drive for .hex files, it shall enumerate parts of it as a SCSI drive. I get the same print outs in my dmesg.

    It seems that it has some issues enumerating at your end:

    [4510004.609642] usb 1-2: config 1 interface 1 altsetting 0 bulk endpoint 0x83 has invalid maxpacket 64
    [4510004.609646] usb 1-2: config 1 interface 1 altsetting 0 bulk endpoint 0x4 has invalid maxpacket 64
    

    If you run JLinkExe from command line (should be in $PATH), it will force a firmware update if available. Could you try this (and ensure that it finishes properly) then power-cycle the board? Or maybe JlinkExe also have issues connecting to the board? If so, try to sudo it and see if that changes anything.

    Can you also ensure that the Segger udev rules are present? They should be located in /etc/udev/rules.d/99-jlink.rules and have atleast these three lines (will have many others, but this is the one for the nRF52-DK debugger):

    ACTION!="add", SUBSYSTEM!="usb_device", GOTO="jlink_rules_end"
    ATTR{idProduct}=="1015", ATTR{idVendor}=="1366", MODE="666"
    LABEL="jlink_rules_end"
    

    Cheers, Håkon

  • Ok, I didn't have anything in the 99-jlink.rules. Also I tried running the eclipse in sudo state, so it got the jlink open (rights issue to USB device?). The firmware got updated OK last week when I first tried the JLink from cmd line.

    However it cannot attach & flash the device via eclipse. The debugger start log seems legit so I don't think this is far from OK.

    SEGGER J-Link GDB Server V5.10u Command Line Version
    
    JLinkARM.dll V5.10u (DLL compiled Mar 17 2016 19:06:19)
    
    -----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:                 nRF52832_xxAA
    Target interface:              SWD
    Target interface speed:        1000kHz
    Target endian:                 little
    
    Connecting to J-Link...
    J-Link is connected.
    Firmware: J-Link OB-SAM3U128-V2-NordicSemi compiled Mar 15 2016 18:03:17
    Hardware: V1.00
    S/N: 682343799
    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 1 bytes @ address 0x00000000 (Data = 0x00)
    Read 1 bytes @ address 0x00000000 (Data = 0x00)
    Reading 64 bytes @ address 0x00000000
    Reading 8 bytes @ address 0x00000000
    Reading 7 bytes @ address 0x00000000
    Target interface speed set to 1000 kHz
    Resetting target
    Halting target CPU...
    ...Target halted (PC = 0x000010BC)
    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= 20008000, MSP= 20008000, PSP= 00000000
    R14(LR) = FFFFFFFF, R15(PC) = 000010BC
    XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000
    CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00
    Reading all registers
    Read 1 bytes @ address 0x00000000 (Data = 0x00)
    Read 1 bytes @ address 0x00000000 (Data = 0x00)
    Reading 8 bytes @ address 0x00000000
    Reading 7 bytes @ address 0x00000000
    Select auto target interface speed (1000 kHz)
    Flash breakpoints enabled
    Semi-hosting enabled (Handle on BKPT)
    Semihosting I/O set to TELNET Client
    SWO disabled succesfully.
    SWO enabled succesfully.
    Read 1 bytes @ address 0x00000000 (Data = 0x00)
    Read 1 bytes @ address 0x00000000 (Data = 0x00)
    Reading 8 bytes @ address 0x00000000
    Reading 7 bytes @ address 0x00000000
    Downloading 4096 bytes @ address 0x0001F000 - Verified OK
    Downloading 4096 bytes @ address 0x00020000 - Verified OK
    Downloading 4096 bytes @ address 0x00021000 - Verified OK
    Downloading 4096 bytes @ address 0x00022000 - Verified OK
    Downloading 4096 bytes @ address 0x00023000 - Verified OK
    Downloading 4096 bytes @ address 0x00024000 - Verified OK
    Downloading 4096 bytes @ address 0x00025000 - Verified OK
    Downloading 260 bytes @ address 0x00026000 - Verified OK
    Downloading 8 bytes @ address 0x00026104 - Verified OK
    Downloading 104 bytes @ address 0x0002610C - Verified OK
    Comparing flash   [....................] Done.
    Verifying flash   [....................] Done.
    Writing register (R8 = 0x00025fb1)
    Writing register (s8 = 0xffffffff)
    Read 1 bytes @ address 0x00025FB1 (Data = 0x49)
    Reading 64 bytes @ address 0x00023740
    Read 1 bytes @ address 0x0002376D (Data = 0xB5)
    Resetting target
    Halting target CPU...
    ...Target halted (PC = 0x000010BC)
    Read 1 bytes @ address 0x0002376D (Data = 0xB5)
    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= 20008000, MSP= 20008000, PSP= 00000000
    R14(LR) = FFFFFFFF, R15(PC) = 000010BC
    XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000
    CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00
    Reading all registers
    Read 1 bytes @ address 0x00000000 (Data = 0x00)
    Read 1 bytes @ address 0x00000000 (Data = 0x00)
    Reading 64 bytes @ address 0x00000000
    Reading 8 bytes @ address 0x00000000
    Reading 7 bytes @ address 0x00000000
    Setting breakpoint @ address 0x0002376D, Size = 4, BPHandle = 0x0001
    Starting target CPU...
    Debugger requested to halt target...
    ...Target halted (PC = 0x000007F0)
    Reading all registers
    Read 1 bytes @ address 0x00000000 (Data = 0x00)
    Read 1 bytes @ address 0x00000000 (Data = 0x00)
    Reading 64 bytes @ address 0x00000000
    Reading 8 bytes @ address 0x00000000
    Reading 7 bytes @ address 0x00000000
    Removing breakpoint @ address 0x0002376D, Size = 4
    Starting target CPU...
    

    After this the old app still runs happily.

  • Plot thickens.

    With just "run" option the eclipse seems to be able to flash the targets added to make targets (now with the ble proximity example both soft device and the app). Also I managed to see the device with smartphone. So this worked atleast for a moment.

    However the debugger still doesn't play along. I can see the user thread for a second or two, but it disappears right away and JLinkGDBServer and gdb terminate with rval -1. Also the SWV terminal terminates with status 0. I tried also logging with the printf/app_trace_put (just added define for the trace support flag in app_trace.h before it's checked). However I can only see crap in the terminal. With same setup and modified blinky example I did manage to see proper trace.

  • Ok, now the debugger works.

    HOX! NORDIC YOU NEED TO FIX THE FAMILY PACK 8.5.0!! HOX!

    Found ansver in the tutorial comments that some dude had to revert device family pack from 8.5.0 to 8.3.2 to get the debugger working. Also I had to change:

    Makefile CFLAGS += -Wall -Werror -O3 to CFLAGS += -Wall -Werror -O0 -g3
    Change the program counter from 0 to start of app (soft device starts from address 0) to (in my case) 0x1f000. This can be done in debug configurations -> GDB SEGGER J-Link Debugging -> you config -> startup page -> set program counter at -field.
    
Related