|
| 1 | + |
| 2 | +if [ -e $MPAT/auto.prop ]; then |
| 3 | +source $MPAT/auto.prop |
| 4 | +else |
| 5 | +eval "$(sed '1,/root=/d' $MPAT/addon.prop)" |
| 6 | +fi |
| 7 | + |
| 8 | +bDeviceLifeTimeEstA="" |
| 9 | + |
| 10 | +# --- Life Time Estimation A --- |
| 11 | +if [ -f /sys/devices/platform/soc/1d84000.ufshc/health_descriptor/life_time_estimation_a ]; then |
| 12 | + bDeviceLifeTimeEstA=$(cat /sys/devices/platform/soc/1d84000.ufshc/health_descriptor/life_time_estimation_a) |
| 13 | + |
| 14 | +elif [ -f /sys/devices/virtual/mi_memory/mi_memory_device/ufshcd0/dump_health_desc ]; then |
| 15 | + bDeviceLifeTimeEstA=$(grep bDeviceLifeTimeEstA \ |
| 16 | + /sys/devices/virtual/mi_memory/mi_memory_device/ufshcd0/dump_health_desc \ |
| 17 | + | cut -d '=' -f2 | awk '{print $1}') |
| 18 | + |
| 19 | +else |
| 20 | + bDeviceLifeTimeEstA=$(grep bDeviceLifeTimeEstA \ |
| 21 | + /sys/kernel/debug/*.ufshc/dump_health_desc 2>/dev/null \ |
| 22 | + | cut -d '=' -f2 | awk '{print $1}') |
| 23 | +fi |
| 24 | + |
| 25 | +dump_files=$(find /sys -name "dump_*_desc" 2>/dev/null | grep ufshc) |
| 26 | + |
| 27 | +if [ -z "$bDeviceLifeTimeEstA" ]; then |
| 28 | + for line in $dump_files; do |
| 29 | + str=$(grep bDeviceLifeTimeEstA "$line" | cut -d '=' -f2 | awk '{print $1}') |
| 30 | + [ -n "$str" ] && bDeviceLifeTimeEstA="$str" && break |
| 31 | + done |
| 32 | +fi |
| 33 | + |
| 34 | +if [ -z "$bDeviceLifeTimeEstA" ]; then |
| 35 | + for line in $(find /sys -name "life_time_estimation_a" 2>/dev/null | grep ufshc); do |
| 36 | + str=$(cat "$line") |
| 37 | + [ -n "$str" ] && bDeviceLifeTimeEstA="$str" && break |
| 38 | + done |
| 39 | +fi |
| 40 | + |
| 41 | +case "$bDeviceLifeTimeEstA" in |
| 42 | +0x00|0x0) echo "$ufs_text_3 $ufs_text_2" ;; |
| 43 | +0x01|0x1) echo "$ufs_text_3 0% ~ 10%" ;; |
| 44 | +0x02|0x2) echo "$ufs_text_3 10% ~ 20%" ;; |
| 45 | +0x03|0x3) echo "$ufs_text_3 20% ~ 30%" ;; |
| 46 | +0x04|0x4) echo "$ufs_text_3 30% ~ 40%" ;; |
| 47 | +0x05|0x5) echo "$ufs_text_3 40% ~ 50%" ;; |
| 48 | +0x06|0x6) echo "$ufs_text_3 50% ~ 60%" ;; |
| 49 | +0x07|0x7) echo "$ufs_text_3 60% ~ 70%" ;; |
| 50 | +0x08|0x8) echo "$ufs_text_3 70% ~ 80%" ;; |
| 51 | +0x09|0x9) echo "$ufs_text_3 80% ~ 90%" ;; |
| 52 | +0x0A|0xA) echo "$ufs_text_3 90% ~ 100%" ;; |
| 53 | +0x0B|0xB) echo "$ufs_text_3 $ufs_text_4" ;; |
| 54 | +*) echo "$ufs_text_3 $ufs_text_2" ;; |
| 55 | +esac |
| 56 | +echo |
| 57 | + |
| 58 | +# --- Pre EOL Info --- |
| 59 | +bPreEOLInfo="" |
| 60 | + |
| 61 | +if [ -f /sys/devices/platform/soc/1d84000.ufshc/health_descriptor/eol_info ]; then |
| 62 | + bPreEOLInfo=$(cat /sys/devices/platform/soc/1d84000.ufshc/health_descriptor/eol_info) |
| 63 | + |
| 64 | +elif [ -f /sys/devices/virtual/mi_memory/mi_memory_device/ufshcd0/dump_health_desc ]; then |
| 65 | + bPreEOLInfo=$(grep bPreEOLInfo \ |
| 66 | + /sys/devices/virtual/mi_memory/mi_memory_device/ufshcd0/dump_health_desc \ |
| 67 | + | cut -d '=' -f2 | awk '{print $1}') |
| 68 | + |
| 69 | +else |
| 70 | + bPreEOLInfo=$(grep bPreEOLInfo \ |
| 71 | + /sys/kernel/debug/*.ufshc/dump_health_desc 2>/dev/null \ |
| 72 | + | cut -d '=' -f2 | awk '{print $1}') |
| 73 | +fi |
| 74 | + |
| 75 | +if [ -z "$bPreEOLInfo" ]; then |
| 76 | + for line in $dump_files; do |
| 77 | + str=$(grep bPreEOLInfo "$line" | cut -d '=' -f2 | awk '{print $1}') |
| 78 | + [ -n "$str" ] && bPreEOLInfo="$str" && break |
| 79 | + done |
| 80 | +fi |
| 81 | + |
| 82 | +if [ -z "$bPreEOLInfo" ]; then |
| 83 | + for line in $(find /sys -name "eol_info" 2>/dev/null | grep ufshc); do |
| 84 | + str=$(cat "$line") |
| 85 | + [ -n "$str" ] && bPreEOLInfo="$str" && break |
| 86 | + done |
| 87 | +fi |
| 88 | + |
| 89 | +case "$bPreEOLInfo" in |
| 90 | +0x00|0x0) echo "$ufs_text_1 $ufs_text_2" ;; |
| 91 | +0x01|0x1) echo "$ufs_text_1 $ufs_text_6" ;; |
| 92 | +0x02|0x2) echo "$ufs_text_1 $ufs_text_5" ;; |
| 93 | +0x03|0x3) echo "$ufs_text_1 $ufs_text_4" ;; |
| 94 | +*) echo "$ufs_text_1 $ufs_text_2" ;; |
| 95 | +esac |
| 96 | + |
| 97 | +echo |
| 98 | +echo "$check_ufs_text_2" |
| 99 | +echo |
| 100 | +dd if=/dev/zero of=${0%/*}/test.bin bs=4M count=256 conv=fsync |
| 101 | + |
| 102 | +echo |
| 103 | +echo "$check_ufs_text_1" |
| 104 | +echo |
| 105 | +dd if=${0%/*}/test.bin of=/dev/null bs=4M |
| 106 | +rm -fr ${0%/*}/test.bin |
0 commit comments