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

SDK 14 RTT logging issue

Hi,

The followings are more like an observation rather than a question..

We just upgraded to SDK 14, and realized that some of the RTT logs were mysteriously disappeared. We tried with and without NRF_LOG_DEFERRED, played with buffer sizes, but still experienced the same: chunks of logs were completely skipped. One would not expect loosing logs for eg. NRF_LOG_DEFERRED=0, but it happens..

All logs were appearing when we were stepping in the debugger (and with the SDK 12.2 we used before)

It turned out that in nrf_log_backend_rtt.c there is a SEGGER_RTT_WriteNoLock with some logic around it to prevent blocking. The problem with that, is if the Segger buffer is full, the log contents will be simply discarded (from the log buffers too!), and even subsequent NRF_LOG_FLUSH calls will not display them.

Our current solution was to remove the followings:

if (processed == 0)
{
  // If RTT is not connected then ensure that logger does not block
  watchdog_counter--;
  if (watchdog_counter == 0)
  {
    break;
  }
}

This has the price that it might block the caller, but at least we see the logs.

Just wondering if there is a better way to approach this...

Parents
  • Hi,

    You can configure the RTT behavior if the buffer is full in sdk_config.h by setting SEGGER_RTT_CONFIG_DEFAULT_MODE to the mode you want.

    The following modes are supported:

    SKIP - Do not block, output nothing.

    TRIM - Do not block, output as much as fits

    BLOCK - Wait until there is space in the buffer

    The default mode is SKIP. You could also try to increase the buffer size(SEGGER_RTT_CONFIG_BUFFER_SIZE_UP) before changing the mode, and see if that solves your issue. E.g. change SEGGER_RTT_CONFIG_BUFFER_SIZE_UP from 512 to 1024.

Reply
  • Hi,

    You can configure the RTT behavior if the buffer is full in sdk_config.h by setting SEGGER_RTT_CONFIG_DEFAULT_MODE to the mode you want.

    The following modes are supported:

    SKIP - Do not block, output nothing.

    TRIM - Do not block, output as much as fits

    BLOCK - Wait until there is space in the buffer

    The default mode is SKIP. You could also try to increase the buffer size(SEGGER_RTT_CONFIG_BUFFER_SIZE_UP) before changing the mode, and see if that solves your issue. E.g. change SEGGER_RTT_CONFIG_BUFFER_SIZE_UP from 512 to 1024.

Children
Related