Advertisement
Guest User

Untitled

a guest
Sep 8th, 2017
452
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.14 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. fail() {
  4. echo -e "\033[1;31m"
  5. echo "************************************************************"
  6. echo "* !!! AN ERROR OCCURED !!! *"
  7. echo "************************************************************"
  8. echo "* An error occured during flashing process. *"
  9. echo "* Your device is now probably not able to boot, therefore *"
  10. echo "* DO NOT PRESS RESET and *"
  11. echo "* LEAVE THE DEVICE CONNECTED TO THE POWER SUPPLY! *"
  12. echo "* For further instructions contact the author: *"
  13. echo "* *"
  14. echo "* MAIL: Marek Vasut <marek.vasut@gmail.com> *"
  15. echo "* *"
  16. echo "************************************************************"
  17. echo -e "\033[1;37m"
  18. exit 1
  19. }
  20.  
  21. flashfail() {
  22. echo -e "\033[1;31m"
  23. echo "************************************************************"
  24. echo "* !!! AN ERROR OCCURED DURING FLASH!!! *"
  25. echo "************************************************************"
  26. echo -e "\033[1;37m"
  27.  
  28. echo -en " \033[1;34;64m(II)\033[1;37m Attempting to restore BLOB ..."
  29. echo "dd if=/mnt/sd0/orig.blob.bin of=/dev/mtdblock0 2>/dev/null || fail"
  30. echo -e "\r \033[1;32;64m(II)\033[1;37m Attempting to restore BLOB ... OK"
  31.  
  32. echo -e "\033[1;31m"
  33. echo "************************************************************"
  34. echo "* BLOB restored, hopefully a brick was avoided! *"
  35. echo "************************************************************"
  36. echo -e "\033[1;37m"
  37. exit 1
  38. }
  39.  
  40. mmcfail() {
  41. echo -e "\r \033[1;31;64m(EE)\033[1;37m Checking if SD/MMC card contains needed files ... FAIL"
  42. echo "************************************************************"
  43. echo "* Please recheck if you really copied all the files to *"
  44. echo "* proper locations on the memory card and try again. *"
  45. echo "* The installation system will now exit to shell. *"
  46. echo "* No changes were made to your device yet, it's safe to *"
  47. echo "* reset the device and try again. *"
  48. echo "************************************************************"
  49. exit 1
  50. }
  51.  
  52. backupfail() {
  53. echo -e "\r \033[1;31;64m(EE)\033[1;37m Backing up flash and original wifi firmware to mmc ... FAIL"
  54. echo "************************************************************"
  55. echo "* Backing up original contents of flash failed, *"
  56. echo "* aborting installation. *"
  57. echo "************************************************************"
  58. exit 1
  59. }
  60.  
  61. export PATH=$PATH:/mnt/sd0/bin
  62.  
  63. insmod /mnt/sd0/modules/softcursor.ko
  64. insmod /mnt/sd0/modules/fbcon_ud.ko
  65. insmod /mnt/sd0/modules/fbcon_cw.ko
  66. insmod /mnt/sd0/modules/fbcon_ccw.ko
  67. insmod /mnt/sd0/modules/fbcon_rotate.ko
  68. insmod /mnt/sd0/modules/bitblit.ko
  69. insmod /mnt/sd0/modules/font.ko
  70. insmod /mnt/sd0/modules/fbcon.ko
  71.  
  72. mkdir /sys
  73. mount -t sysfs sysfs /sys
  74. echo 3 > /sys/class/graphics/fbcon/rotate
  75. mknod /dev/tty0 c 4 0
  76.  
  77. reset
  78. echo -en "\033[1;37m"
  79. echo "************************************************************"
  80. echo "* Welcome to the Zipit Z2 u-boot installation utility *"
  81. echo "* Copyright (C) 2009 Marek Vasut <marek.vasut@gmail.com> *"
  82. echo "* shamelessly pillaged by sweetlilmre *"
  83. echo "* <sweetlilmre@gmail.com> and repurposed for the Zipit Z2 *"
  84. echo "************************************************************"
  85. echo "* This tool will permanently install U-Boot onto your *"
  86. echo "* device by replacing the previous BLOB bootloader. Before *"
  87. echo "* proceeding, please make sure you have a FULLY CHARGED *"
  88. echo "* battery and the Z2 is connected to the AC Charger *"
  89. echo "* *"
  90. echo "* !!! Very important: The author is NOT LIABLE for ANY *"
  91. echo "* damage caused by using this script *"
  92. echo "* and/or related software. In case *"
  93. echo "* your device gets damaged, it's your *"
  94. echo "* problem (though contacting the *"
  95. echo "* author in a polite manner would *"
  96. echo "* be helpful for both interested *"
  97. echo "* parties). *"
  98. echo "* *"
  99. echo "* If you completed those steps above and agree, that it's *"
  100. echo "* your problem if you brick your device, press any key to *"
  101. echo "* continue and start the flashing process. *"
  102. echo "* If you decided not to reflash the device, press the *"
  103. echo "* RESET button at the side of the device. *"
  104. echo "* *"
  105. echo "* In case you have any further questions, fear not and *"
  106. echo "* visit us at: *"
  107. echo "* IRC: #zipit @ irc.freenode.net *"
  108. echo "************************************************************"
  109. read
  110.  
  111. reset
  112. echo -en " \033[1;34;64m(II)\033[1;37m Checking if SD/MMC card contains needed files ..."
  113. [ `ls -la /mnt/sd0/u-boot-zipit2.bin | tr -s " " | cut -d " " -f 5` -gt 0 ] || mmcfail
  114. echo -e "\r \033[1;32;64m(II)\033[1;37m Checking if SD/MMC card contains needed files ... OK"
  115.  
  116. echo -en " \033[1;34;64m(II)\033[1;37m Fixing bad mtdblock1 descriptor ..."
  117. rm /dev/mtdblock1 || backupfail
  118. mknod /dev/mtdblock1 b 31 1 || backupfail
  119. echo -e "\r \033[1;32;64m(II)\033[1;37m Fixing bad mtdblock1 descriptor ... OK"
  120.  
  121. echo -en " \033[1;34;64m(II)\033[1;37m Backing up flash and original wifi firmware to mmc ..."
  122. rm -f /mnt/sd0/orig.blob.bin || backupfail
  123. touch /mnt/sd0/orig.blob.bin || backupfail
  124. dd if=/dev/mtdblock0 of=/mnt/sd0/orig.blob.bin 2>/dev/null || backupfail
  125.  
  126. rm -f /mnt/sd0/orig.kernel.bin || backupfail
  127. touch /mnt/sd0/orig.kernel.bin || backupfail
  128. dd if=/dev/mtdblock1 of=/mnt/sd0/orig.kernel.bin 2>/dev/null || backupfail
  129.  
  130. cp /lib/firmware/* /mnt/sd0 || backupfail
  131.  
  132. sync || backupfail
  133.  
  134. echo -e "\r \033[1;32;64m(II)\033[1;37m Backing up flash and original wifi firmware to mmc ... OK"
  135.  
  136. echo -e "\n \033[1;32;64m(II)\033[1;37m Initiating reflashing process\n"
  137.  
  138. echo -en " \033[1;34;64m(II)\033[1;37m Chopping U-Boot ... "
  139. dd if=/mnt/sd0/u-boot-zipit2.bin of=/mnt/sd0/u-boot.part1 bs=64k count=1 2>/dev/null || fail
  140. dd if=/mnt/sd0/u-boot-zipit2.bin of=/mnt/sd0/u-boot.part2 bs=64k skip=1 2>/dev/null || fail
  141. echo -e "\r \033[1;32;64m(II)\033[1;37m Chopping U-Boot ... OK"
  142.  
  143. echo -en " \033[1;34;64m(II)\033[1;37m Installing U-Boot bootloader part 2... "
  144. echo "dd if=/mnt/sd0/u-boot.part2 of=/dev/mtdblock1 2>/dev/null || flashfail"
  145. echo -e "\r \033[1;32;64m(II)\033[1;37m Installing U-Boot bootloader part 2... OK"
  146.  
  147. echo -en " \033[1;34;64m(II)\033[1;37m Installing U-Boot bootloader part 1... "
  148. echo "dd if=/mnt/sd0/u-boot.part1 of=/dev/mtdblock0 2>/dev/null || flashfail"
  149. echo -e "\r \033[1;32;64m(II)\033[1;37m Installing U-Boot bootloader part 1... OK"
  150.  
  151.  
  152. echo -en " \033[1;34;64m(II)\033[1;37m Verifying U-Boot bootloader ... "
  153. echo dd if=/dev/mtdblock0 of=/mnt/sd0/tmp.tmp bs=64k count=1 2>/dev/null ; [ `md5sum /mnt/sd0/tmp.tmp | cut -d " " -f 1` = `md5sum /mnt/sd0/u-boot.part1 | cut -d " " -f 1` ] || flashfail
  154. echo -e "\r \033[1;32;64m(II)\033[1;37m Verifying U-Boot bootloader ... OK"
  155. rm -f /mnt/sd0/tmp.tmp
  156. sync
  157.  
  158. echo -e "\n \033[1;32;64m(II)\033[1;37m It's generally safe beyond this point.\n"
  159.  
  160.  
  161. sync
  162.  
  163. echo -e "\033[1;37m"
  164. echo "********************************************************************************"
  165. echo "* Installation finished *"
  166. echo "********************************************************************************"
  167. echo "* Your device has been successfully reflashed with GNU/Linux. You can now *"
  168. echo "* safely press RESET button at the back of the device and enjoy the new and *"
  169. echo "* interesting world of GNU/Linux on your PDA. *"
  170. echo "********************************************************************************"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement