4 years, 12 months ago.

How to setup mbed to reboot after a fatal error?

I have a program that queries devices on a zigbee network for sensor data and sends the data to a webserver using ethernet. The code seems to be working fine when everything else is working properly. However, the code tends to crash when the zigbee network is disturbed (some wireless equipment can do it), something loses power (sometimes the breakers are intentionally flipped in our lab), the internet goes down for a bit (which seems to happen on the weekends for maintenance), etc.

I think I'm aware of all the unusual events my mbed has to watch out for to not cause a fatal error, but I'm at a loss for how to test. I would rather have the mbed reboot and start the main program again for simplicity. Right now, the mbed reboots and halts instead of restarting the main program.

I can trigger a fatal error by unplugging the ethernet cable, which outputs this on the serial terminal.

++ MbedOS Error Info ++
Error Status: 0x80020125 Code: 293 Module: 2
Error Message: CMSIS-RTOS error: Stack overflow
Location: 0x8034C45
Error Value: 0x1
Current Thread: main  Id: 0x2000833C Entry: 0x80197DD StackSize: 0x1000 StackMem: 0x20004800 SP: 0x2007FF00
For more info, visit: https://mbed.com/s/error?error=0x80020125&tgt=NUCLEO_F767ZI
-- MbedOS Error Info --

= System will be rebooted due to a fatal error =
= Reboot count(=2) reached maximum, system will halt after rebooting

I'd like to change the maximum reboot count to a ridiculously large number, or infinite, but I haven't been able to figure out how. There is error handling in mbed OS 5, but the examples are more for saving memory and debugging information rather than simply rebooting and hoping for the best. If there really is something wrong and the reboots don't help, I'll have to go fix it, but sometimes we lose valuable data when running experiments overnight or on the weekends.

Does anyone know how to setup the mbed to perpetually reboot and start the main program instead of halting on a fatal error?

2 Answers

4 years, 7 months ago.

You can reset the reboot count in the "mbed_error_reboot_callback" error handler. This call worked for me: mbed_reset_reboot_error_info() I think there is another call that just resets the reboot count.

Accepted Answer
4 years, 8 months ago.

Perhaps you could solve the problem by tracking down the reason for a stack overflow when you lose network connectivity.