CLI terminal connection to nrf52840 DK

Hi,

I want to know how to connect to nrf52840 DK using CLI. So no GUI!!

I'm using a headless computer (Raspberry Pi) to do automatic test cases. It needs to send commands to the nrf52840 DK.
So I was looking into pytest or something similar. But it looks like I can only use JLink but it doesn't work?!

This is what I get using JLink:

pi@raspberrypi:/opt/SEGGER/JLink $ sudo ./JLinkExe -NoGUI 1
SEGGER J-Link Commander V7.80c (Compiled Sep 27 2022 16:10:59)
DLL version V7.80c, compiled Sep 27 2022 16:10:35

Connecting to J-Link via USB...O.K.
Firmware: J-Link OB-nRF5340-NordicSemi compiled Nov  7 2022 16:22:01
Hardware version: V1.00
J-Link uptime (since boot): 0d 07h 28m 25s
S/N: *******
USB speed mode: Full speed (12 MBit/s)
VTref=3.300V


Type "connect" to establish a target connection, '?' for help
J-Link>connect
Please specify device / core. <Default>: Unspecified
Type '?' for selection dialog
Device>nrf52840
Please specify target interface:
  J) JTAG (Default)
  S) SWD
  F) FINE
  I) ICSP
  C) C2
  T) cJTAG
TIF>
Device position in JTAG chain (IRPre,DRPre) <Default>: -1,-1 => Auto-detect
JTAGConf>
Specify target interface speed [kHz]. <Default>: 4000 kHz
Speed>
./JLinkGUIServerExe: error while loading shared libraries: libSM.so.6: cannot open shared object file: No such file or directory
No valid device has been selected.
J-Link>

The device is listed:

/dev/serial/by-id/usb-SEGGER_J-Link_000*******-if00


The reason there are no X libraries installed on the Raspberry Pi is because the OS needs to remain small and fast recoverable.
Also there is no reason to have X like software installed on a headless machine.

So I want to know how to use pytest or something similar to communicate with the nrf52840 DK using CLI only?

  • Hi,

    The nRF52840 does not have a JTAG interface, SWD should be selected when you are asked to "specify target interface".

    I'm not sure if this is the root cause of your issue, but I would recommend you to contact SEGGER support directly if it does not resolve your problem (https://forum.segger.com/). JLink is their software and not something Nordic have deep knowledge of.

    Best regards,
    Jørgen

  • Hi,

    I have asked the same question on the Segger forum and their feedback has helped me figure things out.

    JLink will start the GUI when the device parameter is unspecified.
    To prevent this, device has to be specified, for example:

    -device NRF52840_xxAA

    Then it will not start the GUI. Also there are some other JLink* programs (in the same folder) that will use the -device parameter/argument.

    Regarding interacting with the DK board over USB, I figured out that JLink software is actually not needed.
    You only need to have a sample program on the DK that enables the serial interface (such as hello world for example).
    Then on the Raspberry Pi I used the program minicom to connect to the DK, and it prints the output just fine. You can also use other serial programs like screen or use the fopen() function in C.

    Best regards,

    ephimee

Related