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

Init/deinit openthread stack causes a failed assert

Hello,

for our application i need to periodically enable and disable the openthread stack on the nRF52840 chip.

For testing purposes i've modified the Thread CLI example so that the main loop keeps doing the following:

  1. Wait for a timer to expire (when it does, a flag is set): ~ 7 seconds
  2. Enable the thread stack and connect to the configured thread network. This part calls the thread_init() function in "thread_utils.c" in the examples.
  3. After the connection is established (device is connected as a child or router), waits for about 1.5 seconds (as before, using a timer and a flag).
  4. After this period, turn off the thread stack. This part also calls the thread_deinit() function in "thread_utils.c".
  5. Loop from 1) over and over.

Of course in the main loop the "thread_process" function is called at every iteration while the thread stack is initialized.

Everything works fine for a while. However, after a random time, a failed assertion causes the system to either enter a break condition (if the JLink debugger is connected), or reset.

The failed assertion is in the nrf_802154_csma_ca_start() function, called by otPlatRadioTransmit(). By looking at the source code of the _ca_start() function, it appears that the only way it can lead to a failed assert is that it is called before the previous operation ends. In particular:

void nrf_802154_csma_ca_start(const uint8_t * p_data)
{
    assert(!procedure_is_running());
    
    mp_data = p_data;
    m_nb = 0;
    m_be = NRF_802154_CSMA_CA_MIN_BE;
    m_is_running = true;
    
    random_backoff_start();
}

I've also attached the complete call stack when the failed assert happens:

Can anybody help with this? Am I doing something wrong or should I do something different for initializing/deinitializing the openthread stack?

Thank you!

Parents Reply Children
No Data
Related