ts-7000
[Top] [All Lists]

[ts-7000] wdt2 cuts in during reboot of TS-7260 (& fix)

To:
Subject: [ts-7000] wdt2 cuts in during reboot of TS-7260 (& fix)
From: "Clark" <>
Date: Tue, 16 Aug 2011 23:17:19 -0000
Nothing fancy here, but it works, and I hope it helps... 

We noticed that the reboot sequence would sometimes not reach its end, and a 
hard reset would occur, say while unmounting local file systems.  Obviously not 
ideal.  A standard UNIX technique here, just add a signal handler for the 
SIGTERM signal.  Then the handler physically turns off the hardware timer 
before exiting.  Source code:

/* wdt2.c, modified. */

#include <unistd.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <stdio.h>
#include <fcntl.h>
#include <assert.h>
#include <signal.h>

static volatile unsigned char *wdt_control;
static volatile unsigned char *wdt_feed;


static void
sig_hndlr( int signo )
{
    //Turn off wdt
    *wdt_feed=0x05;
    *wdt_control=0x00;
}

static int
registerSignalHandlers() 
{
  struct sigaction act;

 /* Install signal handler */
  act.sa_handler = sig_hndlr;
  sigemptyset(&act.sa_mask);
  act.sa_flags = 0;
  if( sigaction( SIGTERM, &act, NULL ) < 0 ) return 0;
  else return 1;
}

int main(void)
{

        int fd = open("/dev/mem", O_RDWR|O_SYNC);
        assert(fd != -1);

        wdt_control = (unsigned char 
*)mmap(0,getpagesize(),PROT_READ|PROT_WRITE,MAP_SHARED,fd,0x23800000);
        wdt_feed = (unsigned char 
*)mmap(0,getpagesize(),PROT_READ|PROT_WRITE,MAP_SHARED,fd,0x23C00000);

        if( !registerSignalHandlers() ) {
      fprintf( stderr, "Problem registering signal handler\n" ); 
    }   
        //printf("%d\n",*wdt_control);

        *wdt_feed=0x05;
        *wdt_control=0x07;

   //printf("%d\n",*wdt_control);
   
    while(1)
    {
      *wdt_feed=0x05;
       sleep(5);
    }

}



------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/ts-7000/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/ts-7000/join
    (Yahoo! ID required)

<*> To change settings via email:
     
    

<*> To unsubscribe from this group, send an email to:
    

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

<Prev in Thread] Current Thread [Next in Thread>
  • [ts-7000] wdt2 cuts in during reboot of TS-7260 (& fix), Clark <=
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU