Advertisement
Guest User

B3UZ

a guest
May 25th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.40 KB | None | 0 0
  1. #!/sbin/sh
  2.  
  3. OUTFD=$2
  4. ZIP=$3
  5. debugfile=/sdcard/buz.log
  6. buzver="1.0"
  7. datever="2018-02-25"
  8. pdaver="DRAA"
  9. blver="DRAA"
  10. cpver="DRA9"
  11. dateSecurLvl="2018-01-01"
  12.  
  13. ui_print(){
  14.     echo -n -e "ui_print $1\n" >> /proc/self/fd/$OUTFD
  15.     echo -n -e "ui_print\n" >> /proc/self/fd/$OUTFD
  16. }
  17.  
  18. debug(){
  19.   t1=$(date +"%H:%M:%S")
  20.   t2=$(awk 'NR==3 {print $3}' /proc/timer_list | cut -c1-5)
  21.   echo "$t1.$t2: $1" >> $debugfile
  22. }
  23.  
  24. getinfo(){
  25.   BPROP=/system/build.prop
  26.   TXT=$1
  27.   if [ -f $BPROP ]; then
  28.     tmp=$(cat $BPROP | grep -i $TXT | cut -d= -f2)
  29.     [ -z "$tmp" ] && echo "key not found" || echo $tmp
  30.   else
  31.     echo "build.prop not found"
  32.   fi
  33. }
  34.  
  35. ui_print " "
  36. ui_print "  B3UZ: BaseBand & Booloader Updater Zip"
  37. ui_print "   version $buzver"
  38. ui_print "   $datever"
  39. ui_print "   (c) hypo59 @ mmgmobile.com"
  40. ui_print " "
  41.  
  42. # remove log file if it already exists
  43. [ -f $debugfile ] && rm -f $debugfile
  44. debug "date: $(date +%Y-%m-%d)"
  45. debug "B3UZ version: $buzver"
  46. debug "PDA-BL-CP version: $pdaver-$blver-$cpver"
  47.  
  48. # mount partitions
  49. debug "mount /system"
  50. mount /system
  51. debug "rc=$?"
  52. debug "mount /data"
  53. mount /data
  54. debug "rc=$?"
  55.  
  56. # display informations
  57. ui_print " # support ONLY for SM-G930F (flat S7)"
  58. model=$(getinfo ro.product.model)
  59. ui_print " # phone model detected: $model"
  60. debug "ro.product.model = $model"
  61. if [ ! "$model" = "SM-G930F" ]; then
  62.   ui_print " # bad detection: exit"
  63.   ui_print " "
  64.   exit
  65. fi
  66.  
  67. ui_print " # source firmware version: $pdaver"
  68. ui_print " # bootloader version to flash: $blver"
  69. ui_print " # baseband version to flash: $cpver"
  70. ui_print " # security patch level date: $dateSecurLvl"
  71.  
  72. # extract stuff
  73. ui_print " # extract files for update"
  74. unzip -o "$ZIP" firmware/* -d /tmp
  75. unziprc=$?
  76. debug "extract rc=$unziprc"
  77. if [ ! "$unziprc" = "0" ]; then
  78.   ui_print " # error while extracting: exit"
  79.   ui_print " # logfile saved to: $debugfile"
  80.   exit
  81. fi
  82.  
  83. # apply update
  84. ui_print " # apply $cpver baseband update"
  85. dd if=/tmp/firmware/modem_debug.bin of=/dev/block/platform/155a0000.ufs/by-name/CP_DEBUG
  86. sleep 2
  87. cpdebugrc=$?
  88. debug "CP_DEBUG rc = $cpdebugrc"
  89. if [ ! "$cpdebugrc" = "0" ]; then
  90.   ui_print " # error while applying update: exit"
  91.   ui_print " # logfile saved to: $debugfile"
  92.   ui_print " "
  93.   exit
  94. fi
  95. dd if=/tmp/firmware/modem.bin of=/dev/block/platform/155a0000.ufs/by-name/RADIO
  96. sleep 2
  97. radiorc=$?
  98. debug "RADIO rc = $radiorc"
  99. if [ ! "$radiorc" = "0" ]; then
  100.   ui_print " # error while applying update: exit"
  101.   ui_print " # logfile saved to: $debugfile"
  102.   ui_print " "
  103.   exit
  104. fi
  105. ui_print " # successfully done !"
  106.  
  107. ui_print " # apply $blver bootloader update"
  108. dd if=/tmp/firmware/sboot.bin of=/dev/block/platform/155a0000.ufs/by-name/BOTA0
  109. sleep 2
  110. botazerorc=$?
  111. debug "BOTA0 rc = $botazerorc"
  112. if [ ! "$botazerorc" = "0" ]; then
  113.   ui_print " # error while applying update: exit"
  114.   ui_print " # logfile saved to: $debugfile"
  115.   ui_print " "
  116.   exit
  117. fi
  118. dd if=/tmp/firmware/cm.bin of=/dev/block/platform/155a0000.ufs/by-name/BOTA1
  119. sleep 2
  120. botaonerc=$?
  121. debug "BOTA1 rc = $botaonerc"
  122. if [ ! "$botaonerc" = "0" ]; then
  123.   ui_print " # error while applying update: exit"
  124.   ui_print " # logfile saved to: $debugfile"
  125.   ui_print " "
  126.   exit
  127. fi
  128. ui_print " # successfully done !"
  129. ui_print " "
  130.  
  131. # automatic reboot with fota_bl option
  132. ui_print " # logfile saved to: $debugfile"
  133. ui_print " # automatic reboot in 5s..."
  134. debug "end of script"
  135. sleep 5
  136. reboot fota_bl
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement