Using sta_counter as watchdog in case RPi OS freeze up

Uninterruptible Power intelligent Supply Module

Using sta_counter as watchdog in case RPi OS freeze up

Postby flyvert » Wed Oct 15, 2014 10:29 pm

Hi,

I occasionally have problems with the Rasbian OS freezing up on me (I think its some issue with the SD card and running a MySQL database which frequently writes to the SD card)

Anyway, I got myself a UPiS Advanced to play with and is looking into using the sta_counter to implement an OS watchdog.

Lets say I use a cron job to put 120 seconds into the sta_counter every minute, then if the OS freezes the sta_counter will expire and FSSD will take place, but will it immediately reboot, or leave the RPi in low power state?

I've read the users's guide - and it seems like you need to press the Shutdown button to wake the RPi up after a FSSD?

As I see it, the RPi will then remain shut down after sta_expire and subsequent FSSD?

Or have I got it wrong?

/f
flyvert
 
Posts: 26
Joined: Sat Jul 19, 2014 1:22 pm

Re: Using sta_counter as watchdog in case RPi OS freeze up

Postby Pimaster » Fri Oct 17, 2014 12:15 am

flyvert wrote:Hi,

I occasionally have problems with the Rasbian OS freezing up on me (I think its some issue with the SD card and running a MySQL database which frequently writes to the SD card)

Anyway, I got myself a UPiS Advanced to play with and is looking into using the sta_counter to implement an OS watchdog.

Lets say I use a cron job to put 120 seconds into the sta_counter every minute, then if the OS freezes the sta_counter will expire and FSSD will take place, but will it immediately reboot, or leave the RPi in low power state?


You need to restart the sta_counter, before it will be zero, if it will be zero, then the FSSD wil be started and after FSSD timeout the power will be restarted, so RPi will be started again

flyvert wrote:I've read the users's guide - and it seems like you need to press the Shutdown button to wake the RPi up after a FSSD?


No, you do not need to press anything, it is an automatic type of well know in the uC watch dog system (adapted to the RPi)

It is independent form the FSSD related to the button pressing

flyvert wrote:As I see it, the RPi will then remain shut down after sta_expire and subsequent FSSD?

I do not think, but will check again next days, and confirm.

flyvert wrote:Or have I got it wrong?

Probably you have done something wrong, as nobody until now report such bug, but no problem we will check it again and report it to you

flyvert wrote:/f


Warmest Regards
Pi Master
Warmest Regards
PiM
---
Designing with Mentor Graphics PADS - www.pads.com
Please read and follow the PiForum rules
http://www.forum.pimodules.com/viewtopic.php?f=13&t=196
---
Pimaster
Site Admin
 
Posts: 1593
Joined: Fri Sep 14, 2012 7:50 am

Re: Using sta_counter as watchdog in case RPi OS freeze up

Postby flyvert » Fri Oct 17, 2014 6:54 am

Thanks for the update.

I haven't actually tested anything yet so my question was hypothetical; hopefully I will get some time to implement something with the sta_counter this weekend and see for myself.
flyvert
 
Posts: 26
Joined: Sat Jul 19, 2014 1:22 pm

Re: Using sta_counter as watchdog in case RPi OS freeze up

Postby Martin » Wed Oct 22, 2014 6:50 am

Hello,
I have tried to use watchdog but: When sta_conter (0x6b/02) reach zero, FSSD is invoked and rpi successfully shutdowned. After then no reset is done and rpi stays switched off. I tried to set different values on (0x6b/03) but it didn't help. Maybe 0x6b/04 should be set too? I'm using the newest 1.096beta fw

btw my crontab -l
# Set watchdog
*/3 * * * * /usr/sbin/i2cset -y 1 0x6b 0x02 0xf0

Thank you for help
Martin
 
Posts: 3
Joined: Wed Oct 22, 2014 6:23 am

Re: Using sta_counter as watchdog in case RPi OS freeze up

Postby Pimaster » Wed Oct 22, 2014 10:51 pm

Hi,

Thank you for your report, we will test it again and confirm or correct bug (if exist)

My Warmest Regards
Pi Master
Warmest Regards
PiM
---
Designing with Mentor Graphics PADS - www.pads.com
Please read and follow the PiForum rules
http://www.forum.pimodules.com/viewtopic.php?f=13&t=196
---
Pimaster
Site Admin
 
Posts: 1593
Joined: Fri Sep 14, 2012 7:50 am

Re: Using sta_counter as watchdog in case RPi OS freeze up

Postby flyvert » Tue Nov 18, 2014 11:02 pm

Pimaster wrote:Thank you for your report, we will test it again and confirm or correct bug (if exist)

4 weeks have passed now - any news on this matter?

I'm reluctant to try this out before you have confirmed or rejected the problem described by Martin

Pimaster wrote:... and after FSSD timeout the power will be restarted, so RPi will be started again

Please explain "FSSD timeout" - I've not been able to find it documented anywhere?

What I need is a way of properly & unattendedly restarting the Pi when it has become non-responsive.
flyvert
 
Posts: 26
Joined: Sat Jul 19, 2014 1:22 pm

Re: Using sta_counter as watchdog in case RPi OS freeze up

Postby Pimaster » Wed Nov 19, 2014 2:41 am

Hi,
Sorry, I tested it and works properly, but forget to report it.

However, this version of watch dog, is doing an FSSD on the RPi, so you need to have minimum 2 things confirmed:

1. To have one task with FSSD script running on the RPi or
2. Have done a script based on interrupts

Alternative version of watch dog, with power cutting (for 1 second), and restarting of the RPi, is on the way, but not released yet.

We are working on it, and hoe to include with actual ongoing (already delayed). We are delayed sometimes with answers, due to overload, we just releasing new product, and doing also other projects.

This functionality has been not included in the "official" version, has been added later on, with the PICo interface, and is described in many documents related to new firmware, as also PICo interface. Please check our forum for that, if needed I can send you to your email.

Warmest Regards
Pi Master
Warmest Regards
PiM
---
Designing with Mentor Graphics PADS - www.pads.com
Please read and follow the PiForum rules
http://www.forum.pimodules.com/viewtopic.php?f=13&t=196
---
Pimaster
Site Admin
 
Posts: 1593
Joined: Fri Sep 14, 2012 7:50 am

Re: Using sta_counter as watchdog in case RPi OS freeze up

Postby Martin » Thu Nov 20, 2014 9:58 am

Ah I see,
So in that case I was thinking in wrong way. I thought when event ("raspi is not responding") is invoked Upis will restart raspi as switch off & switch on - without using any raspi scripts. How can I recognise if FSSD is started?

I'm using script somewhere from this forum which is running after pushing upis button. It would be best to use "case" command for pushing button or FSSD event as shutdown or restart command.

~~~~~~start script~~~~~
#!/usr/bin/python

# Python script which waits for a closed circuit on pin 21 (Rasperry Pi Rev 1)
# or pin 27 (Raspberry Pi Rev 2) and which then executes a shutdown
# command.
# Must be run by root preferably by calling it from /etc/rc.local
# e.g. by adding the line
# 'python /full/path/to/scriptname.py &'
# before the 'exit 0' statement

# Import libraries

import RPi.GPIO as GPIO # accessing GPIO pins
import time # work with time functions
import os # simple operating system commands
import re # regular expressions

# set pin depending on revision
# source: http://raspberryalphaomega.org.uk/2013/ ... etection-m
odel-a-b1-and-b2/

revision = "unknown"
with open('/proc/cmdline', 'r') as f:
line = f.readline()
m = re.search('bcm2708.boardrev=(0x[0123456789abcdef]*) ', line)
revision = m.group(1)

# array of revision:pin pairs (verified with 0x2 and 0xf)
pinarray = {'0x2': 21, '0x3': 21, '0x4': 21, '0x5': 21, '0x6': 21, '0x7': 21, '0x8': 21, '0x9': 21, '0xd
': 27, '0xe': 27, '0xf': 27}

# assign value to variable pin
pin = pinarray[revision]

GPIO.setmode(GPIO.BCM) # there are several ways to name pins, we use BCM board numbering
GPIO.setup(pin, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Setup pin as an input
while True: # Setup a while loop to wait for a button press
if(GPIO.input(pin)==0): # Setup an if loop to run a shutdown command when button press sensed
os.system("shutdown -h now") # Send shutdown command to os. Script must be run by root,
no sudo necessary
break
time.sleep(1) # Allow a sleep time of 1 second to reduce CPU usage
~~~~~~end script ~~~~
Martin
 
Posts: 3
Joined: Wed Oct 22, 2014 6:23 am

Re: Using sta_counter as watchdog in case RPi OS freeze up

Postby flyvert » Thu Dec 04, 2014 9:47 pm

Pimaster wrote:Sorry, I tested it and works properly, but forget to report it.

I need help...

1. I checked the fssd_timeout value; which was reported to 0x1e (I did not set myself so I guess it's default)
2. I then set the sta_counter to 10 and watched it tick down
3. Shortly after FSSD triggered the shutdown script (I have implemented the procedure recommended in the user's guide; a 1s polling script)

The Raspberry PI went down and did not start again (I waited 3 minutes and all I could see was the first LED blinking green ~3 times a second)

pi@RPI1 ~ $ date
Thu Dec 4 21:25:48 CET 2014
pi@RPI1 ~ $ sudo /usr/sbin/i2cget -y 1 0x6b 0x03
0x1e
pi@RPI1 ~ $ sudo /usr/sbin/i2cset -y 1 0x6b 0x02 10
pi@RPI1 ~ $ sudo /usr/sbin/i2cget -y 1 0x6b 0x02
0x06
pi@RPI1 ~ $ sudo /usr/sbin/i2cget -y 1 0x6b 0x02
0x04
pi@RPI1 ~ $ sudo /usr/sbin/i2cget -y 1 0x6b 0x02
0x03
pi@RPI1 ~ $ date
Thu Dec 4 21:26:17 CET 2014
pi@RPI1 ~ $
Broadcast message from root@RPI1 (Thu Dec 4 21:26:21 2014):

The system is going down for system halt NOW!


When pressing the FSSD button for >0.3 seconds but <2 seconds the Raspberry booted up again.


I repeated the same test once more; same effect. Raspberry is shut down properly but does not start (waited 2-3 minutes).
This time the FSSD button press resulted in a seemingly "new FSSD" since the red blinking light came on... :?:

I made a second >.3 & <2.0 press and now it started.


What is wrong?

I find the documentation very vague on the sta_counter and fssd_timeout!

Please help me get the automatic restart when sta_counter expires to work!

This is the output of @STATUS:

----------------------
http://www.pimodules.com
UPiS Advanced
Firmware Version:1.096 Beta Version
Hardware Release:VCO2
----------------------

UPiS Status

Powering Source:USB

UPiS RTC Date:2014:12:04

UPiS RTC Time:21:42:24


Average Powering Values
----------------------

RPi Voltage:04.96 V
EPR Voltage:00.00 V
USB Voltage:05.10 V
BAT Voltage:04.22 V
UPiS Current:0742 mA
----------------------

Battery Charger ON
Low Power Restart Time (LPRSTA) is 5 seconds

Raspberry Pi timed shutdown is inactive
Raspberry Pi timed start-up is inactive
File Safe Power Cut-Off Time is: 30 Seconds
File Safe Shut Down type is: RPi NOT Powered while sleep
File Safe Unconditional Shutdown when Power loose Timer is OFF, UPiS will work d
Real Time Clock Correction Factor value is: 0x00

Analog Sensor Temperature:38 C 0100 F
flyvert
 
Posts: 26
Joined: Sat Jul 19, 2014 1:22 pm

Re: Using sta_counter as watchdog in case RPi OS freeze up

Postby flyvert » Thu Dec 11, 2014 8:19 am

Please assist me! :!:
flyvert
 
Posts: 26
Joined: Sat Jul 19, 2014 1:22 pm

Next

Return to UPiS

Who is online

Users browsing this forum: No registered users and 1 guest

cron