hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
 
delay=8
total=${1:-10000}
CNT=/userdata/rockchip-test/reboot_cnt
 
if [ ! -e "/userdata//rockchip-test" ]; then
   echo "no /userdata/rockchip-test"
   mkdir -p /userdata/rockchip-test
fi
 
if [ ! -e "/userdata/rockchip-test/auto_reboot.sh" ]; then
   cp /rockchip-test/auto_reboot/auto_reboot.sh /userdata/rockchip-test
   echo $total > /userdata/rockchip-test/reboot_total_cnt
    sync
fi
 
while true
do
 
if [ -e $CNT ]
then
    cnt=`cat $CNT`
else
    echo reset Reboot count.
    echo 0 > $CNT
fi
 
echo  Reboot after $delay seconds.
 
let "cnt=$cnt+1"
 
if [ $cnt -ge $total ]
then
    echo AutoReboot Finisned.
    echo "off" > $CNT
    echo "do cleaning ..."
    rm -rf /userdata/rockchip-test/auto_reboot.sh
    rm -rf /userdata/rockchip-test/reboot_total_cnt
    rm -f $CNT
    sync
    exit 0
fi
 
echo $cnt > $CNT
echo "current cnt = $cnt, total cnt = $total"
echo "You can stop reboot by: echo off > /userdata/rockchip-test/reboot_cnt"
sleep $delay
cnt=`cat $CNT`
if [ $cnt != "off" ]; then
    sync
    if [ -e /sys/fs/pstore/console-ramoops-0 ]; then
        echo "check console-ramoops-o message"
        grep -q "Restarting system" /sys/fs/pstore/console-ramoops-0
        if [ $? -ne 0 -a $cnt -ge 2 ]; then
           echo "no found 'Restarting system' log in last time kernel message"
           echo "consider kernel crash in last time reboot test"
           echo "quit reboot test"
            rm -rf /userdata/rockchip-test/auto_reboot.sh
            rm -rf /userdata/rockchip-test/reboot_total_cnt
            sync
      exit 1
        else
      reboot
        fi
    else
      reboot
    fi
else
    echo "Auto reboot is off"
    rm -rf /userdata/rockchip-test/auto_reboot.sh
    rm -rf /userdata/rockchip-test/reboot_total_cnt
    rm -f $CNT
    sync
fi
exit 0
done