Logging functions disabled for nRF52 DK board

I have the nRF52 DK board and I am loading the peripheral_uart example. All works fine I can compile and flash and connect to iPhone. There is no problem with the application. I just want to be able to turn on logging. there is a line in log.h as shown below that shows _CDT_PARSER_ as "#define _CDT_PARSER_ 1". I do not see how or where this is set and how I undefine or disable it.

if _CDT_PARSER_ is defined as a 1 then all logging functions will be 0. What am I doing wrong? I am new to nRF52 DK tools so I am sure it is operator error.

/*
 * Eclipse CDT or JetBrains Clion parser is sometimes confused by logging API
 * code and freezes the whole IDE. Following lines hides LOG_x macros from them.
 */
#if defined(__CDT_PARSER__) || defined(__JETBRAINS_IDE__)
#undef LOG_ERR
#undef LOG_WRN
#undef LOG_INF
#undef LOG_DBG

#undef LOG_HEXDUMP_ERR
#undef LOG_HEXDUMP_WRN
#undef LOG_HEXDUMP_INF
#undef LOG_HEXDUMP_DBG

#define LOG_ERR(...) (void) 0
#define LOG_WRN(...) (void) 0
#define LOG_DBG(...) (void) 0
#define LOG_INF(...) (void) 0

#define LOG_HEXDUMP_ERR(...) (void) 0
#define LOG_HEXDUMP_WRN(...) (void) 0
#define LOG_HEXDUMP_DBG(...) (void) 0
#define LOG_HEXDUMP_INF(...) (void) 0
#endif
  • Hi Timothy,

    In the nRF Connect SDK, Logging is enabled and configured through the appropriate Kconfig options.

    For example to enable logging, you add

    CONFIG_LOG=y

    to your prj.conf.

    I assume you're new to NCS. I would therefore strongly recommend you to start with the NCS fundamentals course on our Developer Academy:

    https://academy.nordicsemi.com/courses/nrf-connect-sdk-fundamentals/

    It covers logging as well, if you want to skip straight to that:

    https://academy.nordicsemi.com/courses/nrf-connect-sdk-fundamentals/lessons/lesson-3-printing-messages-to-console-and-logging/topic/exercise-2-4/

    Best regards,

    Raoul

  • Raoul

    thanks for the quick reply. I am not new to NCS. I have been using NCS with the V1.7.0 and nRF9160 for several years.

    I am new to nrf52 and V2.5.0. I have the following in  my prj.conf file. I have details below. what am I doing wrong.

    # Config logger
    CONFIG_LOG=y
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_LOG_BACKEND_RTT=y
    CONFIG_LOG_BACKEND_UART=n
    #CONFIG_LOG_PRINTK=n
    CONFIG_LOG_PRINTK=y

    I have the following in my code

        printf("V %d.%02d %s%s\r\n",VERSION_MAJOR, VERSION_MINOR, VERSION_DATE,VERSION_DATE_EXT);

        LOG_INF("Bluetooth initialized INF");
        LOG_WRN("Bluetooth initialized WRN");
        LOG_ERR("Bluetooth initialized ERR");
        printf("Bluetooth initialized\r\n");
    this is what is printed
    V 0.01 Temp/Humidity BLE Sensor 11/11/23 (Bd 1.0 DK)
    Bluetooth initialized
  • Hi again,

    Which IDE are you using? Are you actually using CLion? Or just VS Code with our extension?

    Timothy said:
    this is what is printed
    V 0.01 Temp/Humidity BLE Sensor 11/11/23 (Bd 1.0 DK)
    Bluetooth initialized

    Thanks for sharing. It looks to me like your LOG_INF statement is actually printing, so that's a good sign.

    But just to be clear, is it cutting off the "INF" at the end of that log statement? And is it not printing the other two statements? Or did you just give me an excerpt?

    I need to understand exactly what issue you are seeing.

    Also, have you tried logging with UART? Or do you have to use RTT?

    Best regards,

    Raoul

  • the LOG_INF is NOT printing. my printf statement is printing. none of the LOG_XXX are printing as I show above. I am using VS Code for all development. the __CDT_PARSER__ is defined somewhere which cause all of the logging statement to be NULL (0). I have no idea where that is defined and why it is blocking things.

    this is my code shown below.

    printf("V %d.%02d %s%s\r\n",VERSION_MAJOR, VERSION_MINOR, VERSION_DATE,VERSION_DATE_EXT);
        LOG_INF("Bluetooth initialized INF");
        LOG_WRN("Bluetooth initialized WRN");
        LOG_ERR("Bluetooth initialized ERR");
        printf("Bluetooth initialized\r\n");
  • Tim,

    I don't know what gave you the idea that __CDT_PARSER__ is defined. You are not using Eclipse so that explains why you cannot find it defined. The nRF Connect SDK documentation describes every sample application in the SDK and shows you how to get a logging console for the sample you are working with. There is a lot of Zephyr code included in the logging subsystem; apparently the printf function which is a C library function bypasses all that and goes directly to UART. All we have to know is that there is a bunch of logging subsystem code--the easiest way to deal with that is to simply follow the directions in the sample in which case we never have to know anything much about that logging subsystem. Maybe it helps to know that it has separate "backends" for UART and for RTT. Definitely for you and I who have come from a nRF9160 background it is unexpected that printf and LOG messages go to different places, but it is what it is! 

    Burt

Related