How to effectively use watchdog in mbed?

Hello,

just for info, you can handle MbedOS crash according to Error handling - API references and tutorials | Mbed OS 6 Documentation and additional info is here.

According to platform/mbed_lib.json are necessary setting already set for auto reboot of your target. However the counter is set to 1 so the MbedOS will stop after first crash, but it can be solved in two ways.

  1. insert the function below before the main. That will reset the counter every time when a crash occurs
   void mbed_error_reboot_callback(mbed_error_ctx *error_context)
   {
       error_context->error_reboot_count = 0; // reset counter
   }
  1. insert settings below to mbed_app.json. That will set a max for the counter. Two boolean macros do not may be set for your case
   {
    "target_overrides": {
         "*": {
           "platform.crash-capture-enabled": true,
           "platform.fatal-error-auto-reboot-enabled": true,
           "platform.error-reboot-max": 10
         }
       }
   }

BR, Jan

3 Likes