epoch1970
Posts: 1841
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

DT bcm watchdog - I can load it but can I start it?

Thu Jul 12, 2018 11:47 am

I've searched briefly, apologies if the question is redundant.

With dtparam=watchdog=on, I can have linux load the watchdog device. So it activates once linux has been loaded.
Is there a way to start/reset the device directly from the device tree? Basically I want watchdog to reset the system if for some reason loading linux fails/takes more than 15 secs.

Thanks in advance

Background: I'm trying to get u-boot to work with watchdog. I want the dog to start counting as soon as u-boot starts; I expect to reset it right before linux boot, and have a running linux under 15 secs, at which time a userland daemon will take over control of the device.
I'm still looking for uboot's "watchdog (load|start|stop)" command, not sure it exists... But I can manipulate the DT before starting linux, hence the question.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1772
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: DT bcm watchdog - I can load it but can I start it?

Thu Jul 12, 2018 1:33 pm

In short, no. Although the firmware is loading and manipulating the Device Tree, (with a few exceptions) only Linux is acting on it, so you are effectively asking if we can configure Linux to start the watchdog timer in case Linux doesn't load correctly. That's not as stupid as it sounds - the watchdog driver could be built into the kernel image and started quite early - but starting it from U-boot seems like a better option.

Neither the watchdog drivers nor the overall watchdog frame seem capable of auto starting - they all seem to rely on a kick from user-space via an ioctl to start the countdown - so even if it was desirable it isn't possible without kernel changes.

epoch1970
Posts: 1841
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: DT bcm watchdog - I can load it but can I start it?

Thu Jul 12, 2018 2:17 pm

Thank you for your response.
I have peered into my u-boot code and found out the version I'm using is indeed watchdog-ready on Pi. That is thanks to Paolo Pisati, who contributed code in January 2017 to u-boot (it has been committed upstream).

Thing is, by default there is no way to interact with it and no trace it is active... Finally I had the idea of hacking into the DT before booting (like removing the mmc0 node) or setting rootfs to a non-existent value. In both cases I got a hanging or crashed system, and 15 secs later the machine restarted.

So all is well, my Pi crashes like a champ :)
Thanks again.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Return to “Device Tree”

Who is online

Users browsing this forum: No registered users and 3 guests