Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- fail() {
- echo -e "\033[1;31m"
- echo "************************************************************"
- echo "* !!! AN ERROR OCCURED !!! *"
- echo "************************************************************"
- echo "* An error occured during flashing process. *"
- echo "* Your device is now probably not able to boot, therefore *"
- echo "* DO NOT PRESS RESET and *"
- echo "* LEAVE THE DEVICE CONNECTED TO THE POWER SUPPLY! *"
- echo "* For further instructions contact the author: *"
- echo "* *"
- echo "* MAIL: Marek Vasut <marek.vasut@gmail.com> *"
- echo "* *"
- echo "************************************************************"
- echo -e "\033[1;37m"
- exit 1
- }
- flashfail() {
- echo -e "\033[1;31m"
- echo "************************************************************"
- echo "* !!! AN ERROR OCCURED DURING FLASH!!! *"
- echo "************************************************************"
- echo -e "\033[1;37m"
- echo -en " \033[1;34;64m(II)\033[1;37m Attempting to restore BLOB ..."
- echo "dd if=/mnt/sd0/orig.blob.bin of=/dev/mtdblock0 2>/dev/null || fail"
- echo -e "\r \033[1;32;64m(II)\033[1;37m Attempting to restore BLOB ... OK"
- echo -e "\033[1;31m"
- echo "************************************************************"
- echo "* BLOB restored, hopefully a brick was avoided! *"
- echo "************************************************************"
- echo -e "\033[1;37m"
- exit 1
- }
- mmcfail() {
- echo -e "\r \033[1;31;64m(EE)\033[1;37m Checking if SD/MMC card contains needed files ... FAIL"
- echo "************************************************************"
- echo "* Please recheck if you really copied all the files to *"
- echo "* proper locations on the memory card and try again. *"
- echo "* The installation system will now exit to shell. *"
- echo "* No changes were made to your device yet, it's safe to *"
- echo "* reset the device and try again. *"
- echo "************************************************************"
- exit 1
- }
- backupfail() {
- echo -e "\r \033[1;31;64m(EE)\033[1;37m Backing up flash and original wifi firmware to mmc ... FAIL"
- echo "************************************************************"
- echo "* Backing up original contents of flash failed, *"
- echo "* aborting installation. *"
- echo "************************************************************"
- exit 1
- }
- export PATH=$PATH:/mnt/sd0/bin
- insmod /mnt/sd0/modules/softcursor.ko
- insmod /mnt/sd0/modules/fbcon_ud.ko
- insmod /mnt/sd0/modules/fbcon_cw.ko
- insmod /mnt/sd0/modules/fbcon_ccw.ko
- insmod /mnt/sd0/modules/fbcon_rotate.ko
- insmod /mnt/sd0/modules/bitblit.ko
- insmod /mnt/sd0/modules/font.ko
- insmod /mnt/sd0/modules/fbcon.ko
- mkdir /sys
- mount -t sysfs sysfs /sys
- echo 3 > /sys/class/graphics/fbcon/rotate
- mknod /dev/tty0 c 4 0
- reset
- echo -en "\033[1;37m"
- echo "************************************************************"
- echo "* Welcome to the Zipit Z2 u-boot installation utility *"
- echo "* Copyright (C) 2009 Marek Vasut <marek.vasut@gmail.com> *"
- echo "* shamelessly pillaged by sweetlilmre *"
- echo "* <sweetlilmre@gmail.com> and repurposed for the Zipit Z2 *"
- echo "************************************************************"
- echo "* This tool will permanently install U-Boot onto your *"
- echo "* device by replacing the previous BLOB bootloader. Before *"
- echo "* proceeding, please make sure you have a FULLY CHARGED *"
- echo "* battery and the Z2 is connected to the AC Charger *"
- echo "* *"
- echo "* !!! Very important: The author is NOT LIABLE for ANY *"
- echo "* damage caused by using this script *"
- echo "* and/or related software. In case *"
- echo "* your device gets damaged, it's your *"
- echo "* problem (though contacting the *"
- echo "* author in a polite manner would *"
- echo "* be helpful for both interested *"
- echo "* parties). *"
- echo "* *"
- echo "* If you completed those steps above and agree, that it's *"
- echo "* your problem if you brick your device, press any key to *"
- echo "* continue and start the flashing process. *"
- echo "* If you decided not to reflash the device, press the *"
- echo "* RESET button at the side of the device. *"
- echo "* *"
- echo "* In case you have any further questions, fear not and *"
- echo "* visit us at: *"
- echo "* IRC: #zipit @ irc.freenode.net *"
- echo "************************************************************"
- read
- reset
- echo -en " \033[1;34;64m(II)\033[1;37m Checking if SD/MMC card contains needed files ..."
- [ `ls -la /mnt/sd0/u-boot-zipit2.bin | tr -s " " | cut -d " " -f 5` -gt 0 ] || mmcfail
- echo -e "\r \033[1;32;64m(II)\033[1;37m Checking if SD/MMC card contains needed files ... OK"
- echo -en " \033[1;34;64m(II)\033[1;37m Fixing bad mtdblock1 descriptor ..."
- rm /dev/mtdblock1 || backupfail
- mknod /dev/mtdblock1 b 31 1 || backupfail
- echo -e "\r \033[1;32;64m(II)\033[1;37m Fixing bad mtdblock1 descriptor ... OK"
- echo -en " \033[1;34;64m(II)\033[1;37m Backing up flash and original wifi firmware to mmc ..."
- rm -f /mnt/sd0/orig.blob.bin || backupfail
- touch /mnt/sd0/orig.blob.bin || backupfail
- dd if=/dev/mtdblock0 of=/mnt/sd0/orig.blob.bin 2>/dev/null || backupfail
- rm -f /mnt/sd0/orig.kernel.bin || backupfail
- touch /mnt/sd0/orig.kernel.bin || backupfail
- dd if=/dev/mtdblock1 of=/mnt/sd0/orig.kernel.bin 2>/dev/null || backupfail
- cp /lib/firmware/* /mnt/sd0 || backupfail
- sync || backupfail
- echo -e "\r \033[1;32;64m(II)\033[1;37m Backing up flash and original wifi firmware to mmc ... OK"
- echo -e "\n \033[1;32;64m(II)\033[1;37m Initiating reflashing process\n"
- echo -en " \033[1;34;64m(II)\033[1;37m Chopping U-Boot ... "
- dd if=/mnt/sd0/u-boot-zipit2.bin of=/mnt/sd0/u-boot.part1 bs=64k count=1 2>/dev/null || fail
- dd if=/mnt/sd0/u-boot-zipit2.bin of=/mnt/sd0/u-boot.part2 bs=64k skip=1 2>/dev/null || fail
- echo -e "\r \033[1;32;64m(II)\033[1;37m Chopping U-Boot ... OK"
- echo -en " \033[1;34;64m(II)\033[1;37m Installing U-Boot bootloader part 2... "
- echo "dd if=/mnt/sd0/u-boot.part2 of=/dev/mtdblock1 2>/dev/null || flashfail"
- echo -e "\r \033[1;32;64m(II)\033[1;37m Installing U-Boot bootloader part 2... OK"
- echo -en " \033[1;34;64m(II)\033[1;37m Installing U-Boot bootloader part 1... "
- echo "dd if=/mnt/sd0/u-boot.part1 of=/dev/mtdblock0 2>/dev/null || flashfail"
- echo -e "\r \033[1;32;64m(II)\033[1;37m Installing U-Boot bootloader part 1... OK"
- echo -en " \033[1;34;64m(II)\033[1;37m Verifying U-Boot bootloader ... "
- 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
- echo -e "\r \033[1;32;64m(II)\033[1;37m Verifying U-Boot bootloader ... OK"
- rm -f /mnt/sd0/tmp.tmp
- sync
- echo -e "\n \033[1;32;64m(II)\033[1;37m It's generally safe beyond this point.\n"
- sync
- echo -e "\033[1;37m"
- echo "********************************************************************************"
- echo "* Installation finished *"
- echo "********************************************************************************"
- echo "* Your device has been successfully reflashed with GNU/Linux. You can now *"
- echo "* safely press RESET button at the back of the device and enjoy the new and *"
- echo "* interesting world of GNU/Linux on your PDA. *"
- echo "********************************************************************************"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement