A Hardware watchdog and shutdown button

Similar documents
lcdproc -- LCD displays easy to use and easy to build

Measuring air pressure with Linux

USER S MANUAL. PH232Ex1. #1 RS-232 Serial Port to Ethernet, Terminal Server/Client. Doc No: PH232Ex1-UM-001 IPEX. (IP Electronix)

Hardware Manual. PCMCIA 1 Port RS EDITION APRIL 1999

Cytron USB to UART Converter UC00A

ISOLATED RS-232 TO RS-422/485 CONVERTER

Modtronix Engineering Modular Electronic Solutions SBC28DC. Single board computer for 28 pin DIP PICs

UTS485 & ULOG485 USB Converter Owner's Manaul

EZL-200F Application Notes (003) Serial Interface (RS232/RS422/RS485)

LCMM024: DRV8825 Stepper Motor Driver Carrier,

DEV-1 HamStack Development Board

Connector and Cable Specifications

8 Port USB to RS- 232/422/485 Octal Adapter. Product Manual. Coolgear, Inc. Version 1.1 April 2018 Model Number: USB-8COMi-RM.

Product Manual. USB to Optical Adapter Industrial Isolated RS- 232/422/485. Coolgear, Inc. Version 2.1 December 2018 Model Number: USB-COMi-Si-M

MMI6070 Quick Start Guide

QuVIS CONNECTOR PINOUT GUIDE

Figure 1. LCD & Keypad - RS232 Terminal

A4988 Stepper Motor Driver Carrier, Black Edition

UTS400 series USB Converter

Sender Receiver Sender

Introduction & Specifications of Hi-Speed USB to Serial Adapters

GT- HE910-EUD. Product description Rev. 8 21/02/ Overview

3.1 I-7560 Pin Assignment and Specifications: Introduction

MP6500 Stepper Motor Driver, Digital Current Control

PCL Port RS-232 Interface Card

Product Manual. USB BAY-4 Port Serial DB- 9 RS-232 Adapter with FTDI Chipset. Coolgear, Inc. Version 1.1 September 2017 Model Number: USBG-BAY4

GT- IRDM-9603 Product description Rev. 2 17/06/2014

Hardware Manual PCMCIA DUAL RS EDITION MAY 1999

W&T Manual Interface modules W&T

ANC Series RS-422 Serial Communications Adapter

USB to RS-232/RS422/485. US-101-I USB To Serial Operation Manual

COMMUNICATION SOFTWARE FOR MM-122A MA-716A

QUASAR PROJECT KIT # ATMEL AVR PROGRAMMER

A4988 Stepper Motor Driver Carrier with Voltage Regulators

TH2683 Insulation Resistance Meter. User s Mannual

Rapid28iXL PIC Prototyping PCB User Manual

Revision: 5/7/ E Main Suite D Pullman, WA (509) Voice and Fax. Power jack 5-9VDC. Serial Port. Parallel Port

Digilab 2E Reference Manual

CSCI 6907 PROJECT PROPOSAL LIGHTS OUT MANAGEMENT

RS-232 Driver Module

MEGATRONICS V3.0 QUICK START GUIDE

A4988 Stepper Motor Driver Carrier

APPLICATION NOTE 655 Supervisor ICs Monitor Battery-Powered Equipment

SitePORTAL Lite TA-SPL32-R48

DIY KIT 121. ATMEL 89Cx051 PROGRAMMER

PCI Express 16-Port Serial I/O Cards

User Manual For CP-JR ARM7 USB-LPC2148 / EXP

Instruction Manual for BE-SP3 Circuit. 10/21/07

MEV Limited USB232/485 INSTRUCTION MANUAL

Device: FDRV-04S. This document version: v1. Matches module version: v2 [2 Oct 2015] Document revision date: 9 November 2015

Wrenchman, Inc Old Hwy. # 8 Suite # 122 New Brighton, Minnesota (651)

PCI Express 4-Port Industrial Serial I/O Cards

Electronic Coin Toss

EX & EX-45362IS 2S RS232/422/485 3-in-1 Serial PCIe Card

Powered RS Port PCIe Card

WiFi to RS-232 adapter user manual

Starter Guide Version Sphinx Access Control System

This, plus your Basic Stamp 2 or Stamp Stack 2 Microcontroller (not included) will let you customize your robot s behavior any which way you want!

PCIe-400 USER S MANUAL

TRP-C37 User s Manual

Model:UT-8814 USB/RS-232 Commercial interface converter. Instruction Manual

Preliminary. PACKAGE - 28-pin MLP (5mm X 5mm) Example Circuit Diagram CP V. 48MHz Oscillator. USB Function Controller 512B EEPROM

Basic Input/Output Operations

Rapid40iXL PIC Prototyping PCB User Manual

TRP-C37. Ethernet to RS232/422/485 Converter. User s Manual. Printed Apr.2014 Rev 1.3

SECURE DIGITAL ACCESS SYSTEM USING IBUTTON

A LCD display with ethernet interface

STEP X - Name of Step QUICK START GUIDE SP385A-R3, SP390A-R3 USB TO RS CONVERTER 24/7 TECHNICAL SUPPORT AT OR VISIT BLACKBOX.

Industrial Quad-band GPRS/GSM Modem GTM-201 Series. User Manual

RS-232 Connector Pin Assignments

USB RS232 Level Conversion copyright 2/25/07 Joe Pardue

EX KVIS RS232/422/485 3-in-1 Serial to USB Adapter (w/ 4KV Isolation, 15KV ESD Surge Protection)

Bluetooth TO Serial CONVERTER E-P132-B

SYLLABUS OF ADVANCED CARD LEVEL & CHIP LEVEL TRAINING ( DESKTOP AND LAPTOP )

Pololu 12V Step-Up/Step-Down Voltage Regulator S10V2F12

DinBox M36 Hardware Description Guide

BeagleBone Black USB Expansion RS232 Module Cape Coolgear, Inc. Version 1.1 September 2017 Model Number:

PIA High-speed Multi I/O Module. Description

USB to RS-232/RS422/485. URK-228-I USB To Serial Operation Manual

User s Manual ANC-6023 RS232/RS422/Video Sync Interface Adapter

Using PSpice to Simulate Transmission Lines K. A. Connor Summer 2000 Fields and Waves I

Display Real Time Clock (RTC) On LCD. Version 1.2. Aug Cytron Technologies Sdn. Bhd.

AX1500. Dual Channel Digital Motor Controller. Quick Start Manual. v1.9b, June 1, 2007

Button Code Kit. Assembly Instructions and User Guide. Single Button Code Entry System

TABLE OF CONTENTS. Communication Functions

Bluetooth to RS-232 Converter. RT-132B Bluetooth Adaptor Operation Manual

Embedded Systems and Software

Device: PLT This document Version: 3.0. For hardware Version: 4. For firmware Version: Date: April 2014

Product Manual. 2 Port USB to RS-422 /485 Optical Isolated Adapter. Coolgear, Inc. Version 1.1 March 2018 Model Number: USB-2COMi-Si-M

Repairing Williams C.P.U. boards. System 3, 4, 6 and 7. Test IC to check basic functionality of the cpu and driver 'out' of the pinball machine.

A64-OLinuXino 64-bit open source embedded computer

XC164CS Prototype Board

ARB-0612 Converter USB RS 232/422/485/485-4W/TTL Manual

DTMF BASED HOME AUTOMATION

SOHORAID Series. SR2611 Series. Manual. Two Bays RAID 1 Internal Module

EMERALD-MM-8P. 8-Channel Software Programmable Protocol. Serial Port PC/104 TM Module. User Manual V1.20

RCS/6000. Hardware. Manual

Section 1 Introduction

Galep-Adapter DIL-40 => ISP-ASYNC/SYNC Article-No.:

NCOM SERIAL DEVICE SERVER 1XX SERIES USER S MANUAL

Transcription:

LinuxFocus article number 239 http://linuxfocus.org A Hardware watchdog and shutdown button by Guido Socher (homepage) About the author: Guido loves Linux because it is always interessting to discover how computers really work. Linux with its modularity and open design is the best system for such adventures. Abstract: The LCD control panel article explained how to build a small microcontroller based LCD panel with enormous possibilities. Sometimes you don t need all those features. The hardware which we design in this article is a lot cheaper (the LCD panel was already a bargain) and includes just 2 important features from the LCD panel: A button to shutdown the server A watchdog to supervise the server The hardware consist only of widely available parts. You will have no problems to get those parts. All parts together will cost you about 5 Euro. What is a watchdog? A watchdog in computer terms is a very reliable hardware which ensures that the computer is always running. You find such devices in the Mars Pathfinder (who wants to send a person to the mars to press the reset button?) or in some extra expensive servers. The idea behind such a watchdog is very simple: The computer has to "say hello" from time to time to the watchdog hardware to let it know that it is still alive. If it fails to do that then it will get a hardware reset. Note that a normal Linux server should be able to run uninterrupted for several month, in average probably 1-2 years without locking up. If you have machine that locks up every week then there is

something else wrong and a watchdog is not the solution. You should check for defect RAM (see memtest86.com) overheated CPUs, too long IDE cables... If Linux is so reliable that it will run for a year without any problems then why do you need a watchdog? Well the answer is simple to: make it even more reliable. There is as well a human problem related to that. A server that made no trouble for a year is basically unknown to the service personal. If it fails then nobody knows where it is? It might as well lock up just before Christmas when everybody is at home. In all such cases a watchdog can be very useful. A watchdog does however not solve all of the problems. It is no protection against defect hardware. If you include a watchdog in your server then you should also ensure that you have well dimensioned (probably not the latest BIOS bugs and chipset bugs, properly cooled hardware). How to use the watchdog? The watchdog we design here only ensures that user space programs are still executing. To have a truly reliable system you still have to monitor your applications (web-servers, databases) and your system resources (disk space, perhaps CPU temperature). You can do this via other user space applications (crontab). All this is already described in the LCD control panel article. Therefore I will not go into further details here. Examples? Here is a small script that can monitor networking, swap usage and disk usage.!/bin/sh PATH=/bin:/usr/bin:/usr/local/bin export PATH Monitor the disk ---------------- check if any of the partitions are more than 80% full. (crontab will automatically send an e-mail if this script produces some output) df egrep (8.% 9.% 100%) Monitor the swap A server should normally be dimensioned such that it does not swap. Swap space should therefore be constant and limited. ---------------- check if more than 6 Mb of swap are used swpfree= free awk /Swap:/{ print $3 } if expr $swpfree \> 6000 > /dev/null ; then echo "$0 warning! swap usage is now $swpfree" echo " " free echo " " ps auxw

fi Monitor the network ------------------- your _own_ IP addr or hostname: hostn="linuxbox.your.supercomputer" if ping -w 5 -qn -c 1 $hostn > /dev/null ; then ok host is up echo "0" > /etc/pingfail else no answer count up the ping failures if [ -r /etc/pingfail ]; then pingfail= cat /etc/pingfail else we do not handle the case where the pingfail file is missing exit 0 fi pingfail= expr "$pingfail" "+" 1 echo "$pingfail ping failures" echo "$pingfail" > /etc/pingfail if [ $pingfail -gt 10 ]; then echo "more than 10 ping failures. System reboot..." /sbin/shutdown -t2 -r now fi fi --- end of monitor script --- You can combine this with a crontab entry that will run the script every 15 minutes: 1,15,30,45 * * * * /where/the/script/is The watchdog hardware There is no standard relay. Every manufacture has it s own design. For our circuit it matters very much what the inner resistance of the coil is. Therefore you find below 2 circuits one for a 5V, 500 Ohm relay and one for a 5V, 120 Ohm relay. Ask for the impedance of the relay or measure it with a Ohmmeter before you buy it. You can click on the schematic for a bigger picture. 120 Ohm relay:

500 Ohm relay: The shutdown button is a push button that connects RTS and CD when pressed. It looks a bit strange in the schematic because Eagle does not have a better symbol. I don t include a part list in this article. You can see what you need in the above schematic (Don t forget the DB9 connector for the serial line). For the diodes you can use any diode, e.g 1N4148. Personally I believe that the circuit with the 500 Ohm relay is better because you do not need R4 and do not need a 2000uF (or 2200uF) capacitor. You can use a smaller 1000uF capacitor for C1. Note: That for the 120 Ohm circuit you need a Red LED and for the 500 Ohm Relay a green LED. This is not joke. The voltage drop over a green LED is higher than over a red LED. Board layout, eagle files and postscript files for etching the board are included in the software package which you can download at the end of the article. The Eagle CAD software for Linux is available from cadsoftusa.com.

How the circuit works The watchdog circuit is build around the NE555 timer chip. This chip includes 2 comparators, a Flipflop and 3 resistors 5K Ohm each to have a reference for the comparators. Whenever the pin named threshold (6) goes above 2/3 of the supply voltage then the Flipflop is set (state on). Now look at the schematic of our circuit: We use the RTS pin from the serial line as supply voltage. The voltages on the RS232 serial line interface are +/- 10V therefore we need a diode before capacitor C1. The capacitor C1 is charged very quickly and serves as a energy storage to be able to switch on the relay for a moment. Capacitor C2 is charged very slowly over the 4.7M resistor. The transistor T1 discharges the capacitor C2 if it gets a short pulse via the RS232 DTR pin. If the pulses are not coming (because the computer has locked up) then the capacitor C2 will eventually (the time is about 40 seconds) be charged above 2/3 of the supply voltage and the Flipflop goes to "on". The capacitor C1, resistor R2 the LED and the relay have to be dimensioned such that the relay is switched on shortly from the energy in capacitor C1 but there is not enough current to keep the relay on all the time. We want the "reset button" to be "pressed" just for a second or two. The LED will stay on until the server comes up again after a reset. As you can see in the schematic there is as well a shutdown button connected to pin CD. If you press it for a short while (15 sec) then the driver software will run "shutdown -h now" and shutdown the server. This is for normal maintenance operations and has nothing to do with the watchdog. The driver software

The driver software is a small C program that can be started from the /etc/init.d/ scripts. It will permanently switch on the RS232 pin RTS and then send pulses to DTR every 12 seconds (the timeout of our watchdog is 40 seconds). If you shut down your computer normally then the program will switch off RTS and give a last pulse to DTR. The effect is that the supply voltage capacitor (C1) will already be discharged before the timeout comes. Therefore the watchdog will not hit under normal operations. To install the software unpack the linuxwd-0.3.tar.gz file which you can get from the download page. Then unpack it and run make to compile. Copy the resulting linuxwd executable to /usr/sbin/linuxwd. Edit the provided linuxwd_rc script (for redhat/mandrake, or linuxwd_rc_anydist for any other distribution) and enter the right serial port where the hardware is connected (ttys1=com2 or ttys0=com1). Copy the rc script then to /etc/rc3.d/s21linuxwd and /etc/rc5.d/s21linuxwd That s it. Testing When you have soldered everything together you should test first the circuit before connecting it to the computer. Connect the pin that will later connect to the RTS line of the serial port to a 9-10V DC power supply and wait 40-50 seconds. You should hear a little click when the relay is switched on and the LED should go on. The relay should not stay permanently on. The LED will stay on until you connect as well the line that will later go to DTR to +10V. When you have verified that this works you can connect it properly to the computer. The linuxwd program has a test mode where it produces some printouts and stops after some time to sent pulses over DTR to simulate a locked up system. Run the command linuxwd -t /dev/ttys0 to run linuxwd in test mode (use /dev/ttys1 if you have the hardware on COM2). Hardware installation The RS232 interface has the following pinout: 9 PIN D-SUB MALE at the Computer.

9 PIN-connector 25 PIN-connector Name Dir Description 1 8 CD input Carrier Detect 2 3 RXD input Receive Data 3 2 TXD output Transmit Data 4 20 DTR output Data Terminal Ready 5 7 GND -- System Ground 6 6 DSR input Data Set Ready 7 4 RTS output Request to Send 8 5 CTS input Clear to Send 9 22 RI input Ring Indicator Connecting the circuit to the RS232 should be straight forward. To connect the CPU reset line with the relay you need to locate the wires that go to the reset button on your computer. Connect the relay from our circuit in parallel to the reset button. Conclusion A watchdog is certainly not a 100% guarantee to have reliable system but it adds another level of security. A problem can be a situation where the file system check does not complete after a hardware reset. The new journaling filesystems might help here but I have not tried them out yet. The watchdog presented here is inexpensive, not too complex to build and almost as good as most commercial products. References The linuxwd driver software: software download page Datasheet for the NE555 NE555.pdf 140K Webpages maintained by the LinuxFocus Editor team Guido Socher "some rights reserved" see linuxfocus.org/license/ http://www.linuxfocus.org Translation information: en --> -- : Guido Socher (homepage) 2005-01-14, generated by lfparser_pdf version 2.51