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

Debugging, NRF_LOG, Segger Embedded Studio Problems

I saw something in the list that might help but I have learned that if I go there I lose all the work I did to get here

I am having major problems with Segger Embedded Studio

  • NRF_LOG_x does not print either through the UART and putty OR RTT in SES [Manually set in the sdk_config.h file] since CMSIS Wizard is not present
  • The CMSIS Configuration Wizard is NOT present in my Tools.xml
  • Debug breakpoints are not hit unless it is in the main() part of main.c and when hit not in the code, only if a debug window to the left of the code
  • I can step line by line if I start and use F10/F11 from the start (do not use F5 and a break point) but never once I use F5 and a break point.

The only thing I can think of is that somehow the installation of SES got really corrupted or I am missing a major step. I have no idea how to fix.

Yet the code I have does partially run - it advertises, gets connected to, responds to service discovery, gets two characteristic descriptors enabled but then when I try and write from the client the write times out. I am not surprised that there are issues with the code as I have ported a SoftDevice only project from nRF51 and Keil.

But being unable to debug or even print to RTT (this is new for me) or via the UART and putty (the latter worked fine in the Keil project) is not helping.

Any help would be great. (Yes I have seen the debugging video and that's how I know my Tools.xml is corrupt).

  • When I set the following 

    #ifndef NRF_FPRINTF_ENABLED
    #define NRF_FPRINTF_ENABLED 0
    #endif

    in the SDK_config.h file I get a list of errors when I try to build (Segger) that all look like this:

    E:\projects\utech\nRF5_SDK_17.0.2_d674dde\components\libraries\log\src/nrf_log_str_formatter.c:124: undefined reference to `nrf_fprintf'

    When looking at the source code for the file nrf_fprintf_format.c I see that all the code is grayed out due to the line #if NRF_MODULE_ENABLED(NRF_FPRINTF) at the beginning of the file which is expected. However, when I look at the file nrf_fprintf.c the source coide is NOT grayed out after the line #if NRF_MODULE_ENABLED(NRF_FPRINTF) which is not expected. This is, of course, why I am getting the build errors.

    Why is that happening? I assume that if I remove the two files from the build everything would be okay. But there must be something that is re-defining NRF_FPRINTF_ENABLED somewhere. So at the moment I have to define NRF_FPRINTF_ENABLED in the SDK_config.h file. DO I need to do something else to remove that module or is it, in fact, needed by NRF_LOG?

    I looked into some more source modules and it turns out that you have to have FPRINTF enabled if you use NRF_LOG, I see this in the source code of the file nrf_log_str_formatter.c

    static void prefix_process(nrf_log_str_formatter_entry_params_t * p_params,
                               nrf_fprintf_ctx_t * p_ctx)
    {
        if (p_params->dropped)
        {
            nrf_fprintf(p_ctx,
                        "%sLogs dropped (%d)%s\r\n",
                        NRF_LOG_COLOR_CODE_RED,
                        p_params->dropped,
                        NRF_LOG_COLOR_CODE_DEFAULT);
        }

    Should probably add both define checks at the beginning of the file. As far as I can tell its only the string formatter of NRF LOG that requires fprintf, but then again, other files call these functions that require fprintf of the string formatter.

    Long story short, NRF_LOG requires NRF_FPRINTF - they need to be enabled/disabled together.

Related