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

SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL when no probe

Hello,

I use a debugger probe (Segger Jlink) with the sdk_config.h setting SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL.

When my probe is not connected, there my product is blocked => i guess that a probe detection is missing in SEGGER_RTT.c, right ?

Where can I fix it please ?

Thank you

Parents Reply Children
  • How does one perform a probe check in s/w?

    Here's a solution... set it to the default non-blocking mode, and only after receiving a keypress decide that there is a connection.  I added this API to SEGGER_RTT.c:

    void SEGGER_RTT_Flags(unsigned up_flags, unsigned down_flags, unsigned *up_flags_old, unsigned *down_flags_old) {
      SEGGER_RTT_CB* p;
      p = &_SEGGER_RTT;
    
      if (up_flags_old) {
    	  *up_flags_old = p->aUp[0].Flags;
      }
      if (down_flags_old) {
    	  *down_flags_old = p->aDown[0].Flags;
      }
      if (up_flags != (unsigned)-1) {
    	  p->aUp[0].Flags    = up_flags;
      }
      if (down_flags != (unsigned)-1) {
    	  p->aDown[0].Flags  = up_flags;
      }
    }

  • I use that (DHCSR is compatible with Cortex M4 only => nRF52840 only)

    int SEGGER_RTT_TerminalOut (char TerminalId, const char* s) {
      int                   Status;
      unsigned              FragLen;
      unsigned              Avail;
      SEGGER_RTT_BUFFER_UP* pRing;
      
    	// C_DEBUGEN == 1 -> Debugger Connected
    	if (CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk)
    	{
    
    	}
    	else
    	{
    		return STRLEN(s);
    	}
    	
    	//
        INIT();

    and I modified nrf_log_internal.h like this

    #define NRF_LOG_INTERNAL_INST(level, level_id, p_inst, ...)                              \
        if (NRF_LOG_ENABLED && (NRF_LOG_LEVEL >= level) &&                                   \
            (level <= NRF_LOG_DEFAULT_LEVEL) && (CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk))                                                \
        {                                                                                    \
            if (NRF_LOG_INST_FILTER(p_inst) >= level)                                        \
            {                                                                                \
                LOG_INTERNAL(LOG_SEVERITY_INST_ID(level_id, p_inst), __VA_ARGS__);           \
            }                                                                                \
        }
    
    #define NRF_LOG_INTERNAL_MODULE(level, level_id, ...)                                    \
        if (NRF_LOG_ENABLED && (NRF_LOG_LEVEL >= level) &&                                   \
            (level <= NRF_LOG_DEFAULT_LEVEL) && (CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk))                                                \
        {                                                                                    \
            if (NRF_LOG_FILTER >= level)                                                     \
            {                                                                                \
                LOG_INTERNAL(LOG_SEVERITY_MOD_ID(level_id), __VA_ARGS__);                    \
            }                                                                                \
        }
    
    #define NRF_LOG_INTERNAL_HEXDUMP_INST(level, level_id, p_inst, p_data, len)        \
        if (NRF_LOG_ENABLED && (NRF_LOG_LEVEL >= level) &&                             \
            (level <= NRF_LOG_DEFAULT_LEVEL) && (CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk))                                          \
        {                                                                              \
            if (NRF_LOG_INST_FILTER(p_inst) >= level)                                  \
            {                                                                          \
                LOG_HEXDUMP(LOG_SEVERITY_INST_ID(level_id, p_inst),                    \
                                         (p_data), (len));                             \
            }                                                                          \
        }
    
    #define NRF_LOG_INTERNAL_HEXDUMP_MODULE(level, level_id, p_data, len)              \
        if (NRF_LOG_ENABLED && (NRF_LOG_LEVEL >= level) &&                             \
            (level <= NRF_LOG_DEFAULT_LEVEL) && (CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk))                                          \
        {                                                                              \
            if (NRF_LOG_FILTER >= level)                                               \
            {                                                                          \
                LOG_HEXDUMP(LOG_SEVERITY_MOD_ID(level_id),                             \
                                         (p_data), (len));                             \
            }                                                                          \
        }

Related