Debugger Electron Hard Fault on ApplicationWatchdog

I’m using @rickkas7’s electronsample library/app to create a new app. In the process of doing this, I’ve been doing some debugging using a Particle debugger. When compiling that example for debugging, I always immediately get a hard fault.

If I comment out the following line, I do not get a Hard Fault:
AppWatchdogWrapper watchdog(60000);

If I remove his AppWatchdogWrapper and use the system ApplicationWatchdog, I get the same error with these two lines too:
ApplicationWatchdog wd(60000, System.reset);
ApplicationWatchdog wd(60000, System.reset, 1800);

I’ve tried to break inside that function to see where the error is stemming from, but there really doesn’t seem to be much going on. Any insights as to why ApplicationWatchdog can’t be debugged? For now I am using the following to get around the issue:

#ifndef USE_SWD_JTAG
AppWatchdogWrapper watchdog(60000);
#endif

I’m building this on firmware v1.0.1 for Electron

@ParticleD, or @mstanley are you able to assist?

I’d like to get @rickkas7’s expertise on this, since he wrote these.

But, I actually do have a theory on this one. In device OS v1.0.0, a breaking change occurred where libraries could not be initialized immediately when included–as they may rely on not yet initialized dependencies in the device OS. Instead, libraries should be included but not initialized until they were called in the setup loop with a .begin() or similar function.

The “proper” way to do it has always been the above recommended way, but it hasn’t been a breaking change until 1.0.0.

It looks like in Rick’s documentation, the following is stated `

Make sure you call these out of setup() and loop, respectively.

batteryCheck.setup();
batteryCheck.loop();

I find this particularly odd since this goes against the paradigm, but there’s likely a reason for it. Perhaps Rick can shine some light on this, assuming I’m on the right track.

1 Like

@rickkas7 any news with this?