Log on interrupt while another log is being processed causes hang

See the below stack trace using nRF5 SDK 17.0.2, where execution had stopped while entering a critical region during an interrupt event when another log was being processed in the main run loop. Is there any way to prevent this?

  • Haven't really since this before, are you logging to UART or RTT? I notice it also says flash there, are you logging/writing to flash? Is there any difference if you use NRF_LOG_DEFERRED 0? Are you doing any NRF_LOG_FLUSH() that affect this?

    Kenneth

  • RTT. No, it just happens to be doing a log when performing a flash operation in my code, but the flash write is not in progress at that point, and I am not logging to flash. It is logging a hex dump of 1kb data, so it takes a bit longer and increases the probability that an interrupt will occur while the log data is transferred over RTT. NRF_LOG_DEFERRED is 0. I am not manually calling NRF_LOG_FLUSH(). RTT is blocking, so main loop is waiting for RTT send when the interrupt occurs.

  • Can you try to use NRF_LOG_DEFERRED 1, and add NRF_LOG_PROCESS() to the main loop, e.g.:

    static void idle_state_handle(void)
    {
    if (NRF_LOG_PROCESS() == false)
    {
    nrf_pwr_mgmt_run();
    }
    }

  • I'm not sure if this will resolve it because a log allocation could still occur on an interrupt when the logs are being sent on RTT, right? However, I don't want to defer logs. This is in a debug build and I want to ensure all logs are sent without risking buffer overflow.

  • I can report it, but then I need some way to recreate it here. Do you have by any chance a way to provide a project that can run on an nRF52-DK?

    In the meantime using deferred might be worth looking into.

    Kenneth

Related