[SOLVED]Linux: Unable to connect to J-Link on board nRF51822 Evaluation Kit

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [SOLVED]Linux: Unable to connect to J-Link on board nRF51822 Evaluation Kit

    When running JLinkExe to connect to my nRF51822 Evaluation Kit which has a J-Link on board, I get this output:

    Source Code

    1. knuta@klure ~/Downloads/JLink_Linux_V456d $ ./JLinkExe
    2. SEGGER J-Link Commander V4.56d ('?' for help)
    3. Compiled Nov 16 2012 16:48:44
    4. Can not connect to J-Link via USB.


    The funny thing is that it seems to detect the device:

    Source Code

    1. J-Link>ShowEmuList
    2. J-Link[0]: Connection: USB, Serial number: *********, USB address: 0


    According to the docs provided by Nordic, I should use the SW port with a speed of 1 MHz, so I try to set that and select the device again:

    Source Code

    1. J-Link>si 1
    2. Selecting SWD as current target interface.
    3. Setting target interface speed to 1MHz. Use "Speed" to change.
    4. J-Link>selemu
    5. J-Link[0]: Connection: USB, Serial number: *********, USB address: 0
    6. Select emulator index: 0
    7. Emulator with USB serial number ********* selected.
    8. Can not connect to J-Link via USB.


    Am I missing a setting or something? The “Can not connect” message gives no hint of what could be wrong.

    The post was edited 1 time, last by knuta ().

  • After finally succeeding with connecting to the J-Link in Windows, this is what I get from JLink.exe on the exact same hardware, except I have booted into Windows Vista instead of Linux:

    Source Code

    1. SEGGER J-Link Commander V4.58a ('?' for help)
    2. Compiled Dec 5 2012 18:38:27
    3. DLL version V4.58a, compiled Dec 5 2012 18:38:08
    4. Firmware: J-Link OB-SAM3U128 V1 compiled Nov 5 2012 19:42:53
    5. Hardware: V1.00
    6. S/N: *********
    7. VTarget = 3.300V
    8. Info: Could not measure total IR len. TDO is constant high.
    9. Info: Could not measure total IR len. TDO is constant high.
    10. No devices found on JTAG chain. Trying to find device on SWD.
    11. Info: Found SWD-DP with ID 0x0BB11477
    12. Info: FPUnit: 4 code (BP) slots and 0 literal slots
    13. Info: Found Cortex-M0 r0p0, Little endian.
    14. Cortex-M0 identified.
    15. JTAG speed: 100 kHz
    16. J-Link>
    Display All


    It seems obvious that there is some kind of software or configuration issue in my Linux setup, but I don't know what could be wrong. Especially since the J-Link does show up in the emulator list in Linux as well.

    I have tried version 4.58 on Linux too, with the same results as before.
  • I'd like to add my voice to the request to Segger to address the support under Linux (and OSX) for the Nordic board.

    I have a few other things to report as well. First, I can also confirm that the OSX Jlink tools fail similarly to the Linux ones:

    Source Code

    1. $ ./JLinkExe.command
    2. SEGGER J-Link Commander V4.58 ('?' for help)
    3. Compiled Nov 29 2012 14:42:36
    4. Can not connect to J-Link via USB.
    5. J-Link>showemulist
    6. J-Link[0]: Connection: USB, Serial number: 0, USB address: -257
    7. J-Link>si 1
    8. Selecting SWD as current target interface.
    9. Setting target interface speed to 1MHz. Use "Speed" to change.
    10. J-Link>selemu
    11. J-Link[0]: Connection: USB, Serial number: 0, USB address: -257
    12. Select emulator index: 0
    13. Can not connect to J-Link via USB.
    14. J-Link>
    Display All



    I can also verify that Linux permissions are not the issue, because for example using OpenOCD on Linux (patched to support the new USB idVendor:idProduct=1366:0105):

    Source Code

    1. Info : J-Link initialization started / target CPU reset initiated
    2. Info : J-Link OB-SAM3U128 V1 compiled Aug 1 2012 10:57:06
    3. Info : J-Link caps 0xb97f5bbf
    4. Info : J-Link hw version 14010000
    5. Info : J-Link hw type uknown 0xe
    6. Info : J-Link max mem block 25136
    7. Info : J-Link configuration
    8. Info : USB-Address: 0x0


    Further, I contacted Nordic, and the engineer reported: "However, there seems to be some issues with JLink and on-board chips with CDC functionality, as used on the nRF51822 Evaluation Kit." He also suggested to contact Segger and request support.


    Any update on this, Segger folks?
  • Thanks Alex, looks like the Nordic board comes up in OSX. However, one still has to manually select the device with "selemu" with no arguments and then select (say) zero. The "selemu 0" command does not work. I cannot get the GDBServer to work yet but I suspect once the JLinkExe startup is figured, the GDB server should follow. At any rate this is a good step forward. Looking forward to the Linux support as well.
  • Awesome! Let me also point out the solution to a problem I encountered while investigating, in case others experience the same thing and need some pointers. I straced the JlinkExe process and saw this:

    Source Code

    1. open("/dev/bus/usb/001/010", O_RDWR) = 4
    2. ioctl(4, USBDEVFS_CLAIMINTERFACE, 0xbf883784) = -1 EBUSY (Device or resource busy)
    3. write(3, "\n ***** Error: ", 16) = 16
    4. write(3, "Can not connect to J-Link via US"..., 34) = 34


    What happens here is that the device is busy because another driver has claimed it. Looking in dmesg, I saw this:

    Source Code

    1. [217129.656127] usb 1-6: new high-speed USB device number 14 using ehci_hcd
    2. [217129.789442] usb 1-6: New USB device found, idVendor=1366, idProduct=0105
    3. [217129.789452] usb 1-6: New USB device strings: Mfr=1, Product=2, SerialNumber=3
    4. [217129.789459] usb 1-6: Product: J-Link
    5. [217129.789465] usb 1-6: Manufacturer: SEGGER
    6. [217129.789470] usb 1-6: SerialNumber: (omitted)
    7. [217129.812561] cdc_acm 1-6:1.0: This device cannot do calls on its own. It is not a modem.
    8. [217129.812713] cdc_acm 1-6:1.0: ttyACM0: USB ACM device
    9. [217129.814803] usbcore: registered new interface driver cdc_acm
    10. [217129.814808] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters


    The nRF51822 is clearly not a modem, but it seems the Linux kernel thinks the USB serial port it exposes is one. This blocks the device so JlinkExe cannot access it, and instead of saying “Device is busy” as it should, it just says failed to connect. This can be solved easily by unloading the cdc_acm driver using modprobe -r or rmmod, and you can avoid it happening again by banning the driver in the modprobe configuration.

    After unloading cdc_acm I got this instead:

    Source Code

    1. ioctl(4, USBDEVFS_SUBMITURB or USBDEVFS_SUBMITURB32, 0xbfd1bbb8) = -1 ENOENT (No such file or directory)


    Which basically means that the wrong endpoint number is being used. I'm sure that is what is being fixed in the upcoming version.

    Let me just say that I would really appreciate if JlinkExe could just print out informative error messages instead of just saying “failed”. Not all users are savvy enough to strace the process to figure out that the device is busy.
  • vonkil wrote:

    Thanks Alex, looks like the Nordic board comes up in OSX. However, one still has to manually select the device with "selemu" with no arguments and then select (say) zero. The "selemu 0" command does not work.


    Actually, the argument is just the interfaces to seach on, not the number itself. I don't know the syntax for an interface, or even what an interface is in this context, since this is unspecified in the documentation.

    It would actually be very nice if the syntax could be modified to allow the parameter as an argument somehow, though. This way, it could be put in a script. I just tested putting selemu in a JLink script, and just adding “0” on the next line didn't work. It just prompted me for a number.
  • Hi,

    Thanks Alex, looks like the Nordic board comes up in OSX. However, one still has to manually select the device with "selemu" with no arguments and then select (say) zero. The "selemu 0" command does not work

    I do not know what you mean...
    If you have one J-Link connected to the Mac (e.g. the J-Link OB on the NordicSemi board), J-Link Commander will automatically connect to it. No need of any additional commands.

    Actually, the argument is just the interfaces to seach on, not the number itself. I don't know the syntax for an interface, or even what an interface is in this context, since this is unspecified in the documentation.

    Seems there is some lack of documentation here.
    [Interface] means the host interfaces to search on for J-Links.
    Currently supported host interfaces: USB, IP

    Sample: selemu usb // Only shows emulators that are connected to the host via USB
    Sample: selemu ip // only shows emulators that are connected to the host via IP

    To select a specific emulator to connect to at startup of J-Link Commander (see chapter 3.2.1.1 of UM08001):

    C Source Code

    1. JLinkExe -SelectEmuBySN 580011111 // Connect to J-Link with serial number 580011111
    2. JLinkExe -IP 192.168.1.17 // Connect to J-Link with IP 192.168.1.17 via ethernet.


    NOTE: Having multiple J-Links connected via USB to the same PC at the same time is currently supported under Windows only. For Mac/Linux this is officially not supported yet (has not been fully tested).


    Best regards
    Alex
  • Yes, it's true I am unfamiliar with the arguments accepted by the JLinkExe application. One cannot even get a list of this arguments with "JLinkExe --help", and I was unable to find an exhaustive list of possible arguments (only a few appear to be listed in UM08003).

    However, my original point stands. On OSX, with no arguments the board is not found.

    Source Code

    1. $ ./JLinkExe
    2. SEGGER J-Link Commander V4.59d ('?' for help)
    3. Compiled Jan 7 2013 19:12:12
    4. Can not connect to J-Link via USB.
    5. J-Link>selemu
    6. J-Link[0]: Connection: USB, Serial number: 0, USB address: -257
    7. Select emulator index: 0DLL version V4.59d, compiled Jan 7 2013 19:12:09
    8. Firmware: J-Link OB-SAM3U128 V1 compiled Jan 7 2013 18:12:29
    9. Hardware: V1.00
    10. S/N: 480200656
    11. VTarget = 3.300V
    12. Info: Could not measure total IR len. TDO is constant high.
    13. Info: Could not measure total IR len. TDO is constant high.
    14. No devices found on JTAG chain. Trying to find device on SWD.
    15. Info: Found SWD-DP with ID 0x0BB11477
    16. Info: FPUnit: 4 code (BP) slots and 0 literal slots
    17. Info: Found Cortex-M0 r0p0, Little endian.Cortex-M0 identified.
    18. JTAG speed: 100 kHz
    19. J-Link>exit
    Display All



    The same is true when using the '-SelectEmuBySN' argument.

    Source Code

    1. $ ./JLinkExe -SelectEmuBySN 480200656
    2. SEGGER J-Link Commander V4.59d ('?' for help)
    3. Compiled Jan 7 2013 19:12:12
    4. Could not find emulator with USB serial number 480200656.
    5. J-Link>selemu
    6. J-Link[0]: Connection: USB, Serial number: 0, USB address: -257
    7. Select emulator index: 0
    8. DLL version V4.59d, compiled Jan 7 2013 19:12:09
    9. Firmware: J-Link OB-SAM3U128 V1 compiled Jan 7 2013 18:12:29
    10. Hardware: V1.00
    11. S/N: 480200656
    12. VTarget = 3.300V
    13. Info: Could not measure total IR len. TDO is constant high.
    14. Info: Could not measure total IR len. TDO is constant high.
    15. No devices found on JTAG chain. Trying to find device on SWD.
    16. Info: Found SWD-DP with ID 0x0BB11477
    17. Info: FPUnit: 4 code (BP) slots and 0 literal slots
    18. Info: Found Cortex-M0 r0p0, Little endian.
    19. Cortex-M0 identified.
    20. JTAG speed: 100 kHz
    21. J-Link>exit
    Display All



    As you can see, there appears to be some trouble in determining the serial number at the USB level.

    Thanks,
    Chris Kilgour
  • Linux version of JLinkExe

    SEGGER - Alex wrote:

    The problem has been fixed in V4.59d of the Mac OS X version.
    A new Linux version will follow within the next days.
    Hi Alex,

    Please post a message as soon as the Linux version is available. I just discovered this forum, and I too have been wrestling for some time trying to get JLink to work natively on Linux to connect to a Nordic nRF51822 evaluation board. I also have been trying to get it to work with Windows Vista (running as a QEMU guest) to no avail. In that case I suppose the problem can be either on the Linux side or the Windows side.

    Thanks.

    --ken
  • SEGGER - Alex wrote:


    The problem has been fixed in V4.59d of the Mac OS X version.
    A new Linux version will follow within the next days.


    That's great! However, I still seem to have some problems connecting to the board under OS X. Where Chris Kilgour got this:

    vonkil wrote:


    Source Code

    1. $ ./JLinkExe
    2. SEGGER J-Link Commander V4.59d ('?' for help)
    3. Compiled Jan 7 2013 19:12:12
    4. Can not connect to J-Link via USB.
    5. J-Link>selemu
    6. J-Link[0]: Connection: USB, Serial number: 0, USB address: -257
    7. Select emulator index: 0DLL version V4.59d, compiled Jan 7 2013 19:12:09
    8. Firmware: J-Link OB-SAM3U128 V1 compiled Jan 7 2013 18:12:29
    9. Hardware: V1.00
    10. S/N: 480200656
    11. VTarget = 3.300V
    12. Info: Could not measure total IR len. TDO is constant high.
    13. Info: Could not measure total IR len. TDO is constant high.
    14. No devices found on JTAG chain. Trying to find device on SWD.
    15. Info: Found SWD-DP with ID 0x0BB11477
    16. Info: FPUnit: 4 code (BP) slots and 0 literal slots
    17. Info: Found Cortex-M0 r0p0, Little endian.Cortex-M0 identified.
    18. JTAG speed: 100 kHz
    19. J-Link>exit
    Display All



    I get this:

    Source Code

    1. knuta@knuta-mbp ~/JLink_MacOSX_V459d $ ./JLinkExe.command
    2. SEGGER J-Link Commander V4.59d ('?' for help)
    3. Compiled Jan 7 2013 19:12:12
    4. Can not connect to J-Link via USB.
    5. J-Link>selemu
    6. J-Link[0]: Connection: USB, Serial number: 0, USB address: -257
    7. Select emulator index: 0
    8. DLL version V4.59d, compiled Jan 7 2013 19:12:09
    9. Firmware: J-Link OB-SAM3U128 V1 compiled Jan 7 2013 18:12:29
    10. Hardware: V1.00
    11. S/N: (redacted)
    12. VTarget = 3.300V
    13. Info: Could not measure total IR len. TDO is constant high.
    14. Info: Could not measure total IR len. TDO is constant high.
    15. No devices found on JTAG chain. Trying to find device on SWD.
    16. Info: Found SWD-DP with ID 0x0BB11477
    17. Info: Found SWD-DP with ID 0x0BB11477
    18. No device found on SWD.
    19. Did not find any core.
    20. Failed to identify target. Trying again with slow (4 kHz) speed.
    21. Info: Could not measure total IR len. TDO is constant high.
    22. Info: Could not measure total IR len. TDO is constant high.
    23. No devices found on JTAG chain. Trying to find device on SWD.
    24. Info: Found SWD-DP with ID 0x0BB11477
    25. Info: Found SWD-DP with ID 0x0BB11477
    26. No device found on SWD.
    27. Did not find any core.
    Display All


    I'm not sure what is different between mine and Chris' setup, but I doubt my board is broken because it works fine from Windows Vista. I am using a 15" MacBook Pro with Retina Display running OS X Mountain Lion, in case that matters. My libusb is the latest from MacPorts.
  • Hi,

    That's great! However, I still seem to have some problems connecting to the board under OS X. Where Chris Kilgour got this:

    The nRF51 from NordicSemi needs special handling, so J-Link needs to know the device.
    Please try again with the following command sequence (without quotes):

    "si 1" // Select SWD as interface
    "device nRF51822"


    Best regards
    Alex
  • Linux version of JLinkExe

    Hello Alex,

    Just checking on the status of the Linux version of JLinkExe. I would be happy to volunteer to do whatever testing on it I can do for you--I'm using gentoo on an x86_64 platform.

    I've attached an strace of JLinkExe startup on my machine; maybe it can help. It opens the Segger device on the USB interface and then appears to get stuck attempting to complete a USBDEVFS_SUBMITURB system call.

    --ken
    Files
    • JLinkExe.txt

      (38.57 kB, downloaded 1,507 times, last: )
  • RAMCode for nRF51822?

    Hello,

    I am using the JLink Commander V4.60 for Mac OSX. Below is my attempt to program an nRF51822. If I don't specify "device nRF51822", nothing is written to memory when I execute loadbin. If I specify "device nRF51822", then memory is written to but I get the error "****** Error: Failed to prepare for programming. Failed to execute RAMCode for RAM check!" Has anyone successfully use J-Link Commander to load the soft_device into memory starting at address 0x00000, program code starting at 0x20000, and successfully run a BLE program on the nRF51822?

    Here's a full account of my J-Link Commander session.

    C Source Code

    1. SEGGER J-Link Commander V4.60 ('?' for help)
    2. Compiled Jan 14 2013 10:51:35
    3. DLL version V4.60, compiled Jan 14 2013 10:51:31
    4. Firmware: J-Link Pro V4 compiled Nov 19 2012 15:15:02
    5. Hardware: V4.00
    6. S/N: 174200017
    7. Feature(s): RDI, FlashBP, FlashDL, JFlash, GDB
    8. VTarget = 1.864V
    9. Info: Found SWD-DP with ID 0x0BB11477
    10. Info: FPUnit: 4 code (BP) slots and 0 literal slots
    11. Info: Found Cortex-M0 r0p0, Little endian.
    12. Found 1 JTAG device, Total IRLen = 4:
    13. Cortex-M0 identified.
    14. JTAG speed: 100 kHz
    15. J-Link>h
    16. R0 = FFFFFFFF, R1 = FFFFFFFF, R2 = FFFFFFFF, R3 = FFFFFFFF
    17. R4 = FFFFFFFF, R5 = FFFFFFFF, R6 = FFFFFFFF, R7 = FFFFFFFF
    18. R8 = FFFFFFFF, R9 = FFFFFFFF, R10= FFFFFFFF, R11= FFFFFFFF
    19. R12= FFFFFFFF, R13= FFFFFFFC, MSP= FFFFFFFC, PSP= FFFFFFFC
    20. R14(LR) = FFFFFFFF, R15(PC) = FFFFFFFE
    21. XPSR = C1000000, APSR = C0000000, EPSR = 01000000, IPSR = 00000000
    22. CFBP = 00000000, CONTROL = 00, FAULTMASK = 00, BASEPRI = 00, PRIMASK = 00
    23. CycleCnt = 00000000
    24. J-Link>loadbin /Users/roy/Documents/hello/firmware-band/S110_nRF51822_3.0.0-1.beta_softdevice.hex 0x0000
    25. Loading binary file... [/Users/roy/Documents/hello/firmware-band/S110_nRF51822_3.0.0-1.beta_softdevice.hex]
    26. Writing bin data into target memory @ 0x00000000.
    27. J-Link>mem 0x00000 10
    28. 00000000 = FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    29. J-Link>device nRF51822
    30. Info: Device "NRF51822" selected (256 KB flash, 8 KB RAM).
    31. Reconnecting to target...
    32. Info: Found SWD-DP with ID 0x0BB11477
    33. Info: FPUnit: 4 code (BP) slots and 0 literal slots
    34. Info: Found Cortex-M0 r0p0, Little endian.
    35. J-Link>h
    36. R0 = FFFFFFFF, R1 = FFFFFFFF, R2 = FFFFFFFF, R3 = FFFFFFFF
    37. R4 = FFFFFFFF, R5 = FFFFFFFF, R6 = FFFFFFFF, R7 = FFFFFFFF
    38. R8 = FFFFFFFF, R9 = FFFFFFFF, R10= FFFFFFFF, R11= FFFFFFFF
    39. R12= FFFFFFFF, R13= FFFFFFFC, MSP= FFFFFFFC, PSP= FFFFFFFC
    40. R14(LR) = FFFFFFFF, R15(PC) = FFFFFFFE
    41. XPSR = C1000000, APSR = C0000000, EPSR = 01000000, IPSR = 00000000
    42. CFBP = 00000000, CONTROL = 00, FAULTMASK = 00, BASEPRI = 00, PRIMASK = 00
    43. CycleCnt = 00000000
    44. J-Link>h
    45. R0 = FFFFFFFF, R1 = FFFFFFFF, R2 = FFFFFFFF, R3 = FFFFFFFF
    46. R4 = FFFFFFFF, R5 = FFFFFFFF, R6 = FFFFFFFF, R7 = FFFFFFFF
    47. R8 = FFFFFFFF, R9 = FFFFFFFF, R10= FFFFFFFF, R11= FFFFFFFF
    48. R12= FFFFFFFF, R13= FFFFFFFC, MSP= FFFFFFFC, PSP= FFFFFFFC
    49. R14(LR) = FFFFFFFF, R15(PC) = FFFFFFFE
    50. XPSR = C1000000, APSR = C0000000, EPSR = 01000000, IPSR = 00000000
    51. CFBP = 00000000, CONTROL = 00, FAULTMASK = 00, BASEPRI = 00, PRIMASK = 00
    52. CycleCnt = 00000000
    53. J-Link>loadbin /Users/roy/Documents/hello/firmware-band/S110_nRF51822_3.0.0-1.beta_softdevice.hex 0x0000
    54. Loading binary file... [/Users/roy/Documents/hello/firmware-band/S110_nRF51822_3.0.0-1.beta_softdevice.hex]
    55. Writing bin data into target memory @ 0x00000000.
    56. ****** Error: Failed to prepare for programming.
    57. Failed to execute RAMCode for RAM check!
    Display All
  • knuta wrote:


    Source Code

    1. knuta@knuta-mbp ~/JLink_MacOSX_V459d $ ./JLinkExe.command
    2. SEGGER J-Link Commander V4.59d ('?' for help)
    3. Compiled Jan 7 2013 19:12:12
    4. Can not connect to J-Link via USB.
    5. J-Link>selemu
    6. J-Link[0]: Connection: USB, Serial number: 0, USB address: -257
    7. Select emulator index: 0
    8. DLL version V4.59d, compiled Jan 7 2013 19:12:09
    9. Firmware: J-Link OB-SAM3U128 V1 compiled Jan 7 2013 18:12:29
    10. Hardware: V1.00
    11. S/N: (redacted)
    12. VTarget = 3.300V
    13. Info: Could not measure total IR len. TDO is constant high.
    14. Info: Could not measure total IR len. TDO is constant high.
    15. No devices found on JTAG chain. Trying to find device on SWD.
    16. Info: Found SWD-DP with ID 0x0BB11477
    17. Info: Found SWD-DP with ID 0x0BB11477
    18. No device found on SWD.
    19. Did not find any core.
    20. Failed to identify target. Trying again with slow (4 kHz) speed.
    21. Info: Could not measure total IR len. TDO is constant high.
    22. Info: Could not measure total IR len. TDO is constant high.
    23. No devices found on JTAG chain. Trying to find device on SWD.
    24. Info: Found SWD-DP with ID 0x0BB11477
    25. Info: Found SWD-DP with ID 0x0BB11477
    26. No device found on SWD.
    27. Did not find any core.
    Display All



    For what it's worth, this still happens on version 4.60 as well. As mentioned, this is OS X Mountain Lion, and libusb is the latest from macports. I have also verified that the board still works under Windows Vista, so I doubt it is hardware error. Is there anything I could do to try to determine what the cause is?