init.vendor.sensordebug.ssr_dump.sh 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #!/vendor/bin/sh
  2. # Copyright (c) 2020 The Linux Foundation. All rights reserved.
  3. #
  4. # Redistribution and use in source and binary forms, with or without
  5. # modification, are permitted provided that the following conditions are met:
  6. # * Redistributions of source code must retain the above copyright
  7. # notice, this list of conditions and the following disclaimer.
  8. # * Redistributions in binary form must reproduce the above copyright
  9. # notice, this list of conditions and the following disclaimer in the
  10. # documentation and/or other materials provided with the distribution.
  11. # * Neither the name of The Linux Foundation nor
  12. # the names of its contributors may be used to endorse or promote
  13. # products derived from this software without specific prior written
  14. # permission.
  15. #
  16. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  17. # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18. # IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  19. # NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  20. # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  21. # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  22. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  23. # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  24. # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  25. # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  26. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. #
  28. #
  29. # Function to start sensors for SSC enabled platforms
  30. #
  31. echo "Sensor SSR Dump"
  32. param=$1
  33. echo "param: $param"
  34. index=0
  35. adsp_path="none"
  36. adsp_str="adsp"
  37. if [[ "$param" == "start" || "$param" == "stop" ]]; then
  38. COUNT_CMD='ls -l /sys/class/remoteproc | grep ^l | wc -l'
  39. count=$(eval $COUNT_CMD)
  40. echo "count: $count"
  41. for file in /sys/class/remoteproc/*
  42. do
  43. local_path=$file"/name"
  44. echo "$local_path:$local_path"
  45. name=$(eval cat $local_path)
  46. echo "name:$name"
  47. if [[ "$name" == *"$adsp_str"* ]]; then
  48. echo "found~!! index: $index"
  49. adsp_path=$file
  50. break
  51. fi
  52. ((index++))
  53. done
  54. if [ "$param" == "start" ]; then
  55. echo "start"
  56. if [ "$adsp_path" != "none" ]; then
  57. echo "adsp_path:$adsp_path"
  58. SSR_DUMP_CMD=""
  59. ENABLE_RAMDUMPS_CMD='getprop persist.vendor.ssr.enable_ramdumps'
  60. enable_ramdumps=$(eval $ENABLE_RAMDUMPS_CMD)
  61. echo "enable_ramdumps:$enable_ramdumps"
  62. if [ "$enable_ramdumps" == "0" ]; then
  63. SSR_DUMP_CMD+="setprop persist.vendor.ssr.enable_ramdumps 1 &"
  64. fi
  65. RESTART_LEVEL_CMD='getprop persist.vendor.ssr.restart_level'
  66. restart_level=$(eval $RESTART_LEVEL_CMD)
  67. echo "restart_level:$restart_level"
  68. if [ "$restart_level" == "ALL_ENABLE" ]; then
  69. set_val="$restart_level"
  70. elif [ "$restart_level" == "ALL_DISABLE" ]; then
  71. set_val="adsp"
  72. elif [ -n "$restart_level" ];then
  73. if [[ "$restart_level" == *adsp* ]]; then
  74. set_val="$restart_level"
  75. else
  76. set_val="$restart_level adsp"
  77. fi
  78. else
  79. set_val="adsp"
  80. fi
  81. SSR_DUMP_CMD+="echo enabled > $adsp_path/recovery &"
  82. SSR_DUMP_CMD+="echo enabled > $adsp_path/coredump &"
  83. SSR_DUMP_CMD+="setprop persist.vendor.ssr.restart_level '$set_val'"
  84. echo "SSR_DUMP_CMD:$SSR_DUMP_CMD"
  85. eval $SSR_DUMP_CMD
  86. fi
  87. fi
  88. if [ "$param" == "stop" ]; then
  89. echo "stop"
  90. if [ "$adsp_path" != "none" ]; then
  91. echo "adsp_path:$adsp_path"
  92. SSR_DUMP_CMD="setprop persist.vendor.ssr.enable_ramdumps 0 &"
  93. SSR_DUMP_CMD+="echo 0 > /sys/module/qcom_ramdump/parameters/enable_dump_collection &"
  94. SSR_DUMP_CMD+="echo disabled > $adsp_path/recovery &"
  95. SSR_DUMP_CMD+="echo disabled > $adsp_path/coredump &"
  96. SSR_DUMP_CMD+="setprop persist.vendor.ssr.restart_level ALL_DISABLE"
  97. eval $SSR_DUMP_CMD
  98. fi
  99. fi
  100. fi
  101. if [ "$param" == "complete" ]; then
  102. chown root:system /data/vendor/ramdump/remoteproc-adsp.elf
  103. INTENT_CMD="am broadcast -a com.sec.android.ISSUE_TRACKER_ACTION "
  104. INTENT_CMD+="--ei ERRCODE -126 "
  105. INTENT_CMD+="--es ERRNAME \"Sensor Silent dump\" "
  106. INTENT_CMD+="--es ERRPKG \"Sensor ADSP\" "
  107. INTENT_CMD+="--es ERRMSG \"Sensor SSR Dump after SSR\" "
  108. INTENT_CMD+="--es EXTLOG \"/data/vendor/ramdump/remoteproc-adsp.elf\""
  109. echo "$INTENT_CMD" && eval "$INTENT_CMD"
  110. fi