Debian Codegraph @

doc/stonith/README.rcd_serial

raw
1 rcd_serial - RC Delayed Serial
2 ------------------------------
3
4 This stonith plugin uses one (or both) of the control lines of a serial
5 device (on the stonith host) to reboot another host (the stonith'ed host)
6 by closing its reset switch. A simple idea with one major problem - any
7 glitch which occurs on the serial line of the stonith host can potentially
8 cause a reset of the stonith'ed host. Such "glitches" can occur when the
9 stonith host is powered up or reset, during BIOS detection of the serial
10 ports, when the kernel loads up the serial port driver, etc.
11
12 To fix this, you need to introduce a delay between the assertion of the
13 control signal on the serial port and the closing of the reset switch.
14 Then any glitches will be dissipated. When you really want to do the
15 business, you hold the control signal high for a "long time" rather than
16 just tickling it "glitch-fashion" by, e.g., using the rcd_serial plugin.
17
18 As the name of the plugin suggests, one way to achieve the required delay is
19 to use a simple RC circuit and an npn transistor:
20
21
22 . .
23 RTS . . ----------- +5V
24 or ---------- . |
25 DTR . | . Rl reset
26 . | T1 . | |\logic
27 . Rt | ------RWL--------| ------->
28 . | b| /c . |/
29 . |---Rb---|/ .
30 . | |\ . (m/b wiring typical
31 . C | \e . only - YMMV!)
32 . | | .
33 . | | .
34 SG ---------------------------RWG----------- 0V
35 . .
36 . . stonith'ed host
37 stonith host --->.<----- RC circuit ----->.<---- RWL = reset wire live
38 (serial port) . . RWG = reset wire ground
39
40
41 The characteristic delay (in seconds) is given by the product of Rt (in ohms)
42 and C (in Farads). Suitable values for the 4 components of the RC circuit
43 above are:
44
45 Rt = 20k
46 C = 47uF
47 Rb = 360k
48 T1 = BC108
49
50 which gives a delay of 20 x 10e3 x 47 x 10e-6 = 0.94s. In practice the
51 actual delay achieved will depend on the pull-up load resistor Rl if Rl is
52 small: for Rl greater than 3k there is no significant dependence but lower
53 than this and the delay will increase - to about 1.4s at 1k and 1.9s at 0.5k.
54
55 This circuit will work but it is a bit dangerous for the following reasons:
56
57 1) If by mistake you open the serial port with minicom (or virtually any
58 other piece of software) you will cause a stonith reset ;-(. This is
59 because opening the port will by default cause the assertion of both DTR
60 and RTS, and a program like minicom will hold them high thenceforth (unless
61 and until a receive buffer overflow pulls RTS down).
62
63 2) Some motherboards have the property that when held in the reset state,
64 all serial outputs are driven high. Thus, if you have the circuit above
65 attached to a serial port on such a motherboard, if you were to press the
66 (manual) reset switch and hold it in for more than a second or so, you will
67 cause a stonith reset of the attached system ;-(.
68
69 This problem can be solved by adding a second npn transistor to act as a
70 shorting switch across the capacitor, driven by the other serial output:
71
72
73 . .
74 . . ----------- +5V
75 RTS ----------------- . |
76 . | . Rl reset
77 . | T1 . | |\logic
78 . Rt | ------RWL--------| ------->
79 . | b| /c . |/
80 . T2 --|---Rb---|/ .
81 . | / | |\ . (m/b wiring typical
82 . b| /c | | \e . only - YMMV!)
83 DTR ------Rb--|/ C | .
84 . |\ | | .
85 . | \e | | .
86 . | | | .
87 SG ----------------------------------RWG------------- 0V
88 . .
89 . . stonith'ed host
90 stonith->.<--------- RC circuit ------->.<---- RWL = reset wire live
91 host . . RWG = reset wire ground
92
93
94 Now when RTS goes high it can only charge up C and cause a reset if DTR is
95 simultaneously kept low - if DTR goes high, T2 will switch on and discharge
96 the capacitor. Only a very unusual piece of software e.g. the rcd_serial
97 plugin, is going to achieve this (rather bizarre) combination of signals
98 (the "meaning" of which is something along the lines of "you are clear to
99 send but I'm not ready"!). T2 can be another BC108 and with Rb the same.
100
101 RS232 signal levels are typically +-8V to +-12V so a 16V rating or greater
102 for the capacitor is sufficient BUT NOTE that a _polarised_ electrolytic should
103 not be used because the voltage switches around as the capacitor charges.
104 Nitai make a range of non-polar aluminium electrolytic capacitors. A 16V 47uF
105 radial capacitor measures 6mm diameter by 11mm long and along with the 3
106 resistors (1/8W are fine) and the transistors, the whole circuit can be built
107 in the back of a DB9 serial "plug" so that all that emerges from the plug are
108 the 2 reset wires to go to the stonith'ed host's m/b reset pins.
109
110 NOTE that with these circuits the reset wires are now POLARISED and hence
111 they are labelled RWG and RWL above. You cannot connect to the reset pins
112 either way round as you can when connecting a manual reset switch! You'll
113 soon enough know if you've got it the wrong way round because your machine
114 will be in permanent reset state ;-(
115
116
117 How to find out if your motherboard can be reset by these circuits
118 ------------------------------------------------------------------
119
120 You can either build it first and then suck it and see, or, you need a
121 multimeter. The 0V rail of your system is available in either
122 of the 2 black wires in the middle of a spare power connector (one of
123 those horrible 4-way plugs which you push with difficulty into the back
124 of hard disks, etc. Curse IBM for ever specifying such a monstrosity!).
125 Likewise, the +5V rail is the red wire. (The yellow one is +12V, ignore
126 this.)
127
128 First, with the system powered down and the meter set to read ohms:
129
130 check that one of the reset pins is connected to 0V - this then
131 is the RWG pin;
132
133 check that the other pin (RWL) has a high resistance wrt 0V
134 (probably > 2M) and has a small resistance wrt to +5V - between
135 0.5k and 10k (or higher, doesn't really matter) will be fine.
136
137 Second, with the system powered up and the meter set to read Volts:
138
139 check that RWG is indeed that i.e. there should be 0V between it
140 and the 0V rail;
141
142 check that RWL is around +5V wrt the 0V rail.
143
144 If all this checks out, you are _probably_ OK. However, I've got one
145 system which checks out fine but actually won't work. The reason is that
146 when you short the reset pins, the actual current drain is much higher than
147 one would expect. Why, I don't know, but there is a final test you can do
148 to detect this kind of system.
149
150 With the system powered up and the meter set to read milliamps:
151
152 short the reset pins with the meter i.e. reset the system, and
153 note how much current is actually drained when the system is in
154 the reset state.
155
156 Mostly you will find that the reset current is 1mA or less and this is
157 fine. On the system I mention above, it is 80mA! If the current is
158 greater than 20mA or so, you have probably had it with the simple circuits
159 above, although reducing the base bias resistor will get you a bit further.
160 Otherwise, you have to use an analog switch (like the 4066 - I had to use 4
161 of these in parallel to reset my 80mA system) which is tedious because then
162 you need a +5V supply rail to the circuit so you can no longer just build it
163 in the back of a serial plug. Mail me if you want the details.
164
165 With the circuit built and the rcd_serial plugin compiled, you can use:
166
167 stonith -t rcd_serial -p "testhost /dev/ttyS0 rts XXX" testhost
168
169 to test it. XXX is the duration in millisecs so just keep increasing this
170 until you get a reset - but wait a few secs between each attempt because
171 the capacitor takes time to discharge. Once you've found the minimum value
172 required to cause a reset, add say 200ms for safety and use this value
173 henceforth.
174
175 Finally, of course, all the usual disclaimers apply. If you follow my
176 advice and destroy your system, sorry. But it's highly unlikely: serial
177 port outputs are internally protected against short circuits, and reset pins
178 are designed to be short circuited! The only circumstance in which I can
179 see a possibility of damaging something by incorrect wiring would be if the
180 2 systems concerned were not at the same earth potential. Provided both
181 systems are plugged into the same mains system (i.e. are not miles apart
182 and connected only by a very long reset wire ;-) this shouldn't arise.
183
184 John Sutton
185 [email protected]
186 October 2002