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

RTT Logging not working when building with ARM GCC

Hi,

I'm trying to use RTT Logging in my application. If I build and flash my application through Segger Embedded Studio RTT logging works. However If I use ARM GCC to build the application and nrfjprog to flash RTT logging does not work. 

NRF_LOG and BACKEND_RTT is enabled in my sdk_config.h and I'm doing the following calls in main:

APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
NRF_LOG_DEFAULT_BACKENDS_INIT();


For ARM GCC I'm using the generic linker file inside the SDK folder config/nrf52840/generic_gcc_nrf52.ld, with a slight modification to the RAM_START and RAM_SIZE to allow for multiple connections. 

Are there any more modifications that needs to be done in order to enable RTT Logging when using ARM GCC? 

As a side note: UART Backend logging works without any issues when I build with ARM GCC

board: nRF52840 Preview DK

SDK: v15

Softdevice: 6.0.0

Br,
Anton

Parents
  • Hi,

    Which version of ARM GCC do you use? We have seen issues with ARM GCC 7.x.x and link time optimization (LTO). (Therefor, the SDK is still tested using version 6.3.1).

  • One more thing I forgot to mention in the original post is that before I changed the RAM_START and RAM_SIZE the RTT output worked. However then the application doesn't work since there is not enough memory for the softdevice. 

  • OK, I see. So probably there is not enough available RAM for the RTT buffer? But then I would have expected you to see a linker error. Does the map file tell you anything useful?

  • 8132.nrf52840_xxaa.map
    I've tried to look through, although I'm not quite sure what do look for. I have uploaded the file in my answer. Perhaps you can see something?

  • Here is the part relating to Segger RTT

     .text.SEGGER_RTT_ReadNoLock
                    0x0000000000000000      0x100 _build/nrf52840_xxaa/SEGGER_RTT.c.o
     .text.SEGGER_RTT_Read
                    0x0000000000000000      0x110 _build/nrf52840_xxaa/SEGGER_RTT.c.o
     .text.SEGGER_RTT_WriteWithOverwriteNoLock
                    0x0000000000000000       0xe8 _build/nrf52840_xxaa/SEGGER_RTT.c.o
     .text.SEGGER_RTT_WriteSkipNoLock
                    0x0000000000000000       0xa0 _build/nrf52840_xxaa/SEGGER_RTT.c.o
     .text.SEGGER_RTT_Write
                    0x0000000000000000      0x1f4 _build/nrf52840_xxaa/SEGGER_RTT.c.o
     .text.SEGGER_RTT_WriteString
                    0x0000000000000000      0x1f8 _build/nrf52840_xxaa/SEGGER_RTT.c.o
     .text.SEGGER_RTT_PutCharSkipNoLock
                    0x0000000000000000       0x40 _build/nrf52840_xxaa/SEGGER_RTT.c.o
     .text.SEGGER_RTT_PutCharSkip
                    0x0000000000000000       0xb8 _build/nrf52840_xxaa/SEGGER_RTT.c.o
     .text.SEGGER_RTT_PutChar
                    0x0000000000000000       0xd4 _build/nrf52840_xxaa/SEGGER_RTT.c.o
     .text.SEGGER_RTT_GetKey
                    0x0000000000000000      0x104 _build/nrf52840_xxaa/SEGGER_RTT.c.o
     .text.SEGGER_RTT_WaitKey
                    0x0000000000000000      0x124 _build/nrf52840_xxaa/SEGGER_RTT.c.o
     .text.SEGGER_RTT_HasKey
                    0x0000000000000000       0x6c _build/nrf52840_xxaa/SEGGER_RTT.c.o
     .text.SEGGER_RTT_HasData
                    0x0000000000000000       0x18 _build/nrf52840_xxaa/SEGGER_RTT.c.o
     .text.SEGGER_RTT_AllocDownBuffer
                    0x0000000000000000       0xc4 _build/nrf52840_xxaa/SEGGER_RTT.c.o
     .text.SEGGER_RTT_AllocUpBuffer
                    0x0000000000000000       0xcc _build/nrf52840_xxaa/SEGGER_RTT.c.o
     .text.SEGGER_RTT_ConfigUpBuffer
                    0x0000000000000000       0xdc _build/nrf52840_xxaa/SEGGER_RTT.c.o
     .text.SEGGER_RTT_ConfigDownBuffer
                    0x0000000000000000       0xbc _build/nrf52840_xxaa/SEGGER_RTT.c.o
     .text.SEGGER_RTT_SetNameUpBuffer
                    0x0000000000000000       0x98 _build/nrf52840_xxaa/SEGGER_RTT.c.o
     .text.SEGGER_RTT_SetNameDownBuffer
                    0x0000000000000000       0x98 _build/nrf52840_xxaa/SEGGER_RTT.c.o
     .text.SEGGER_RTT_SetFlagsUpBuffer
                    0x0000000000000000       0x98 _build/nrf52840_xxaa/SEGGER_RTT.c.o
     .text.SEGGER_RTT_SetFlagsDownBuffer
                    0x0000000000000000       0x98 _build/nrf52840_xxaa/SEGGER_RTT.c.o
     .text.SEGGER_RTT_SetTerminal
                    0x0000000000000000      0x160 _build/nrf52840_xxaa/SEGGER_RTT.c.o
     .text.SEGGER_RTT_TerminalOut
                    0x0000000000000000      0x408 _build/nrf52840_xxaa/SEGGER_RTT.c.o
     .bss._ActiveTerminal
                    0x0000000000000000        0x1 _build/nrf52840_xxaa/SEGGER_RTT.c.o
     .rodata._aTerminalId
                    0x0000000000000000       0x10 _build/nrf52840_xxaa/SEGGER_RTT.c.o

  • Hi,

    I have no explanation at this point, and I do not recall ever seeing this issue earlier. A few additional questions:

    • Can you confirm that  you use JLinkRTTViewer.exe to view the logs?
    • Does it have any effect if you disable UART logging (so that you only have RTT logging enabled)?
    • How have you configured the RTT viewer? It should look similar to this:

     

Reply Children
  • Hi,

    • Can you confirm that  you use JLinkRTTViewer.exe to view the logs? No, I'm on Linux so I use JLinkExe and JLinkRTTClient to view the logs. When connecting using JLinkExe I use SWD as the interface
    • Does it have any effect if you disable UART logging (so that you only have RTT logging enabled)? No, I have disabled UART Logging but still no RTT Logs
    • How have you configured the RTT viewer? When using JLinkExe the only option I select is SWD as the interface and then default the rest of selection. This configuration has worked previously.
  • Hi,

    JLinkExe and JLinkRTTClient should work out of the box and you got it working previously, so this should not be related then. This is puzzling, and have asked around the office, but one of those I talked to had seen this behaviour earlier. Do you get any errors or other interesting logs from JLinkExe or JLinkRTTClient?

  • Here is the output when connecting to the device using JLinkExe:

    Type "connect" to establish a target connection, '?' for help
    J-Link>connect
    Please specify device / core. <Default>: NRF52832_XXAA
    Type '?' for selection dialog
    Device>
    Please specify target interface:
      J) JTAG (Default)
      S) SWD
      T) cJTAG
    TIF>S
    Specify target interface speed [kHz]. <Default>: 4000 kHz
    Speed>
    Device "NRF52832_XXAA" selected.
    
    
    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>


    And RTTClient:
    ###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 Aug  8 2018 16:32:02 * 
    ###RTT Client: *                                                          * 
    ###RTT Client: ************************************************************ 
    
    ###RTT Client: -----------------------------------------------
    ###RTT Client: Connecting to J-Link RTT Server via localhost:19021  Connected.
    SEGGER J-Link V6.34a - Real time terminal output
    J-Link OB-SAM3U128-V2-NordicSemi compiled Jul 12 2018 11:44:41 V1.0, SN=683356885
    Process: nrfjprog
    ###RTT Client: Connection closed by J-Link DLL. Going to reconnect.
    ###RTT Client: Connecting to J-Link RTT Server via localhost:19021 .. Connected.
    SEGGER J-Link V6.34a - Real time terminal output
    J-Link OB-SAM3U128-V2-NordicSemi compiled Jul 12 2018 11:44:41 V1.0, SN=683356885
    Process: nrfjprog
    ###RTT Client: Connection closed by J-Link DLL. Going to reconnect.
    ###RTT Client: Connecting to J-Link RTT Server via localhost:19021 .................... Connected.
    SEGGER J-Link V6.34a - Real time terminal output
    J-Link OB-SAM3U128-V2-NordicSemi compiled Jul 12 2018 11:44:41 V1.0, SN=683356885
    Process: JLinkExe
    
    



  • These are the values I use for RAM START and RAM SIZE, according to the output from the softdevice enable function:

    RAM (rwx) :  ORIGIN = 0x20015290, LENGTH = 0x2AD70


    Perhaps we should see if we can reproduce the issue from an example project?

  • Hi,

    Have you verified that the application is running in the first place? If not, I wonder if this issue is not related to RTT at all, but that you forgot to flash the SoftDevice? When you upload a BLE project from SES it will also upload the SoftDevice automatically, but if you use GCC you have to do it explicitly (either using nrfjprog manually or calling "make flash_softdevice" if you are using an SDK example Makefile).

Related