4700 Watchdog: Difference between revisions

From embeddedTS Manuals
(Created page with "The watchdog is manipulated via the ts4700ctl utility. The default INITRD linuxrc autofeeds the watchdog by daemonizing and feeding it in the background via userspace. It can be ...")
 
(Clean up and remove /dev/watchdog mention, not quite properly implemented in the shipping image)
 
Line 1: Line 1:
The watchdog is manipulated via the ts4700ctl utility. The default INITRD linuxrc autofeeds the watchdog by daemonizing and feeding it in the background via userspace. 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.
The watchdog is manipulated via the <source inline>ts4700ctl</source> utility by default. The linuxrc script starts an autofeed thread for the watchdog timer which daemonizes and automatically feeds the WDT in the background. By default, the autofeed thread is started with a value of 1 (timeout of ~2.7 s) and will feed the WDT around every 1 second interval. This is suitable for most applications. However, if it is desired to integrate the WDT more tightly in to an application thread, it is possible to manually feed the WDT. Note that the linuxrc script which is used must be modified to not start up the autofeed thread. Instead, it should feed the WDT timer directly or start up any other processes that will be responsible for feeding the WDT.
 
The WDT in the [[#Syscon|FPGA syscon]] can be fed by writing one of four values to the 16-bit register. The values have the following effects:


{| class="wikitable"
{| class="wikitable"
Line 7: Line 9:
|-
|-
| 0
| 0
| feed watchdog for another .338s
| Feed watchdog for .338s
|-
|-
| 1
| 1
| feed watchdog for another 2.706s
| Feed watchdog for 2.706s
|-
|-
| 2
| 2
| feed watchdog for another 10.824s
| Feed watchdog for 10.824s
|-
|-
| 3
| 3
| disable watchdog
| Disarm/disable the watchdog
|}
|}



Latest revision as of 13:43, 25 November 2020

The watchdog is manipulated via the ts4700ctl utility by default. The linuxrc script starts an autofeed thread for the watchdog timer which daemonizes and automatically feeds the WDT in the background. By default, the autofeed thread is started with a value of 1 (timeout of ~2.7 s) and will feed the WDT around every 1 second interval. This is suitable for most applications. However, if it is desired to integrate the WDT more tightly in to an application thread, it is possible to manually feed the WDT. Note that the linuxrc script which is used must be modified to not start up the autofeed thread. Instead, it should feed the WDT timer directly or start up any other processes that will be responsible for feeding the WDT.

The WDT in the FPGA syscon can be fed by writing one of four values to the 16-bit register. The values have the following effects:

Value Result
0 Feed watchdog for .338s
1 Feed watchdog for 2.706s
2 Feed watchdog for 10.824s
3 Disarm/disable the 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 <stdio.h>
#include <stdint.h>
#include <fcntl.h>
#include <sys/mman.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(;;) {
                // This feeds the watchdog for 10s.
                syscon[0x6/2] = 2;
                sleep(5);
        }

        return 0;
}