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

Flash write with softdevice during assert handler

Hi,

  I need to write a 32-bit value to an NVM flash page whenever my code hits an assert failure.  This failure can occur anywhere in the code - my application, the Nordic SDK, the softdevice, etc.  I'm using SDK16, the S140 softdevice and FreeRTOS.  I'm running into issues using the normal flash write process of erase page, write new value, flush page when I hit certain asserts.  If my assert comes from a low priority task context, everything works fine.  However, if the assert is from the SDK or the softdevice, or the MCU is in interrupt context, my flash write fails.  I'm using nrf_fstorage_write() to do flash writes

  - Is there a recommended process to follow for writing a value to flash that will work in all the cases described above?

  - Do I need to disable the softdevice before writing to flash?

  - Do I need to be at task context to perform the write?  If so, is there a recommended way to force that context from the assert handler that was called inside of an interrupt?

  Since I've hit an assert, my application has stopped, and I will need to reset to continue operation.  However, I would like to store the cause of the issue for later analysis and debugging.  Note that since I've hit an assert somewhere in the code, I can't rely on everything being functional - i.e., if the softdevice asserts, I can't rely on the softdevice to schedule the flash writes.

  Thanks...

Brian

Parents Reply Children
No Data
Related