bugcheck.sh 3.0 KB

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