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

SEGGER_RTT_CONFIG_DEFAULT_MODE blocking app

If SEGGER_RTT_CONFIG_DEFAULT_MODE is "BLOCK", the program won't start without RTT attached - at least for me... is there a possible solution? I mean, technically it makes sense, because the buffer is never flushed without RTT Logger attached, but as we require the blocking logging in the current stage of the project for debugging purposes, we would have to maintain two different firmware versions to use with and without RTT logger attached

  • found a possible workaround: nrf SDK actually checks if the RTT is attached by a watchdog timer in nrf_log_backend_rtt.c BUT you'll have a race condition if you're doing something like me: LOG_INIT(NULL); NRF_LOG_DEFAULT_BACKENDS_INIT(); NRF_LOG_INFO("%s", versionbuffer); NRF_LOG_FLUSH();

    in this case, the watchdog would only handle 1 message (but expects 10) so the NRF_LOG_FLUSH will block. I simply added 10 empty NRF_LOG_INFO messages before the first flush and it seems to work

  • Hi Chris,

    As far as I understand the watchdog_counter (maybe not watchdog timer ?) was to avoid staying in that loop without any byte processed ? It's not about the number of queuing message as you mentioned (10), simply try 10 times if there is no byte queued it will exit the loop.

  • we had similar issues... (we are on armGCC and makefile, your mileage may vary) a simple way to get to the behavior you want this is to add a makefile command line option. something like:

    make flash RTT=NO
    

    adding the RTT option necessitate just 2 changes in the makefile, at the top of it add this:

    ifdef RTT
    ifeq ($(RTT), YES)
                LOGGING_MESSAGES := -DNRF_LOG_ENABLED=1 #add messages
    else
                LOGGING_MESSAGES := -DNRF_LOG_ENABLED=0 #remove messages
    endif
    endif
    

    and later on in the makefile add to the existing CFLAGS

    FLAGS += $(LOGGING_MESSAGES)
    

    You can do fancier things but I'm just showing a simple example. You will have to clean when you switch the options but it works. Hope this helps

Related