merge: packages: update branding in core packages
[openwrt/openwrt.git] / package / utils / ct-bugcheck / src / bugcheck.sh
1 #!/bin/sh
2
3 # Check for ath10k (and maybe other) bugs, package them up,
4 # and let user know what to do with them.
5
6 TMPLOC=/tmp
7 CRASHDIR=$TMPLOC/bugcheck
8 FOUND_BUG=0
9
10 # set -x
11
12 bugcheck_generic()
13 {
14 echo "OpenWrt crashlog report" > $CRASHDIR/info.txt
15 date >> $CRASHDIR/info.txt
16 echo >> $CRASHDIR/info.txt
17 echo "uname" >> $CRASHDIR/info.txt
18 uname -a >> $CRASHDIR/info.txt
19 echo >> $CRASHDIR/info.txt
20 echo "os-release" >> $CRASHDIR/info.txt
21 cat /etc/os-release >> $CRASHDIR/info.txt
22 echo >> $CRASHDIR/info.txt
23 echo "os-release" >> $CRASHDIR/info.txt
24 cat /etc/os-release >> $CRASHDIR/info.txt
25 echo >> $CRASHDIR/info.txt
26 echo "dmesg output" >> $CRASHDIR/info.txt
27 dmesg >> $CRASHDIR/info.txt
28 if [ -x /usr/bin/lspci ]
29 then
30 echo >> $CRASHDIR/info.txt
31 echo "lspci" >> $CRASHDIR/info.txt
32 lspci >> $CRASHDIR/info.txt
33 fi
34 echo >> $CRASHDIR/info.txt
35 echo "cpuinfo" >> $CRASHDIR/info.txt
36 cat /proc/cpuinfo >> $CRASHDIR/info.txt
37 echo >> $CRASHDIR/info.txt
38 echo "meminfo" >> $CRASHDIR/info.txt
39 cat /proc/cpuinfo >> $CRASHDIR/info.txt
40 echo >> $CRASHDIR/info.txt
41 echo "cmdline" >> $CRASHDIR/info.txt
42 cat /proc/cmdline >> $CRASHDIR/info.txt
43 echo >> $CRASHDIR/info.txt
44 echo "lsmod" >> $CRASHDIR/info.txt
45 lsmod >> $CRASHDIR/info.txt
46 }
47
48 roll_crashes()
49 {
50 # Roll any existing crashes
51 if [ -d $CRASHDIR ]
52 then
53 if [ -d $CRASHDIR.1 ]
54 then
55 rm -fr $CRASHDIR.1
56 fi
57 mv $CRASHDIR $CRASHDIR.1
58 fi
59
60 # Prepare location
61 mkdir -p $CRASHDIR
62 }
63
64 # ath10k, check debugfs entries.
65 for i in /sys/kernel/debug/ieee80211/*/ath10k/fw_crash_dump
66 do
67 #echo "Checking $i"
68 if cat $i > $TMPLOC/ath10k_crash.bin 2>&1
69 then
70 FOUND_BUG=1
71
72 #echo "Found ath10k crash data in $i"
73 roll_crashes
74
75 ADIR=${i/fw_crash_dump/}
76
77 CTFW=0
78 if grep -- -ct- $TMPLOC/ath10k_crash.bin > /dev/null 2>&1
79 then
80 CTFW=1
81 fi
82
83 echo "Send bug reports to:" > $CRASHDIR/report_to.txt
84 if [ -f $ADIR/ct_special -o $CTFW == "1" ]
85 then
86 # Looks like this is CT firmware or driver...
87 echo "greearb@candelatech.com" >> $CRASHDIR/report_to.txt
88 echo "and/or report or check for duplicates here:" >> $CRASHDIR/report_to.txt
89 echo "https://github.com/greearb/ath10k-ct/issues" >> $CRASHDIR/report_to.txt
90 else
91 # Not sure who would want these bug reports for upstream...
92 echo "https://www.lede-project.org/" >> $CRASHDIR/report_to.txt
93 fi
94 echo >> $CRASHDIR/report_to.txt
95 echo "Please attach all files in this directory to bug reports." >> $CRASHDIR/report_to.txt
96
97 mv $TMPLOC/ath10k_crash.bin $CRASHDIR
98
99 # Add any more ath10k specific stuff here.
100
101 # And call generic bug reporting logic
102 bugcheck_generic
103 fi
104 done
105
106 if [ $FOUND_BUG == "1" ]
107 then
108 # Notify LUCI somehow?
109 echo "bugcheck.sh found an issue to be reported" > /dev/kmsg
110 echo "See $CRASHDIR for details on how to report this" > /dev/kmsg
111 # Let calling code know something was wrong.
112 exit 1
113 fi
114
115 exit 0