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

JLink RTT Viewer Wont Log

Hello!

I am using the nRF52832 with nRF5_SDK 14.0.0. with a JLink connection. My OS is Ubuntu 16.04.

After placing NRF_LOG_INFO() statements around my code, connecting to the nRF52832_XXAA device with 'JLinkExe', and running 'JLinkRTTClient', only the first log statement would log in my terminal window, not even a statement placed immediately after the first one. I went into my 'sdk_config.h' file and set:

#define NRF_LOG_BACKEND_UART_ENABLED        0

... and then it worked. RTT Client would show the process traveling through my code, and logging expectedly until experiencing a fatal error when it reaches the command 'sd_power_system_off()'. I figured this error made sense, as the RTT client would need CPU to do its job. This isn't my question though. EDIT: after adding 'NRF_LOG_FINAL_FLUSH()' before the 'system_off' the error does not appear anymore.

After changing some code functionality, the JLinkRTTClient again does not log anything. I narrowed the effect down to this single line of code: When changing the command

err_code = sd_power_system_off();
NRF_LOG_INFO("err_code is: %d", err_code);            // error code is 8198
APP_ERROR_CHECK(err_code);

... to:

err_code = sd_nvic_SystemReset();
NRF_LOG_INFO("err_code is: %d", err_code);            // nothing logged
APP_ERROR_CHECK(err_code);

... for the purpose of setting up a battery performance test, to run the code over and over until the battery dies, the RTT viewer does not log anything. It pauses after 'Process: JLinkExe' with no further activity. Here is a terminal view showing two separate connection attempts, first after using 'sd_power_system_off()', then a stuck attempt after using 'sd_nvic_SystemReset()':

JLink RTT Client terminal view

EDIT: After adding 'NRF_LOG_FINAL_FLUSH();' before the 'SystemReset', the RTT viewer now prints:

<info> a<info> a<inf<info> a<info> a<info> a<info>

... over and over with nothing else. Is it trying to print ' app: [log comment]'? I have no log messages starting with the letter 'a'. What is interrupting its print?

The odd thing is is that the code is actually functioning as expected. I am receiving my BLE signals over and over again, as the test should, but i cant see anything logged to my terminal.

Here are some main.c code snippets: My NRF log_init, and the problematic line switch:

static void log_init(void)
{
ret_code_t err_code = NRF_LOG_INIT(NULL);
APP_ERROR_CHECK(err_code);
NRF_LOG_DEFAULT_BACKENDS_INIT();
}


void batt_test_timer_event_handler()
{
uint32_t err_code;
NRF_LOG_INFO("batt_test_timer expired and is about to reset the system");

err_code = sd_nvic_SystemReset();          // with this line, no logs will appear
//err_code = sd_power_system_off();        // with this instead, logs will appear until the error happening here.

NRF_LOG_INFO("err_code is: %d", err_code);     // error value is 8198 with system_off, no error is logged (NOTHING is logged) with SystemReset.
APP_ERROR_CHECK(err_code);
}

... a skeleton of my main:

int main(void)
{
// ... variables...
// ... Initialize...
log_init();
NRF_LOG_INFO("in main");

// ...some main stuff...

batt_test_timer_start();
// Enter main loop.
for (;; )
    {
	    power_manage();
    }
}

Why does the RTTClient need the error to display its logs? Is the RTT Client waiting for my process to end before it displays its logs? Am I missing a core requirement for using NRF_LOG_INFO()?

Another weird thing: I have three timers set up, totaling maybe 12 seconds. The logging that does occur when that single line of code is switch to 'system_off' appears immediately after I connect to the device. Why is that? I thought it was a 'real-time' viewer, why is it skipping through the timers and displaying everything at once?

Any re-direction, help, ideas, or hints are greatly appreciated!

Thanks!

Related