Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Example that logs over Segger RTT requiring no configuration changes by me

I'm trying to get debug output to appear in my Segger J-LINK SWO viewer (from an NR52840 SDK board with NRF5 v16) which I understand is a potentially complicated process; I've received nothing in the SWO viewer so far.  Do you have an example which sends debug output to Segger RTT by default, without me screwing anything up, i.e. all I have to do is make flash, just so that I can check that the connection and the Segger tools are good (not that there's much that can go wrong with them)?

FYI, in my sdk_config.h I have NRF_LOG_ENABLED 1,  NRF_LOG_BACKEND_RTT_ENABLED 1, NRF_LOG_BACKEND_UART_ENABLED 0NRF_LOG_DEFERRED 0 and NRF_LOG_DEFAULT_LEVEL 3 and in main.c I start with:

NRF_LOG_INIT(NULL);
NRF_LOG_DEFAULT_BACKENDS_INIT();

NRF_LOG_INFO("Hello world.\n");

In the Segger SWO viewer I've selected nRF52840_xxAA, let it measure the clock, selected channel 0, the green LED near the PCA10056 on the board is flashing regularly and I pressed the reset button on the board. Nada.

Oh, and I also have the defaults for the Segger RTT settings, i.e.:

#define SEGGER_RTT_CONFIG_BUFFER_SIZE_UP 512
#define SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS 2
#define SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN 16
#define SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS 2
#define SEGGER_RTT_CONFIG_DEFAULT_MODE 0

Rob

Parents
  • I've generally had more success with the RTTClient. Could you try that as well? I have included some screenshots below to show how I tested it here. We do not have any examples for SWO that I'm aware of. I'm actually not sure if this output is even available on the Jlink lite we have on our DKs. I will find out if you are interested.

    RTT viewer:

    RTT Client:

Reply
  • I've generally had more success with the RTTClient. Could you try that as well? I have included some screenshots below to show how I tested it here. We do not have any examples for SWO that I'm aware of. I'm actually not sure if this output is even available on the Jlink lite we have on our DKs. I will find out if you are interested.

    RTT viewer:

    RTT Client:

Children
  • Yes, I would be interested in SWO I think, seems simpler for me.

    I did have auto-detect on in the RTT Viewer.  Just did what you suggested and started JLink in one DOS box:

    Connecting to target via SWD
    Found SW-DP with ID 0x2BA01477
    Found SW-DP with ID 0x2BA01477
    Scanning AP map to find all available APs
    AP[2]: Stopped AP scan as end of AP map has been reached
    AP[0]: AHB-AP (IDR: 0x24770011)
    AP[1]: JTAG-AP (IDR: 0x02880000)
    Iterating through AP map to find AHB-AP to use
    AP[0]: Core found
    AP[0]: AHB-AP ROM base: 0xE00FF000
    CPUID register: 0x410FC241. Implementer code: 0x41 (ARM)
    Found Cortex-M4 r0p1, Little endian.
    FPUnit: 6 code (BP) slots and 2 literal slots
    CoreSight components:
    ROMTbl[0] @ E00FF000
    ROMTbl[0][0]: E000E000, CID: B105E00D, PID: 000BB00C SCS-M7
    ROMTbl[0][1]: E0001000, CID: B105E00D, PID: 003BB002 DWT
    ROMTbl[0][2]: E0002000, CID: B105E00D, PID: 002BB003 FPB
    ROMTbl[0][3]: E0000000, CID: B105E00D, PID: 003BB001 ITM
    ROMTbl[0][4]: E0040000, CID: B105900D, PID: 000BB9A1 TPIU
    ROMTbl[0][5]: E0041000, CID: B105900D, PID: 000BB925 ETM
    Cortex-M4 identified.
    J-Link>g
    
    **************************
    WARNING: T-bit of XPSR is 0 but should be 1. Changed to 1.
    **************************
    
    J-Link>r
    Reset delay: 0 ms
    Reset type NORMAL: Resets core & peripherals via SYSRESETREQ & VECTRESET bit.
    Reset: Halt core after reset via DEMCR.VC_CORERESET.
    Reset: Reset device via AIRCR.SYSRESETREQ.
    J-Link>

    ...but when I start jlinkrttclient in another window it looks the same as yours except no debug is printed below it:

    C:\Program Files (x86)\SEGGER\JLink_V641a>jlinkrttclient
    ###RTT Client: ************************************************************
    ###RTT Client: *               SEGGER Microcontroller GmbH                *
    ###RTT Client: *   Solutions for real time microcontroller applications   *
    ###RTT Client: ************************************************************
    ###RTT Client: *                                                          *
    ###RTT Client: *       (c) 2012 - 2016  SEGGER Microcontroller GmbH       *
    ###RTT Client: *                                                          *
    ###RTT Client: *     www.segger.com     Support: [email protected]       *
    ###RTT Client: *                                                          *
    ###RTT Client: ************************************************************
    ###RTT Client: *                                                          *
    ###RTT Client: * SEGGER J-Link RTT Client   Compiled Nov 27 2018 14:10:37 *
    ###RTT Client: *                                                          *
    ###RTT Client: ************************************************************
    
    ###RTT Client: -----------------------------------------------
    ###RTT Client: Connecting to J-Link RTT Server via localhost:19021  Connected.
    SEGGER J-Link V6.41a (beta) - Real time terminal output
    J-Link OB-SAM3U128-V2-NordicSemi compiled Jan 21 2020 17:30:48 V1.0, SN=683253856
    Process: JLink.exe
    

    This is with the ble_peripheral build still on the NRF52840 DK board.  What am I doing wrong?

  • Ooo!  Belay that, I just built and download my own build to my board and J-Link RTT client suddenly burst into life:

    <info> app: Hello world.
    
    <info> app: CELLULAR_PORT_TEST: tick time now is 0.
    
    <info> app: CELLULAR_PORT_TEST: creating a mutex...
    
    <info> app:                     returned error code 0, handle 0x20000978.
    
    <info> app: CELLULAR_PORT_TEST: creating a queue...
    
    <info> app:                     returned error code 0, handle 0x200009c0.
    
    <info> app: CELLULAR_PORT_TEST: creating a test task with stack 2048 byte(s) and priority 12, passing it the pointer 0x20000220 containing

    Obviously I'm doing something right, just need to figure out the sequence.  Thanks for your help, if you have anything on using SWO then do let me know.

  • Hmmm.  Haven't been able to do it again though.  Any hints on reliability?  I've tried reducing the speed from 4000 kHz to 1000 kHz but that doesn't seem to have helped.

  • It seems to work only the first time after JLink connects.  If I do a reset (pressing 'r' in JLink commander, or pressing the reset button on the board) nothing more comes out; I have to restart JLink commander and then does stuffs appear in the RTT viewer once more.

    Any clues as to why that might be?

  • No, even that's not consistent, it just seems to be unreliable.

Related