Add error codes to flasher script

This commit is contained in:
Wynter Woods 2015-11-09 05:54:54 -08:00
parent 7e908446d0
commit a37d5c2538
1 changed files with 39 additions and 20 deletions

View File

@ -121,7 +121,17 @@ prepare_uboot_script() {
mkimage -A arm -T script -C none -n "flash CHIP" -d "${UBOOT_SCRIPT_SRC}" "${UBOOT_SCRIPT}" mkimage -A arm -T script -C none -n "flash CHIP" -d "${UBOOT_SCRIPT_SRC}" "${UBOOT_SCRIPT}"
} }
assert_error() {
ERR=$?
ERRCODE=$1
if [ "${ERR}" != "0" ]; then
if [ -z "${ERR}" ]; then
exit ${ERR}
fi
else
exit ${ERRCODE}
fi
}
echo == preparing images == echo == preparing images ==
prepare_images prepare_images
@ -132,41 +142,50 @@ if ! wait_for_fel; then
echo "ERROR: please make sure CHIP is connected and jumpered in FEL mode" echo "ERROR: please make sure CHIP is connected and jumpered in FEL mode"
fi fi
${FEL} spl "${SPL}" ${FEL} spl "${SPL}"
assert_error 128
sleep 1 # wait for DRAM initialization to complete sleep 1 # wait for DRAM initialization to complete
echo == upload spl == echo == upload spl ==
${FEL} write $SPL_MEM_ADDR "${PADDED_SPL}" || ( echo "ERROR: could not write ${PADDED_SPL}" && exit $? ) ${FEL} write $SPL_MEM_ADDR "${PADDED_SPL}" || ( echo "ERROR: could not write ${PADDED_SPL}" && exit $? )
assert_error 129
echo == upload u-boot == echo == upload u-boot ==
${FEL} write $UBOOT_MEM_ADDR "${PADDED_UBOOT}" || ( echo "ERROR: could not write ${PADDED_UBOOT}" && exit $? ) ${FEL} write $UBOOT_MEM_ADDR "${PADDED_UBOOT}" || ( echo "ERROR: could not write ${PADDED_UBOOT}" && exit $? )
assert_error 130
echo == upload u-boot script == echo == upload u-boot script ==
${FEL} write $UBOOT_SCRIPT_MEM_ADDR "${UBOOT_SCRIPT}" || ( echo "ERROR: could not write ${UBOOT_SCRIPT}" && exit $? ) ${FEL} write $UBOOT_SCRIPT_MEM_ADDR "${UBOOT_SCRIPT}" || ( echo "ERROR: could not write ${UBOOT_SCRIPT}" && exit $? )
assert_error 131
if [[ "${METHOD}" == "fel" ]]; then if [[ "${METHOD}" == "fel" ]]; then
echo == upload ubi == echo == upload ubi ==
${FEL} --progress write $UBI_MEM_ADDR "${UBI}" ${FEL} --progress write $UBI_MEM_ADDR "${UBI}"
echo == execute the main u-boot binary == echo == execute the main u-boot binary ==
${FEL} exe $UBOOT_MEM_ADDR ${FEL} exe $UBOOT_MEM_ADDR
echo == write ubi == echo == write ubi ==
else else
echo == execute the main u-boot binary == echo == execute the main u-boot binary ==
${FEL} exe $UBOOT_MEM_ADDR ${FEL} exe $UBOOT_MEM_ADDR
assert_error 132
echo == creating sparse image ==
img2simg ${UBI} ${SPARSE_UBI} $((2*1024*1024)) echo == creating sparse image ==
img2simg ${UBI} ${SPARSE_UBI} $((2*1024*1024))
echo == waiting for fastboot == assert_error 133
if wait_for_fastboot; then
fastboot -i 0x1f3a -u flash UBI ${SPARSE_UBI} echo == waiting for fastboot ==
fastboot -i 0x1f3a continue if wait_for_fastboot; then
else fastboot -i 0x1f3a -u flash UBI ${SPARSE_UBI}
rm -rf "${TMPDIR}" assert_error 134
exit 1
fi fastboot -i 0x1f3a continue
assert_error 135
else
rm -rf "${TMPDIR}"
exit 1
fi
fi fi
rm -rf "${TMPDIR}" rm -rf "${TMPDIR}"