diff --git a/chip-update-firmware.sh b/chip-update-firmware.sh index f80f17f..f33da80 100755 --- a/chip-update-firmware.sh +++ b/chip-update-firmware.sh @@ -93,7 +93,7 @@ function require_directory { } function dl_probe { - + if [ -z $CACHENUM ]; then CACHENUM=$(curl -s $DL_URL/$BRANCH/$FLAVOR/latest) fi @@ -117,7 +117,7 @@ function dl_probe { else echo "== Cached probe files located ==" fi - + echo "== Staging for NAND probe ==" ln -s ../../$DL_DIR/${BRANCH}-${FLAVOR}-b${CACHENUM}/ $IMAGESDIR if [[ -f ${IMAGESDIR}/ubi_type ]]; then rm ${IMAGESDIR}/ubi_type; fi @@ -150,7 +150,7 @@ function dl_probe { ;; esac fi - + if [[ ! -f "$DL_DIR/$BRANCH-$FLAVOR-b${CACHENUM}/$UBI_PREFIX-$UBI_TYPE.$UBI_SUFFIX" ]]; then echo "== Downloading new UBI, this will be cached for future flashes. ==" pushd $DL_DIR/${BRANCH}-${FLAVOR}-b${CACHENUM} > /dev/null @@ -170,6 +170,14 @@ rm -rf ${IMAGESDIR} require_directory "$DL_DIR" dl_probe -flash_images - -ready_to_roll +##pass +flash_images && ready_to_roll || ( + ##fail + echo -e "\n FLASH VERIFICATION FAILED.\n\n" + echo -e "\tTROUBLESHOOTING:\n" + echo -e "\tIs the FEL pin connected to GND?" + echo -e "\tHave you tried turning it off and turning it on again?" + echo -e "\tDid you run the setup script in CHIP-SDK?" + echo -e "\tDownload could be corrupt, it can be re-downloaded by adding the '-f' flag." + echo -e "\n\n" +) diff --git a/common.sh b/common.sh index 9cc80f6..a6b998b 100755 --- a/common.sh +++ b/common.sh @@ -109,6 +109,8 @@ reset" > $ubootcmds #------------------------------------------------------------ flash_images() { + local RC=0 + local tmpdir=`mktemp -d -t chip-uboot-script-XXXXXX` local ubootcmds=$tmpdir/uboot.cmds local ubootscr=$tmpdir/uboot.scr @@ -122,7 +124,6 @@ flash_images() { echo "nand erase.chip" > $ubootcmds fi - ## echo "env default -a" >> $ubootcmds echo "nand write.raw.noverify $SPLMEMADDR 0x0 $pagespereb" >> $ubootcmds echo "nand write.raw.noverify $SPLMEMADDR 0x400000 $pagespereb" >> $ubootcmds echo "nand write $UBOOTMEMADDR 0x800000 $ubootsize" >> $ubootcmds @@ -173,29 +174,32 @@ flash_images() { echo "fastboot 0" >> $ubootcmds echo "reset" >> $ubootcmds - mkimage -A arm -T script -C none -n "flash $FLAVOR" -d $ubootcmds $ubootscr + mkimage -A arm -T script -C none -n "flash $FLAVOR" -d $ubootcmds $ubootscr || RC=1 if ! wait_for_fel; then echo "ERROR: please make sure CHIP is connected and jumpered in FEL mode" - exit 1 + RC=1 fi - $FEL spl $IMAGESDIR/sunxi-spl.bin + $FEL spl $IMAGESDIR/sunxi-spl.bin || RC=1 # wait for DRAM initialization to complete sleep 1 - $FEL write $UBOOTMEMADDR $IMAGESDIR/uboot-$nand_erasesize.bin - $FEL write $SPLMEMADDR $IMAGESDIR/spl-$nand_erasesize-$nand_writesize-$nand_oobsize.bin - $FEL write $UBOOTSCRMEMADDR $ubootscr - $FEL exe $UBOOTMEMADDR + $FEL write $UBOOTMEMADDR $IMAGESDIR/uboot-$nand_erasesize.bin || RC=1 + $FEL write $SPLMEMADDR $IMAGESDIR/spl-$nand_erasesize-$nand_writesize-$nand_oobsize.bin || RC=1 + $FEL write $UBOOTSCRMEMADDR $ubootscr || RC=1 + $FEL exe $UBOOTMEMADDR || RC=1 if wait_for_fastboot; then - fastboot -i 0x1f3a -u flash UBI $IMAGESDIR/chip-$nand_erasesize-$nand_writesize.ubi.sparse + fastboot -i 0x1f3a -u flash UBI $IMAGESDIR/chip-$nand_erasesize-$nand_writesize.ubi.sparse || RC=1 else echo "failed to flash the UBI image" + RC=1 fi rm -rf $tmpdir + + return $RC } #------------------------------------------------------------