printk via RTT will not work, but printf does

Hello there,

I have looked through all of the various other related questions, but still cannot resolve this issue. I am trying to use RTT versus a UART for the console. I have confirmed that the printf operation works, but not printk. I have looked at all the various configuration settings and stepped through the code, and the call branches to "log_printk" versus "vprintk". 

I have the following config statements defined in the project file:

CONFIG_CONSOLE=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_RTT_CONSOLE=y
CONFIG_UART_CONSOLE=n
CONFIG_PRINTK=y
CONFIG_LOG_PRINTK=n

However in the output config file, the parameter CONFIG_LOG_PRINTK is always set as "y". Can you tell me why I cannot change this printk log parameter, it appears that this is stopping me from using printk to the RTT console.
Thanks,
Pam
  • Hi Pam

    Could you try to add the following config as well?

    CONFIG_UART_RTT=y

    This should fix the issue. 

    Best regards
    Torbjørn

  • Hi Torbjørn,

    Unfortunately that didn't help. I'm thinking the problem might be related to not being able to set CONFIG_LOG_PRINTK=n. I am getting a build error when I try to set it to "n" in the prj.conf file. Also, I think I am not allowed to set it within the Kconfig menu, the option is greyed out. Here is the build error I am seeing:

    warning: LOG_PRINTK (defined at c:\Soberlink\soberlink_sfw\trunk_NordicBLE\peripheral_uart\build\subsys\logging\Kconfig.processing:8) was assigned the value 'n' but
    got the value 'y'. See docs.zephyrproject.org/.../CONFIG_LOG_PRINTK.html
    and/or look up LOG_PRINTK in the menuconfig/guiconfig interface. The Application Development Primer,
    Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be
    helpful too.

    The reason I think the issue might be related to this logging feature is that when I single step through the printk() routine, the code then branches to the routine log_printk() versus vprintk().

    Thanks,

    Pam

  • Hi Pam

    Is there any particular reason you need to set CONFIG_LOG_PRINTK=n ?

    I was able to route the printk message to RTT in the peripheral_uart sample by adding the following configurations only:

    CONFIG_UART_RTT=y
    CONFIG_RTT_CONSOLE=y

    Best regards
    Torbjørn
     
  • Hello Torbjørn,

    I see what part of the issue might be. I am able to see all the printk statements (as well as log statements I believe) using the Segger RTT Client program. But they are not showing consistently in either the NRF Terminal window within Visual Studio, or the Terminal window within the Ozone debugger. I was occasionally able to see some statements, then nothing. Resetting the processor within the debugger doesn't help, nor does exiting and re-downloading the image. It appears to be very random when it works in those terminal windows, which is rarely.

    Thanks,

    Pam

  • Hi Pam

    I must admit I don't have a lot of experience using the RTT interface in the nRF Terminal or Ozone, but I was able to get it working without obvious issues. 

    I made a small modification to one of the Bluetooth examples to print to the RTT log every second, and can see it appear consistently. 

    Which operating system and version are you running on your PC? 

    Do you know which version of the JLink DLL you are using? 

    Best regards
    Torbjørn

Related