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

Cannot see NRF_LOG_INFO in Segger Embedded Studio

I can find some other topics about this:

Like this one:

https://devzone.nordicsemi.com/f/nordic-q-a/43370/nrf_log_info-and-printf-does-not-work

or this article:

https://westsideelectronics.com/getting-logging-to-work-in-segger-embedded-studio/

But the problem is, I can not find the define:

NRF_LOG_BACKEND_RTT_ENABLED

Should I just replace config_sdk.h with another file with the right defines ?

Using the blinky example.

  • I'm bit irritated, just thinking why aren't these things documentated, as a customer I want to concentrate on the application not 'just' getting the logging to work.....

    But anyway....

    I thought sdk_config.h is for every project the same and you can define or undefine on what you need for the project, but this isn't the case. So I took another sample project, ble_app_uart project.

    Eventually I stripped it down to just get the LOG working to this:

    static void log_init(void)
    {
        ret_code_t err_code = NRF_LOG_INIT(NULL);
        APP_ERROR_CHECK(err_code);
    
        NRF_LOG_DEFAULT_BACKENDS_INIT();
    }
    
    int main(void)
    {
      log_init();
      
    
      NRF_LOG_INFO("Initalization done");
    
      // Enter main loop.
      for (;;)
      {
        NRF_LOG_INFO("test");
        nrf_delay_ms(500);
      
      }
    
    }

    It still didn't work, after like a day trying and trying found out that this is working:

    /**@brief Function for handling the idle state (main loop).
     *
     * @details If there is no pending log operation, then sleep until next the next event occurs.
     */
    static void idle_state_handle(void)
    {
        if (NRF_LOG_PROCESS() == false)
        {
            nrf_pwr_mgmt_run();
        }
    }
    
    static void log_init(void)
    {
        ret_code_t err_code = NRF_LOG_INIT(NULL);
        APP_ERROR_CHECK(err_code);
    
        NRF_LOG_DEFAULT_BACKENDS_INIT();
    }
    
    int main(void)
    {
      log_init();
     
    
      NRF_LOG_INFO("Initalization done");
    
      // Enter main loop.
      for (;;)
      {
        NRF_LOG_INFO("test");
        nrf_delay_ms(500);
        idle_state_handle();
      }
    
    }

    Can somebody explain why the function idle_state_handle() is needed to get the log function to work ? Took me all day to find out.

    Look, I don't mind some work to get things working, but like I said, I want to work on my appliction and not these kind of things, why aren't these things documentated ?

  • Stripped it down a bit more, if I comment the if statement then it doesn't work and when I decomment the if statement it is working:

    static void log_init(void)
    {
        ret_code_t err_code = NRF_LOG_INIT(NULL);
        APP_ERROR_CHECK(err_code);
    
        NRF_LOG_DEFAULT_BACKENDS_INIT();
    }
    
    int main(void)
    {
      log_init();
     
    
      NRF_LOG_INFO("Initalization done");
    
      // Enter main loop.
      for (;;)
      {
        NRF_LOG_INFO("test");
        //nrf_delay_ms(500);
        if (NRF_LOG_PROCESS() == false);
      }
    
    }

  • After searching on the specific function I can find these documentation:

    https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v14.0.0%2Fgroup__nrf__log__ctrl.html

    Like I said, you can find a lot of information how to edit to sdk_config to get the logging working, but not that the functions NRF_LOG_FLUSH() or NRF_LOG_PROCESS() is needed to get the log working.

    I thought it just works like printf, but apparently it collects all the logs and process it at once, is this correct ?

    At leasted I'm bit 'cooled' down, it is what is. I'm busy with a diy BMS:

  • Hi, 

    Sorry for the delay due to the weekend. 

    Since Blinky Example doesn't implement with Logger backend interface, it cannot enable the NRF_LOG_BACKEND_RTT_ENABLED in the config_sdk.h to get it to work. You should refer to the  Logger module documentation to implement it, which also includes using NRF_LOG_FLUSH() and NRF_LOG_PROCESS(). 

    Regards,
    Amanda

  • Very thank you, another question, how to enable the NRFX_LOG_INFO outputs ? I'm trying to setup the saadc

    Already defined:


    #define NRFX_SAADC_CONFIG_LOG_ENABLED 1
    #define NRFX_SAADC_CONFIG_LOG_LEVEL 3

    But still no logger output from nrfx_saadc.c

    Thanks in advance.

Related