Using Zephyr's settings subsystem along with Bluetooth sometimes results in an MPSL assertion.

nRF Connect SDK: 2.1.2

I'm using Zephyr's settings subsystem (with NVS as the backend storage implementation).  With this setup, when the method settings_save() is called, changed settings are written to flash.

I've noticed that when Bluetooth is connected and data is flowing (via BLE notifications), sometimes calling settings_save() results in an assertion with MPSL.  Specifically, this assertion:

<err> mpsl_init: MPSL ASSERT: 108, 659

This seems to indicate an assertion has occurred on line 659 of file 108.  Unfortunately, because MPSL is closed-source, I have no way of looking at the code that generated this assertion to determine the cause.  It's possible my code is doing something wrong that leads to this assertion, or it could be a bug in the MPSL, but I cannot investigate further.  I'm hoping someone at Nordic with access to the MPSL source can look at line 659 of file 108 and let me know what this assertion means, and if there's anything I can do to prevent it.

Some notes about the cause:

  • This assertion occurs intermittently.  It does not happen every time settings_save() is called.
  • I have never observed it to happen without Bluetooth connected (and I've tried thousands of times!)
  • I have never observed it to happen with Bluetooth connected but idle, that is, not sending notifications (and again I've tried thousands of times!)
  • When my application is sending notifications, it acts as a peripheral with 15ms connection interval, and it sends one BLE notification of approximately 79 bytes every interval.  So, that's one 79 byte notification every 15ms, or approximately 5 kilobytes per second.  Calling settings_save() during this data transmission is when I've seen the assertion occur.  But, even then, it does not occur every time.
  • The assertion seems far more likely to occur on the first settings_save() on a fresh chip.  It occurs approximately 40% of the time in this case.  I suspect that, when settings_save() is called for the first time, additional work is done to set up the NVS structure in flash so there's more opportunity for the failure to occur.  After this first settings_save(), subsequent calls are much less likely to trigger the assertion.

I'm hoping you can provide some more information on this specific assertion and what, if anything, I can do to prevent it.  If you need more information about my application, I can answer any questions you have.  However, the application itself is proprietary and cannot be shared.

Thanks!

Parents
  • Hi Ricky, 

    The information I got from the team is that this error is related to the RTC timer: "It seems like you're trying to set up a CC for a time that has already passed." There must be something wrong with the timing with MPSL.
    Could you give some more information about your LFCLK oscillator, do you use external crystal or it's the internal RC . Have you configured your application to use the correct LFCLK source?

    Do you call settings_* API inside bt_ready() callback ? 
    How often do you call settings_save() ? how large is the data to store? 

  • Thanks for the response!

    Sorry I took so long to get back to you. I tried to replicate the issue with a minimal reproducible example that I could share, running on the nRF52840DK.  However, when I created a project that just handled settings and sent notifications (at the same rate as my application), I was unable to observe the issue.

    This leads me to believe there's more to it than I thought. Something about my application or hardware is causing the issue to occur; it's not just Bluetooth and the settings subsystem. I'll have to look into it more next week.

    To answer your questions:

    • We're using the internal RC, and have configured the application like so:
      CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
    • No settings API calls are made in the bt_ready() callback. I don't even have one, as I call bt_enable(NULL) (no callback).
    • The application rarely calls settings_save(), but calling it just once is enough to trigger the issue. It's not related to calling it many times. The amount of data saved is 5 bytes. The setting name is 15 bytes.

    I'll keep experimenting next week and report back if I find anything.  In the meantime, I'm going to assume it's something I'm doing and not an issue with the MPSL.

    Thanks for your help!

Reply
  • Thanks for the response!

    Sorry I took so long to get back to you. I tried to replicate the issue with a minimal reproducible example that I could share, running on the nRF52840DK.  However, when I created a project that just handled settings and sent notifications (at the same rate as my application), I was unable to observe the issue.

    This leads me to believe there's more to it than I thought. Something about my application or hardware is causing the issue to occur; it's not just Bluetooth and the settings subsystem. I'll have to look into it more next week.

    To answer your questions:

    • We're using the internal RC, and have configured the application like so:
      CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
    • No settings API calls are made in the bt_ready() callback. I don't even have one, as I call bt_enable(NULL) (no callback).
    • The application rarely calls settings_save(), but calling it just once is enough to trigger the issue. It's not related to calling it many times. The amount of data saved is 5 bytes. The setting name is 15 bytes.

    I'll keep experimenting next week and report back if I find anything.  In the meantime, I'm going to assume it's something I'm doing and not an issue with the MPSL.

    Thanks for your help!

Children
No Data
Related