Tool/software: TI-RTOS
I'm sure this isn't an unusual problem, but I haven't found anything so far that helps me solve the problem.
I want to be able to log errors to memory when one happens, so I can then trigger a soft reset to allow the device to continue function while allowing me to review the error later.
I've set up an error function in my release.cfg file, so any hard fault will be routed through the error module to this function. My plan is to then use the NVS driver to store some flags, and possible a string to memory.
My project is based around the WSN example, and this function resides in the main file which also houses the main() function.
void myErrorFxn(Error_Block *eb) { // HWI exceptions are set to re-route here in release.cfg uint32_t error = 8; // Random value // Intialise NVS to store the error NVS_Params_init(&nvsErrParams); nvsErrHandle = NVS_open(1, &nvsErrParams); if (nvsErrHandle == NULL) { System_abort("NVS init fail\n"); } uint32_t status = NVS_write(nvsErrHandle, 0, &error, sizeof(error), NVS_WRITE_ERASE); if(status != NVS_STATUS_SUCCESS){ // If this happens we've got bigger problems! System_abort("NVS read error"); } NVS_close(nvsErrHandle); // Then restart SysCtrlSystemReset(); }
I'm unable to get a non-null handle back when I call NVS_open(), despite this working fine elsewhere. The only other time I open this particular NVS region is to read it in the main task to read the memory contents, where it is then closed again immediately.
Is it just not possible to re-open a driver after a hwi exception/hard fault? If so, how can this type of incident be logged?