This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

RTT & NRF_LOG_ENABLED=0

Hello,

We use SEGGER_RTT_ReadNoLock() in our code, and this works perfectly. Our nRF is connected to a DK, which is connected to a computer.

However, when we compile with NRF_LOG_ENABLED=0, RTT isn't working anymore. It is a bit hard to know what's going on since JLinkExe doesn't seem to notive.

I suspect there is a relationship between the two, since we also use logging over RTT (SWD) to debug; but I did not find a way to fix it.

Would you have any ideas? Maybe other flags to set/unset?C

Thank you very much.

  • Hi John,

    Could you provide the build output log and a screenshot showing any errors.?

    Kind Regards,

    Swathy

  • Here are two screenshots. I send data via JLinkRTTViewer.

    In the first case, logs are enabled and the bytes are sent.

    In the second case, logs are disabled and a warning appears.

    Here are the build logs while compiling with DNRF_LOG_ENABLED=0.

    cd _build && mkdir nrf52832_xxaa
    Compiling file: main.c
    Compiling file: ble_advertising.c
    Compiling file: ble_link_ctx_manager.c
    Compiling file: ble_nus.c
    Compiling file: ble_advdata.c
    Compiling file: ble_conn_params.c
    Compiling file: ble_conn_state.c
    Compiling file: ble_srv_common.c
    Compiling file: nrf_ble_gatt.c
    Compiling file: nrf_ble_qwr.c
    Compiling file: auth_status_tracker.c
    Compiling file: gatt_cache_manager.c
    Compiling file: gatts_cache_manager.c
    Compiling file: id_manager.c
    Compiling file: nrf_ble_lesc.c
    Compiling file: peer_data_storage.c
    Compiling file: peer_database.c
    Compiling file: peer_id.c
    Compiling file: peer_manager.c
    Compiling file: peer_manager_handler.c
    Compiling file: pm_buffer.c
    Compiling file: security_dispatcher.c
    Compiling file: security_manager.c
    Compiling file: boards.c
    Compiling file: nrf_atomic.c
    Compiling file: nrf_atfifo.c
    Compiling file: nrf_atflags.c
    Compiling file: nrf_balloc.c
    Compiling file: bsp.c
    Compiling file: bsp_btn_ble.c
    Compiling file: app_button.c
    Compiling file: crc16.c
    Compiling file: nrf_hw_backend_init.c
    Compiling file: nrf_hw_backend_rng.c
    Compiling file: nrf_hw_backend_rng_mbedtls.c
    Compiling file: oberon_backend_chacha_poly_aead.c
    Compiling file: oberon_backend_ecc.c
    Compiling file: oberon_backend_ecdh.c
    Compiling file: oberon_backend_ecdsa.c
    Compiling file: oberon_backend_eddsa.c
    Compiling file: oberon_backend_hash.c
    Compiling file: oberon_backend_hmac.c
    Compiling file: nrf_crypto_aead.c
    Compiling file: nrf_crypto_aes.c
    Compiling file: nrf_crypto_aes_shared.c
    Compiling file: nrf_crypto_ecc.c
    Compiling file: nrf_crypto_ecdh.c
    Compiling file: nrf_crypto_ecdsa.c
    Compiling file: nrf_crypto_eddsa.c
    Compiling file: nrf_crypto_error.c
    Compiling file: nrf_crypto_hash.c
    Compiling file: nrf_crypto_hkdf.c
    Compiling file: nrf_crypto_hmac.c
    Compiling file: nrf_crypto_init.c
    Compiling file: nrf_crypto_rng.c
    Compiling file: nrf_crypto_shared.c
    Compiling file: nrf_section_iter.c
    Compiling file: fds.c
    Compiling file: nrf_fstorage.c
    Compiling file: nrf_fstorage_sd.c
    Compiling file: hardfault_implementation.c
    Compiling file: nrf_log_backend_rtt.c
    Compiling file: nrf_log_backend_serial.c
    Compiling file: nrf_log_backend_uart.c
    Compiling file: nrf_log_default_backends.c
    Compiling file: nrf_log_frontend.c
    Compiling file: nrf_log_str_formatter.c
    Compiling file: mem_manager.c
    Compiling file: nrf_memobj.c
    Compiling file: app_pwm.c
    Compiling file: nrf_pwr_mgmt.c
    Compiling file: nrf_queue.c
    Compiling file: nrf_ringbuf.c
    Compiling file: app_scheduler.c
    Compiling file: nrf_sortlist.c
    Compiling file: nrf_strerror.c
    Compiling file: app_timer2.c
    Compiling file: drv_rtc.c
    Compiling file: app_error.c
    Compiling file: app_error_handler_gcc.c
    Compiling file: app_error_weak.c
    Compiling file: app_util_platform.c
    Compiling file: nrf_assert.c
    Compiling file: nrf_sdh.c
    Compiling file: nrf_sdh_ble.c
    Compiling file: nrf_sdh_soc.c
    Compiling file: nrf_fprintf.c
    Compiling file: nrf_fprintf_format.c
    Compiling file: aes.c
    Compiling file: ctr_drbg.c
    Compiling file: platform_util.c
    Compiling file: SEGGER_RTT.c
    Compiling file: SEGGER_RTT_Syscalls_GCC.c
    Compiling file: SEGGER_RTT_printf.c
    Compiling file: utf.c
    Compiling file: nrf_drv_clock.c
    Compiling file: nrf_drv_ppi.c
    Compiling file: nrf_drv_rng.c
    Compiling file: nrf_drv_spi.c
    Compiling file: nrf_drv_twi.c
    Compiling file: nrf_drv_uart.c
    Compiling file: nrfx_clock.c
    Compiling file: nrfx_gpiote.c
    Compiling file: nrfx_ppi.c
    Compiling file: nrfx_rng.c
    Compiling file: nrfx_spi.c
    Compiling file: nrfx_spim.c
    Compiling file: nrfx_timer.c
    Compiling file: nrfx_twi.c
    Compiling file: nrfx_uart.c
    Compiling file: nrfx_uarte.c
    Compiling file: nrfx_prs.c
    Assembling file: gcc_startup_nrf52.S
    Compiling file: system_nrf52.c
    Compiling file: nrfx_atomic.c
    Linking target: _build/nrf52832_xxaa.out
       text       data        bss        dec        hex    filename
     243212        964      19248     263424      40500    _build/nrf52832_xxaa.out
    Preparing: _build/nrf52832_xxaa.hex
    Preparing: _build/nrf52832_xxaa.bin
    DONE nrf52832_xxaa


    Flashing the firmware:

    DONE nrf52832_xxaa
    nrfjprog -f nrf52 --program _build/nrf52832_xxaa.hex --sectorerase
    Parsing image file.
    Erasing page at address 0x26000.
    Erasing page at address 0x27000.
    Erasing page at address 0x28000.
    Erasing page at address 0x29000.
    Erasing page at address 0x2A000.
    Erasing page at address 0x2B000.
    Erasing page at address 0x2C000.
    Erasing page at address 0x2D000.
    Erasing page at address 0x2E000.
    Erasing page at address 0x2F000.
    Erasing page at address 0x30000.
    Erasing page at address 0x31000.
    Erasing page at address 0x32000.
    Erasing page at address 0x33000.
    Erasing page at address 0x34000.
    Erasing page at address 0x35000.
    Erasing page at address 0x36000.
    Erasing page at address 0x37000.
    Erasing page at address 0x38000.
    Erasing page at address 0x39000.
    Erasing page at address 0x3A000.
    Erasing page at address 0x3B000.
    Erasing page at address 0x3C000.
    Erasing page at address 0x3D000.
    Erasing page at address 0x3E000.
    Erasing page at address 0x3F000.
    Erasing page at address 0x40000.
    Erasing page at address 0x41000.
    Erasing page at address 0x42000.
    Erasing page at address 0x43000.
    Erasing page at address 0x44000.
    Erasing page at address 0x45000.
    Erasing page at address 0x46000.
    Erasing page at address 0x47000.
    Erasing page at address 0x48000.
    Erasing page at address 0x49000.
    Erasing page at address 0x4A000.
    Erasing page at address 0x4B000.
    Erasing page at address 0x4C000.
    Erasing page at address 0x4D000.
    Erasing page at address 0x4E000.
    Erasing page at address 0x4F000.
    Erasing page at address 0x50000.
    Erasing page at address 0x51000.
    Erasing page at address 0x52000.
    Erasing page at address 0x53000.
    Erasing page at address 0x54000.
    Erasing page at address 0x55000.
    Erasing page at address 0x56000.
    Erasing page at address 0x57000.
    Erasing page at address c0x58000.
    Erasing page at address 0x59000.
    Erasing page at address 0x5A000.
    Erasing page at address 0x5B000.
    Erasing page at address 0x5C000.
    Erasing page at address 0x5D000.
    Erasing page at address 0x5E000.
    Erasing page at address 0x5F000.
    Erasing page at address 0x60000.
    Erasing page at address 0x61000.
    Applying system reset.
    Checking that the area to write is not protected.
    Programming device.
    nrfjprog -f nrf52 --reset
    Applying system reset.
    Run.


    Here is how I use RTT:

            const int bufferIndex = 0;
            if (SEGGER_RTT_HasData(bufferIndex))
            {
                char buf[32];
                int r = SEGGER_RTT_ReadNoLock(bufferIndex, buf, sizeof(buf));
                buf[r - 1] = '\0';
                // do stuff with buf
            }
  • Hi John,

    Could you show me how you initialised RTT?

    Regards,

    Swathy

  • I don't init anything. Should I?

    I simply do the following:

    #include <SEGGER_RTT.h>


    // and in some loop:

            const int bufferIndex = 0;
            if (SEGGER_RTT_HasData(bufferIndex))
            {
                char buf[32];
                int r = SEGGER_RTT_ReadNoLock(bufferIndex, buf, sizeof(buf));
                buf[r - 1] = '\0';
                exec_cmd(buf);
            }
  • Hey john,

    In your case, since you have not initialized RTT anywhere in the program, the RTT is configured properly when you initialize the logger module. Then it is expected that it does not work when NRF_LOG_ENABLED is 0.. Kindly try initializing RTT.

    Regards,

    Swathy

Related