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

NRF_LOG_INFO() and printf() doesn't print

Hi, I'm using nRF52805.

In my code, I used BLE to transmit I2C and ADC data to the mobile app nRF Connect correctly and continuously. 

I tried to use NRF_LOG_INFO() and printf() to print some information on either PuTTY or RTT Viewer (only use 1 Hyperterminal at one time). However, nothing is printed. 

Here are my seetings: 

1) NRF_LOG_PROCESS() or NRF_LOG_FLUSH() is called regularly. 

2) Both NRF_LOG_INIT() and the NRF_LOG_DEFAULT_BACKENDS_INIT() macro are placed at the beginning of main.

3) NRF_LOG_ENABLED  = 1

4) Added breakpoint in debug mode, the NRF_LOG_INFO() and printf()  are reached. 

My SDK is provided SDK.txt

Does anyone have any clue? Thanks. 

Parents
  • Hello,

    My SDK is provided SDK.txt

    Thank you for providing the sdk_config.h file.

    I tried to use NRF_LOG_INFO() and printf() to print some information on either PuTTY or RTT Viewer (only use 1 Hyperterminal at one time).

    Since you're using the RTT backend for the logger the logs will only be visible in an RTT monitor, like RTT Viewer or the debug terminal in SES - PuTTY should however show printf statements, since you have RETARGET enabled in your sdk_config.h. Are you not seeing any of the printf statements in PuTTY either?

    I'm using nRF52805

    Could you elaborate on this - are you using the nRF52805 on a custom board, or emulated on a DK?
    If you are using a custom board, how are you programming / connecting a debugger to your board?

    1) NRF_LOG_PROCESS() or NRF_LOG_FLUSH() is called regularly. 

    Could you elaborate on how often NRF_LOG_PROCESS is called, and have you verified that the program actually makes it to the NRF_LOG_PROCESS call?
    Since you are using the deferred logging option no logs will be processed until NRF_LOG_PROCESS is called. This is a common reason for logs not showing.
    Could you try to disable the deferred logging option, and see if you then see logs appear as your calls to NRF_LOG_INFO happens?

    Best regards,
    Karl

Reply
  • Hello,

    My SDK is provided SDK.txt

    Thank you for providing the sdk_config.h file.

    I tried to use NRF_LOG_INFO() and printf() to print some information on either PuTTY or RTT Viewer (only use 1 Hyperterminal at one time).

    Since you're using the RTT backend for the logger the logs will only be visible in an RTT monitor, like RTT Viewer or the debug terminal in SES - PuTTY should however show printf statements, since you have RETARGET enabled in your sdk_config.h. Are you not seeing any of the printf statements in PuTTY either?

    I'm using nRF52805

    Could you elaborate on this - are you using the nRF52805 on a custom board, or emulated on a DK?
    If you are using a custom board, how are you programming / connecting a debugger to your board?

    1) NRF_LOG_PROCESS() or NRF_LOG_FLUSH() is called regularly. 

    Could you elaborate on how often NRF_LOG_PROCESS is called, and have you verified that the program actually makes it to the NRF_LOG_PROCESS call?
    Since you are using the deferred logging option no logs will be processed until NRF_LOG_PROCESS is called. This is a common reason for logs not showing.
    Could you try to disable the deferred logging option, and see if you then see logs appear as your calls to NRF_LOG_INFO happens?

    Best regards,
    Karl

Children
  • Thanks, Karl. 

    I solved the problem. Here are my correct SDK settings: 

    NRF_LOG_ENABLED  = 1
    NRF_LOG_BACKEND_RTT_ENABLED 1
    NRF_LOG_DEFERRED = 0

    Now, I can use NRF_LOG_INFO(""); to see the loggings in RTT Viewer.

    Plz refer to this link to see logger config

  • Thanks, Karl. 

    I solved the problem.

    Great, I am happy to hear that you were able to resolve the issue!

    Now, I can use NRF_LOG_INFO(""); to see the loggings in RTT Viewer.

    If logs are showing now that you do not have the DEFERRED option set this likely means that NRF_LOG_PROCESS is not being called as often as you had though initially, which might be worthwhile to take a look at.
    Leaving DEFERRED disabled will mean that log processing happens in-place, which could slow down your program, or otherwise increase the execution time of functions that contain a lot of logging, so please also keep this in mind.

    Best regards,
    Karl

Related