TS-4710 Watchdog: Difference between revisions

From embeddedTS Manuals
(Created page with "The watchdog is manipulated via the tshwctl utility. The startup scripts automatically run and daemonize tshwctl to feed the watchdog by default. It can be armed in 3 modes ...")
 
No edit summary
Line 23: Line 23:
You can feed the watchdog from your application by poking a register:
You can feed the watchdog from your application by poking a register:
<source lang=c>
<source lang=c>
#include <stdio.h>
#include <sys/mman.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <assert.h>
 
int main()
{
        int mem;
        volatile uint16_t *syscon;
 
        mem = open("/dev/mem", O_RDWR|O_SYNC);
        syscon = mmap(0,
                      getpagesize(),
                      PROT_READ|PROT_WRITE,
                      MAP_SHARED,
                      mem,
                      0x80004000);


        for(;;) {
static volatile unsigned short *syscon;
                // This feeds the watchdog for 10s.
static unsigned short peek16(unsigned int adr) {
                syscon[0x6/2] = 2;
return syscon[adr / 2];
                sleep(5);
}
        }


        return 0;
static void poke16(unsigned int adr, unsigned short val) {
syscon[adr / 2] = val;
}
int main(void) {
    int devmem = open("/dev/mem", O_RDWR|O_SYNC);
    assert(devmem != -1);
    syscon = (unsigned short *) mmap(0, 4096,
          PROT_READ | PROT_WRITE, MAP_SHARED, devmem, 0x80004000);
    while(1) {
          poke16(0x6, 0x2); // Feed watchdog
          sleep(5);
    }
    return 0;
}
}
</source>
</source>

Revision as of 10:45, 27 February 2013

The watchdog is manipulated via the tshwctl utility. The startup scripts automatically run and daemonize tshwctl to feed the watchdog by default. It can be armed in 3 modes (0 - .4s, 1- 2.7s, 2 - 10.8s). It can be either auto-fed from a background process that continually feeds the watchdog while running (--autofeed option), or via a /dev/watchdog UNIX named pipe which receives single ASCII characters which are written to feed it from another application.

Value Result
0 feed watchdog for another .338s
1 feed watchdog for another 2.706s
2 feed watchdog for another 10.824s
3 disable watchdog

Watchdog by default comes out of reset armed for .338 seconds. TS-BOOTROM firmware feeds for 10.824 and OS code has 10.824 seconds to take over.

You can feed the watchdog from your application by poking a register:

#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <assert.h>

static volatile unsigned short *syscon;
static unsigned short peek16(unsigned int adr) {
	return syscon[adr / 2];
}

static void poke16(unsigned int adr, unsigned short val) {
	syscon[adr / 2] = val;
}
 
int main(void) {
     int devmem = open("/dev/mem", O_RDWR|O_SYNC);
 
     assert(devmem != -1);
     syscon = (unsigned short *) mmap(0, 4096,
          PROT_READ | PROT_WRITE, MAP_SHARED, devmem, 0x80004000);
 
     while(1) {
          poke16(0x6, 0x2); // Feed watchdog
          sleep(5);
     }
 
     return 0;
}