NVS in watchdog callback

Hi,

I'm trying to save system uptime when the watchdog callback occurs.

The NVS functionality works when calling nvs_write elsewhere in code.

Calling nvs_write inside the watchdog callback, I always receive -ETIMEDOUT. The documentation for NVS states"In a multi-threaded application, another thread might intercept the fault and the NVS API will return an -ETIMEDOUT error." what does that mean?

Parents Reply
  • It seems to work if I signal a thread from the WDT callback to save the uptime. I suppose the NVS write function have some mutex/semaphore stuff that should not be handled in ISR. However, it is still strange that it work with CONFIG_BT=n.

    I'm not sure whether it is to risky to rely on signaling a thread to save NVS after the watchdog has bitten as the system might be in an unstable state (the task could have crashed).

    Wouldn't it be better just to allocate a flash area for storing uptime and inside the WDT CB write directly to the flash address without using the NVS driver?

Children
No Data
Related