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

how to enable NCS RTT logging?

I'm following the NCS tutorials. I'm targeting the 52840 on the 9160DK board. I'm using SES with NCS1.6.

I'm able to get the hello world to run and the message is out on the serial port. Now I'd like to have RTT for logging but I found it's very confusing to how to get it to work.

I used Project->Config NCS project to enable the RTT option. I'm not sure if this is the only thing needed. Probably not because it doesn't work. I saw others also modify prj.conf to include various options but it doesn't seem conclusive as to what are the necessary changes. They all look different.

I'm wondering if there are tutorial or documents to:

1. how to enable RTT

2. how the logger works in general.

3. How does the configuration (ie KConfig) work? Should I just use SES for that or also need to edit the prj.conf?

Thanks!

My main() is like this:

#include "logging/log.h"

LOG_MODULE_REGISTER(main);

void main(void)
{
    LOG_INF("Hello World!\n");
}

As to the hardware, I assume it works through the same interface chip on the 9160DK, without needing a dedicated JLink?

Parents
  • I finally figured that out. The logger is a Zephyr thread. (It could be configured as non-thread too. I'll save that exercise for another day.) To make sure the logger thread have a chance to run and work, I'll need to call sleep. So the main() looks like this:

    LOG_MODULE_REGISTER(main, LOG_LEVEL_INF);
    
    void main(void)
    {
      while(1){
        LOG_INF("Hello World!\n");
        k_sleep(K_MSEC(100));    
      }
    }

    It's probably not the best way to structure main() but I just want to get my Hello World out and move on. It's good enough for now.

  • Hi, it good to hear that you got it working.

    However, it should not be necessary to call k_sleep to let the logging thread run.

    First, when you reach the end of main, it should be able to switch to the logging thread. But also, if you use the default thread priorities, the main thread is preemptible, so unless the logging thread has a lower priority, it should be able to run.

    For reference, here is the application I used to test your problem: minimal_log.zip

Reply Children
Related