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

Can I view NRF_LOG_DEBUG logging in keil without an actual uart port? How?

Hello:

I have been trying to figure out the proper app ram address base by calling sd_ble_enable.

I am using keil's debug mode, and when the program hit the breakpoint I set at:

err_code = sd_ble_enable(&app_ram_base);

I press F10, move my mouse over to &app_ram_base, in hoping that I will get the updated value.

No, not really. Instead I get the old value. Even if the return error code is 0 (NRF_SUCCESS).

So now I'm thinking maybe I looked at the wrong direction, maybe this is not how it's done. Maybe I should use keil's UART window, or Debug(printf) viewer, or trace window etc to get the job done.

So I keep hearing this logging thing that is available since sdk 12. And I'm here asking:

  1. Is obtaining that base address value possible in this way (using keil only, my custom board does not have uart pin out, sadly, my bad)
  2. How do I do it?

This is what I tried:

in sdk_config.h, I changed:

#define CLOCK_CONFIG_LOG_ENABLED 0

to

#define CLOCK_CONFIG_LOG_ENABLED 1

and

#define CLOCK_CONFIG_LOG_LEVEL 3

to

#define CLOCK_CONFIG_LOG_LEVEL 4

And nothing really happened. All the windows I mentioned above were blank.

Can someone please help me? Thanks in advance.

  • Hi,

    If you do not have UART pin output from your board, you cannot use logging over UART. You can use RTT for logging if using a J-Link programmer. NRF_LOG support RTT as the backend for logging, you can enable this by setting the following in sdk_config.h:

    #define NRF_LOG_ENABLED 1
    #define NRF_LOG_BACKEND_SERIAL_USES_UART 0
    #define NRF_LOG_BACKEND_SERIAL_USES_RTT 1
    

    Note that if NRF_LOG_DEFERRED is set, you need to call NRF_LOG_PROCESS() or NRF_LOG_FLUSH() to process the log queue.

    You can view the output from the RTT using J-Link RTT viewer.

    Best regards,

    Jørgen

  • Hello Jørgen, a few more questions:

    • Do I have to add addtional files from segger co, ltd in order to use it? Includes and .c source codes?

    • What do you mean by "Note that if NRF_LOG_DEFERRED is set, you need to call NRF_LOG_PROCESS() or NRF_LOG_FLUSH() to process the log queue.“? It was set by default. Can I disable it to reduce the amount of hassle?

    If I can't, do I have to call the 2 functions every time I want to view the log?

  • If you use any of the examples from our SDK (v11.0.0 or above), the RTT source files are allready added to the project. The header files are included by NRF_LOG module. If you created project from scratch, you will have to include the source files from [SDK_ROOT]\external\segger_rtt, and include the directory in your include paths.

    You can disable DEFERRED logging, which will make the prints happen immediately. The advantage of deferred logging is that printing can be performed in a non-busy state (e.g. before going to sleep/idle in main loop), reducing the chance of logging being disrupted by softdevice etc.

Related