Imbrium Logo

Enabling the watchdog on the Arcturus uCdimm VZ


I want to user the hardware watchdog time in the 68VZ328. This involves having an application running in the background that periodicall writes to the watchdog.

The first thing I did was to add /dev/watchdog into the list of character devices. This is done in the file /home/uClinux-dist/vendors/Arcturus/uCdimm/Makefile. I simply added the correct node at the end of the devices list:

DEVICES = \
		[...]
	        zero,c,1,5     random,c,1,8       urandom,c,1,9 \
        \
        ipsec,c,36,10 \
        ledman,c,126,0 \
        watchdog,c,10,130

The romfs installation script that is invoked from the toplevel makefile will create the entry in romfs/dev/ and the genromfs will make the node that you will later on see in the actual ROM file system generated. For information about the romfs itself and how to mount it, see here

Next, I wanted to include a simple write access every so-and-so seconds in my application. I looked at the busybox implementation of the watchdog and found the following code in watchdog.c (Ok, I could have thought of this myself, since this is quite simple :) All it does is open a file and periodically write a 0 (zero) every 30 seconds to it:

if ((fd=open(argv[1], O_WRONLY)) == -1) {
                perror_msg_and_die(argv[1]);
        }
        while (1) {
                sleep(30);
                write(fd, "\0", 1);
        }

So if I replace argv[1] with "/dev/watchdog" I should be set, right?!