RTL872x watchdog does not work during sleep

Hi, I'm trying to configure the hardware watchdog on a muon to reset it in case something goes wrong, but it never resets it.
What am I doing wrong?

Thanks!

source code:

#include "Particle.h"
SYSTEM_MODE(SEMI_AUTOMATIC);

Serial1LogHandler logHandler(115200, LOG_LEVEL_INFO);

void setup()
{
  Watchdog.init(WatchdogConfiguration()
                    .capabilities(WatchdogCap::SLEEP_RUNNING)
                    .timeout(20s));
  Watchdog.start();

  SystemSleepConfiguration config;
  config.mode(SystemSleepMode::HIBERNATE)
      .duration(1h);

  SystemSleepResult result = System.sleep(config);
}

void loop()
{
}


(the values set in my demo code are not realistic, I just want the watchdog to do its job)

I don't see anything obviously wrong with that code.

Watchdog.init() and Watchdog.start() both return a system error code (0 = success); it might be good to log those to see if either is returning an error code.

ok, thanks, I added the logs and they indeed return 0.
After that, the watchdog never kicks in.

I tried:

  • SYSTEM_MODE(AUTOMATIC);
  • config.mode(SystemSleepMode::STOP)
  • config.mode(SystemSleepMode::ULTRA_LOW_POWER)
  • .timeout(20000));
  • .timeout(20s));

unplugged:

  • an I2C sensor from the QWIIC connector in case this was causing issues
  • my serial cable connected to TX/RX on the 40pin connector
  • the usb cable with which I'm programming it
  • the only thing powering the board is the original battery

Any other ideas?
Thanks,



0000001126 [hal] INFO: Remove Ethernet interface
0000001128 [net.ifapi] INFO: Netif en2 deleted
0000001157 [sys.power] WARN: Disabled by configuration
0000001172 [system] INFO: Device 99874897378947845879 started
0000001234 [hal] INFO: WiFi KM0 firmware initialization started   result=0 (RAM start=10006000 end=1001a000)
0000001239 [hal] INFO: WiFi KM0 firmware initialization completed result=0 (RAM start=10006000 end=10013fa0 reserved=00005000)
0000001261 [hal] INFO: rltk_wlan_set_netif_info: 0, 94:94:4a:07:15:48
0000001391 [hal] INFO: WiFi on
0000001731 [hal] INFO: WiFi off
0000002352 [system.nm] INFO: State changed: NONE -> DISABLED
0000002374 [comm] INFO: channel inited
0000002380 [app] INFO: Watchdog init result=0
0000002382 [app] INFO: Watchdog start result=0

code with logs:

#include "Particle.h"
SYSTEM_MODE(SEMI_AUTOMATIC);

Serial1LogHandler logHandler(115200, LOG_LEVEL_INFO);

void setup()
{
  bool r;
  r = Watchdog.init(WatchdogConfiguration()
                             .capabilities(WatchdogCap::SLEEP_RUNNING)
                             .timeout(20000));

  Log.info("Watchdog init result=%d", r);

  r = Watchdog.start();
  Log.info("Watchdog start result=%d", r);


  SystemSleepConfiguration config;
  config.mode(SystemSleepMode::HIBERNATE)
      .duration(1h);

  SystemSleepResult result = System.sleep(config);
}

void loop()
{
}

This is on deviceOS 6.3.0

I have tested this on a Photon 2, same results, no watchdog reset.

From this topic it seems clear that on certain sleep modes one can configure the watchdog to keep running on Gen3 devices:

However I'm still not able to make it work on Muons or Photon 2's.

PS: I updated the title of this topic to reflect the new findings.

Could it be that the option SLEEP_RUNNING does not work on RTL827x MCUs?
I took out the sleep option to nail things down.

If I use this code:

#include "Particle.h"
SYSTEM_MODE(SEMI_AUTOMATIC);
SerialLogHandler logHandler(LOG_LEVEL_TRACE);

void setup()
{
  waitFor(Serial.isConnected, 5000);
  delay(1000);

  bool r;
  r = Watchdog.init(WatchdogConfiguration()
                        .timeout(20000));
  Log.info("Watchdog init result=%d", r);

  r = Watchdog.start();
  Log.info("Watchdog start result=%d", r);

}

void loop()
{
}

The device resets after 20 seconds. This is fantastic.

As soon as I add:

.capabilities(WatchdogCap::SLEEP_RUNNING)

The device never resets, so I do not see the watchdog working even when the device is awake.

I'm currently using DeviceOS 6.3.0, but tried 5.3 quickly, where the feature came out, and there I was still not able to make this work.

Where could the problem be?
Thanks

Since the RTL872x does not support stopping the watchdog in sleep, SLEEP_RUNNING is always true and can't be turned off.

When I briefly looked yesterday I didn't see any obvious check where that would have caused a failure, but it is quite possible that you can't set it.

@rickkas7, the Muon has an onboard AM1805 RTC/Watchdog. I know that DeviceOS will use it for the RTC if found but does it also defer watchdog functionality from the built-in HW watchdog to the AM1805?

Device OS only uses the AM1805 RTC when HAL_PLATFORM_EXTERNAL_RTC is defined for the platform, and it's only defined for Tracker SoM. This is presumably because Muon and M-SoM are a single platform, and the M-SoM doesn't have a AM1805. So none of the features of the AM1805 are built into Device OS for Muon.

1 Like

Alright, let's set aside SLEEP_RUNNING for now.

Has there been any update on why the watchdog isn’t waking up a Photon 2 or a Muon after 20 seconds when they hibernate?

#include "Particle.h"
SYSTEM_MODE(SEMI_AUTOMATIC);
SerialLogHandler logHandler(LOG_LEVEL_TRACE);

void setup()
{
  waitFor(Serial.isConnected, 5000);
  delay(1000);

  bool r;
  r = Watchdog.init(WatchdogConfiguration()
                        .timeout(20000));
  Log.info("Watchdog init result=%d", r);

  r = Watchdog.start();
  Log.info("Watchdog start result=%d", r);

  SystemSleepConfiguration config;
  config.mode(SystemSleepMode::HIBERNATE)
      .duration(1h);

  SystemSleepResult result = System.sleep(config);
}

void loop()
{
}

Thanks!

That should work; I think engineering will need to investigate.

ok that sounds promising, are you raising this to their attention or should I?
Thanks again.

Hey Paul, how do you know this? I thought we needed the RK library for using the onboard ab1805.
Thanks

@gusgonnet, as @rickkas7 pointed out, the RTC portion of the AM1805 is only used by DeviceOS if the device is a Tracker SoM. There is no guarantee that an MSoM will have an AM1805 so it doesn't kick in on the Muon. I wish there was a way, like the PMIC to specify in user code that an AM1805 is present, for any device (that can run newer versions of DeviceOS).

2 Likes

Hey, just following up in case this got forgotten.
Any news please let me know.
Thanks

The watchdog on RTL872x does not appear to run in sleep mode, but the Realtek documentation indicates that it should. This is being followed up with Realtek.

2 Likes