Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- function boot_mode {
- echo "Boot Mode"
- echo "0=Normal"
- echo "1=Recovery"
- echo "2=Easy-Recovery"
- echo "3=Re-Easy-Recovery"
- echo "Chooses the mode in which to boot the device"
- echo -n "Choice [0-3]:"
- read response
- if [ $response -ge 0 ] && [ $response -le 3 ]
- then
- boot_mode=${response}
- echo "Confirmed: boot_mode=[${boot_mode}]"
- else
- echo "Invalid response, exiting"
- exit 1
- fi
- }
- function launch_mode {
- echo "Launch Mode"
- echo "0=APL"
- echo "1=TestMode.apk"
- echo "2=Slave TestMode"
- echo "3=Boot Error"
- echo "Chooses the mode in which to boot the device"
- echo -n "Choice [0-3]:"
- read response
- if [ $response -ge 0 ] && [ $response -le 3 ]
- then
- launch_mode=${response}
- echo "Confirmed: launch_mode=[${launch_mode}]"
- else
- echo "Invalid response, exiting"
- exit 1
- fi
- }
- function test_sub_mode {
- echo "Test Sub Mode"
- echo "0=Tech Mode"
- echo "1=TestMode_A.key"
- echo "2=Serv"
- echo "Chooses the mode in which to boot the device"
- echo -n "Choice [0-2]:"
- read response
- if [ $response -ge 0 ] && [ $response -le 2 ]
- then
- test_sub_mode=${response}
- echo "Confirmed: test_sub_mode=[${test_sub_mode}]"
- else
- echo "Invalid response, exiting"
- exit 1
- fi
- }
- function boot_image_flag {
- echo "Boot Image Flag"
- echo "0=SideA"
- echo "1=SideB"
- echo "Chooses the mode in which to boot the device"
- echo -n "Choice [0-1]:"
- read response
- if [ $response -ge 0 ] && [ $response -le 1 ]
- then
- boot_image_flag=${response}
- echo "Confirmed: boot_image_flag=[${boot_image_flag}]"
- else
- echo "Invalid response, exiting"
- exit 1
- fi
- }
- function recovery_image_flag {
- echo "Recovery Image Flag"
- echo "0=SideA"
- echo "1=SideB"
- echo "Chooses the mode in which to recovery the device"
- echo -n "Choice [0-1]:"
- read response
- if [ $response -ge 0 ] && [ $response -le 1 ]
- then
- recovery_image_flag=${response}
- echo "Confirmed: recovery_image_flag=[${recovery_image_flag}]"
- else
- echo "Invalid response, exiting"
- exit 1
- fi
- }
- function debug_flag {
- echo "Debug Flag"
- echo "0=Disabled"
- echo "1=Debug"
- echo "2=Debug+Console"
- echo "Chooses the mode in which to recovery the device"
- echo -n "Choice [0-2]:"
- read response
- if [ $response -ge 0 ] && [ $response -le 2 ]
- then
- debug_flag=${response}
- echo "Confirmed: debug_flag=[${debug_flag}]"
- else
- echo "Invalid response, exiting"
- exit 1
- fi
- }
- function otg_switch {
- echo "OTG Switch"
- echo "0=Host Mode"
- echo "1=Device Mode"
- echo "Chooses the mode in which to recovery the device"
- echo -n "Choice [0-1]:"
- read response
- if [ $response -ge 0 ] && [ $response -le 1 ]
- then
- otg_switch=${response}
- echo "Confirmed: otg_switch=[${otg_switch}]"
- else
- echo "Invalid response, exiting"
- exit 1
- fi
- }
- function mem_check_flag {
- echo "Memory Check"
- echo "0=No"
- echo "1=Yes"
- echo "Chooses the mode in which to recovery the device"
- echo -n "Choice [0-1]:"
- read response
- if [ $response -ge 0 ] && [ $response -le 1 ]
- then
- mem_check_flag=${response}
- echo "Confirmed: mem_check_flag=[${mem_check_flag}]"
- else
- echo "Invalid response, exiting"
- exit 1
- fi
- }
- function warp_boot {
- echo "Warp Boot"
- echo "0=SideA"
- echo "1=SideB"
- echo "Chooses the mode in which to recovery the device"
- echo -n "Choice [0-1]:"
- read response
- if [ $response -ge 0 ] && [ $response -le 1 ]
- then
- warp_boot=${response}
- echo "Confirmed: warp_boot=[${warp_boot}]"
- else
- echo "Invalid response, exiting"
- exit 1
- fi
- }
- function sub_boot_mode {
- echo "Sub Boot Mode"
- echo "0=Enable WARP!"
- echo "1=Disable WARP!"
- echo "2=Snapshot"
- echo "Chooses the mode in which to recovery the device"
- echo -n "Choice [0-2]:"
- read response
- if [ $response -ge 0 ] && [ $response -le 2 ]
- then
- sub_boot_mode=${response}
- echo "Confirmed: sub_boot_mode=[${sub_boot_mode}]"
- else
- echo "Invalid response, exiting"
- exit 1
- fi
- }
- function choice_password {
- echo "Choice Password"
- echo "0=LKPFeD4BcVzESR2Y"
- echo "1=<No Password>"
- echo "Chooses the mode in which to boot the device"
- echo -n "Choice [0-1]:"
- read response
- if [ $response -ge 0 ] && [ $response -le 1 ]
- then
- choice_password=${response}
- echo "Confirmed: choice_password=[${choice_password}]"
- else
- echo "Invalid response, exiting"
- exit 1
- fi
- }
- function update_selection {
- echo "Update Selection"
- echo "0=Recovery-Update"
- echo "1=uboot update"
- echo "2=boot update"
- echo "3=boot.img update"
- echo "4=recovery.img update"
- echo "5=system.img update"
- echo "6=opening data update"
- echo "7=UI update"
- echo "8=All image update"
- echo "9=TESTMODE_N.KEY"
- echo "a=easyrecovery copy"
- echo "b=easyrecovery copy&verify"
- echo "c=password key copy&verify"
- echo "d=easyrecovery mode change"
- echo "Chooses the mode in which to boot the device"
- echo -n "Choice [0-9,a-d]"
- read response
- echo "$response" | grep -q '^[0-9a-d]$'
- if [[ $? -eq 0 ]]
- then
- update_selection=${response}
- echo "Confirmed: update_selection=[${update_selection}]"
- else
- echo "Invalid response, exiting"
- exit 1
- fi
- }
- function update_sub_device {
- echo "Update Sub Device"
- echo "0=SD Card"
- echo "1=USB1"
- echo "2=USB2"
- echo "Chooses the mode in which to recovery the device"
- echo -n "Choice [0-2]:"
- read response
- if [ $response -ge 0 ] && [ $response -le 2 ]
- then
- update_sub_device=${response}
- echo "Confirmed: update_sub_device=[${update_sub_device}]"
- else
- echo "Invalid response, exiting"
- exit 1
- fi
- }
- function ui_update_flag {
- echo "UI Update Flag"
- echo "0=Non-Updating"
- echo "1=Updating"
- echo "Chooses the mode in which to recovery the device"
- echo -n "Choice [0-1]:"
- read response
- if [ $response -ge 0 ] && [ $response -le 1 ]
- then
- ui_update_flag=${response}
- echo "Confirmed: ui_update_flag=[${ui_update_flag}]"
- else
- echo "Invalid response, exiting"
- exit 1
- fi
- }
- [ -f /tmp/bsp_image ] && rm -Rf /tmp/bsp_image
- mkdir -p /tmp/bsp_image
- bsp_image_file=/tmp/bsp_image/newbsp.img
- sd_password_file=/tmp/bsp_image/warpdisabledbsp.img
- testmode_a_key_file=/tmp/bsp_image/testmode_a.key
- sdunlock_file=/tmp/bsp_image/sdunlock
- echo -ne "\x44\x44\x44\x45\x44\x47\x44\x6c\x47\x6c\x46\x68\x45\x59\x44\x57" > ${testmode_a_key_file}
- echo -ne "\x46\x5c\x44\x62\x46\x5d\x4c\x57\x44\x55\x44\x60\x45\x6c\x44\x6c" >> ${testmode_a_key_file}
- echo -ne "\x45\x44\x44\x44\x47\x47\x45\x55\x44\x60\x46\x60\x4c\x44\x44\x44" >> ${testmode_a_key_file}
- echo -ne "\x44\x4c\x6c\x47\x6c\x47\x60\x47\x55\x47\x57\x47\x5d\x47\x62\x47" >> ${testmode_a_key_file}
- echo -ne "\x5c\x47\x57\x44\x59\x45\x68\x47\x6c\x6c" >> ${testmode_a_key_file}
- echo -ne "\x41\x41\x41\x41\x41\x41\x41\x41\x41" > /tmp/bsp_image/SDCardDataVersion.txt
- echo -ne "\x41\x41\x41\x41\x41\x41\x41\x41" > /tmp/bsp_image/SDCardCWWVersion.txt
- echo -ne "\x41\x41\x41\x41\x41\x41\x41\x41" > /tmp/bsp_image/SDCardCVJVersion.txt
- #boot_mode=0
- #launch_mode=0
- #test_sub_mode=0
- #boot_image_flag=0
- #debug_flag=1
- #otg_switch=0
- #mem_check_flag=0
- #warp_boot=0
- #sub_boot_mode=0
- #update_selection=0
- #update_sub_device=0
- #choice_password=1
- #ui_update_flag=0
- # 00 Signature
- echo -ne "\xa5\x5a\x5a\xa5" > ${bsp_image_file}
- # 04 Boot Mode
- [ -z $boot_mode ] && boot_mode
- echo -ne "\x0${boot_mode}\0\0\0" >> ${bsp_image_file}
- # 08 Launch Mode
- [ -z $launch_mode ] && launch_mode
- echo -ne "\x0${launch_mode}\0\0\0" >> ${bsp_image_file}
- # 12 Test Sub Mode
- [ -z $test_sub_mode ] && test_sub_mode
- echo -ne "\x0${test_sub_mode}\0\0\0" >> ${bsp_image_file}
- # 16 Boot Image Flag
- [ -z $boot_image_flag ] && boot_image_flag
- echo -ne "\x0${boot_image_flag}\0\0\0" >> ${bsp_image_file}
- # 20 Recovery Image Flag
- [ -z $boot_image_flag ] && boot_image_flag
- echo -ne "\x0${boot_image_flag}\0\0\0" >> ${bsp_image_file}
- # 24 Debug Flag
- [ -z $debug_flag ] && debug_flag
- echo -ne "\x0${debug_flag}\0\0\0" >> ${bsp_image_file}
- # 28 OTG Switch
- [ -z $otg_switch ] && otg_switch
- echo -ne "\x0${otg_switch}\0\0\0" >> ${bsp_image_file}
- # 32 Memory Check
- [ -z $mem_check_flag ] && mem_check_flag
- echo -ne "\x0${mem_check_flag}\0\0\0" >> ${bsp_image_file}
- # 36 Warp Boot
- [ -z $warp_boot ] && warp_boot
- echo -ne "\x0${warp_boot}\0\0\0" >> ${bsp_image_file}
- # 40 Sub Boot Mode
- [ -z $sub_boot_mode ] && sub_boot_mode
- echo -ne "\x0${sub_boot_mode}\0\0\0" >> ${bsp_image_file}
- # 44 Update Selection
- [ -z $update_selection ] && update_selection
- echo -ne "\x0${update_selection}\0\0\0" >> ${bsp_image_file}
- # 48 Update Sub Device
- [ -z $update_sub_device ] && update_sub_device
- echo -ne "\x0${update_sub_device}\0\0\0" >> ${bsp_image_file}
- # Choice Password
- [ -z $choice_password ] && choice_password
- cat <<EOF > /tmp/bsp_image/Copy_Script.sh
- #!/system/bin/sh
- ioctl -l 8 -a 4 /dev/mtd/mtd0 1074285826 2424832 65536 &>/mnt/udisk/ioctllog
- dd if=/mnt/udisk/newbsp.img of=/dev/block/mtdblock0 seek=2424832 count=84 bs=1 &>>/mnt/udisk/ioctllog
- sync
- echo done
- EOF
- echo "choice_password=[${choice_password}]"
- if [ $choice_password == '1' ]
- then
- cat >> /tmp/bsp_image/Copy_Script.sh << EOF
- cat /mnt/udisk/sdunlock>/data/local/tmp/sdunlock
- chmod 777 /data/local/tmp/sdunlock
- /data/local/tmp/sdunlock
- EOF
- fi
- echo "### [/tmp/bsp_image/Copy_Script.sh] ###"
- [ $choice_password == '0' ] && choice_password="LKPFeD4BcVzESR2Y"
- [ $choice_password == '1' ] && choice_password="\x2a\x2a\x2a\x2a\x2a\x2a\x2a\x2a\x2a\x2a\x2a\x2a\x2a\x2a\x2a\x2a"
- #[ $choice_password == '1' ] && choice_password="\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
- echo -ne "${choice_password}" >> ${bsp_image_file}
- echo -ne "${choice_password}" > ${sd_password_file}
- # 68 ui_update_flag
- [ -z $ui_update_flag ] && ui_update_flag
- echo -ne "\x0${ui_update_flag}\0\0\0" >> ${bsp_image_file}
- echo -ne "\xff\xff\xff\xff\xff\xff\xff\xff" >> ${bsp_image_file}
- crc32 ${bsp_image_file}
- bsp_image_crc=`crc32 ${bsp_image_file} | tr -d '\n'`
- echo -ne "\x${bsp_image_crc:6:2}\x${bsp_image_crc:4:2}\x${bsp_image_crc:2:2}\x${bsp_image_crc:0:2}" >> ${bsp_image_file}
- echo -e "bsp_image_crc=[${bsp_image_crc}]"
- echo "### bsp_image_file [${bsp_image_file}] ###"
- hexdump -C ${bsp_image_file}
- echo "### sd_password_file [${sd_password_file}] ###"
- hexdump -C ${sd_password_file}
- echo "### [/tmp/bsp_image/Copy_Script.sh] ###"
- cat /tmp/bsp_image/Copy_Script.sh
- echo "Finished with [$0]"
Advertisement
Add Comment
Please, Sign In to add comment