Set ubuntu core watchdog to specific watchdog module

Hi,

I am working on a machine that embeds an hardware watchdog. By searching into /lib/modules/5.15.0-76-generic/kernel/drivers/watchdog I located the kernel module related to the hardware watchdog.

Is it possible to make the ubuntu core watchdog (the one accessed with $ snap set core watchdog) use the module of the hardware watchdog I located? If the answer is yes, how do I dot that?

Thank you in advance

/dev/watchdog0 should be used. Do you have multiple watchdog devices in /dev?

You can configure the watchdog in /etc/systemd/system.conf.d. But this is manual. There is no way to do it from snap set. See the manual page of systemd’s system.conf (WatchdogDevice=).

An alternative is to use module_blacklist kernel command line and set it in your gadget snap, to disable other watchdogs to take /dev/watchdog0.

See

Yes I do have multiple watchdog devices because I configured an additional watchdog (/dev/watchdog1), by loading the kernel module of interest with modprobe. Therefore I would like to use this watchdog device. Are you saying that the only watchdog device I can use is /dev/watchdog0?

I tried to add WatchdogDevice=/dev/watchdog1 to the configuration file of the systemd watchdog. However, everytime I reboot ubuntu core, the watchdog device I loaded disappears, whereas the changes to the configuration file stay. I don’t understand whether I succeded in changing the watchdog device.

How can I check whether the watchdog device I am using is exactly the one that I want? Is there a way to stop petting the systemd watchdog?

Do you mean the module is not loaded on reboot? Maybe you need to add the module in modprobe.d if the module does not have the correct modalias. Could you see if modinfo on the module gives you any alias? And compare to the modalias in the /sys/devices/... of the device?

Often, the proper way to ensure you are using the right device (on Linux in general, for any kind of device), is usually to make a udev rule that matches your device and creates a symlink. Then use that symlink in the configuration file. Though this is not very Ubuntu Core style. I would just disable all the others in the kernel command line from the gadget instead.

1 Like

You should be able to use the modules_load= kernel cmdline option from the gadget to force-load your module…

Combined with the modprobe.blacklist= option to prevent loading of the default watchdog module you should end up with a single /dev/watchdog device then

Thank you for the fast response.

I think I succeded in loading the module on reboot, by adding a .conf file containing the name of module of interest to the /etc/modules-load.d. Now everytime that I reboot the system I find /dev/watchdog1.

Now I would like to tell systemd to use the loaded module as a watchdog. As mentioned above, I tried to add WatchdogDevice=/dev/watchdog1 to the configuration file of the systemd watchdog. However, if I run for example snap set core watchdog.runtime-timeout=1m, the file gets overwritten and the added line, about the device to use, diappears. Is it normal?

Could you please explain further how to make a udev rule that matches my device and create a symlink to test whether the system is using the watchdog module I want?

Thanks for the fast response.

Is it possible to do this without a gadget module, directly from the terminal of ubuntu core?

I think doing it manually might be too late in the boot process, not sure if systemd will actually recognize it as valid watchdog when it comes up later since it likely starts pinging it right on its own startup of the init binary … but that’s just a theory so you should try…

Unless this install is for random home use and not for any commercial production system I’d not mangle config files on the filesystem (i.e. udev rules, modules.conf and the like) though. By design such things should come from the gadget which usually holds all hardware specific info and basic configuration

1 Like