Formatting

This commit is contained in:
computermouth 2016-10-27 16:30:12 -07:00
parent fd388104fb
commit 43ae8f730c
2 changed files with 32 additions and 23 deletions

View File

@ -8,6 +8,8 @@ IMAGESDIR=".new/firmware/images"
DL_URL="http://opensource.nextthing.co/chip/images" DL_URL="http://opensource.nextthing.co/chip/images"
WGET="wget -q --show-progress"
FLAVOR=server FLAVOR=server
BRANCH=stable BRANCH=stable
@ -26,28 +28,28 @@ UBI_TYPE="400000-4000"
while getopts "sgpbhB:" opt; do while getopts "sgpbhB:" opt; do
case $opt in case $opt in
s) s)
echo "server selected" echo "== Server selected =="
FLAVOR=server FLAVOR=server
;; ;;
g) g)
echo "gui selected" echo "== Gui selected =="
FLAVOR=gui FLAVOR=gui
;; ;;
p) p)
echo "pocketchip selected" echo "== Pocketchip selected =="
FLAVOR=pocketchip FLAVOR=pocketchip
;; ;;
b) b)
echo "buildroot selected" echo "== Buildroot selected =="
FLAVOR=buildroot FLAVOR=buildroot
;; ;;
B) B)
BRANCH="$OPTARG" BRANCH="$OPTARG"
echo "${BRANCH} branch selected" echo "== ${BRANCH} branch selected =="
;; ;;
h) h)
echo "" echo ""
echo "Help" echo "== help =="
echo "" echo ""
echo " -s -- Server [Debian + Headless]" echo " -s -- Server [Debian + Headless]"
echo " -g -- GUI [Debian + XFCE]" echo " -g -- GUI [Debian + XFCE]"
@ -59,7 +61,7 @@ while getopts "sgpbhB:" opt; do
exit 0 exit 0
;; ;;
\?) \?)
echo "Invalid option: -$OPTARG" >&2 echo "== Invalid option: -$OPTARG ==" >&2
exit 1 exit 1
;; ;;
esac esac
@ -73,43 +75,44 @@ function require_directory {
function dl_probe { function dl_probe {
CACHENUM=$(curl $DL_URL/$BRANCH/$FLAVOR/latest) CACHENUM=$(curl -s $DL_URL/$BRANCH/$FLAVOR/latest)
if [[ ! -d "$DL_DIR/$BRANCH-$FLAVOR-b${CACHENUM}" ]]; then if [[ ! -d "$DL_DIR/$BRANCH-$FLAVOR-b${CACHENUM}" ]]; then
echo "New image available" echo "== New image available =="
rm -rf $DL_DIR/$BRANCH-$FLAVOR* rm -rf $DL_DIR/$BRANCH-$FLAVOR*
mkdir -p $DL_DIR/${BRANCH}-${FLAVOR}-b${CACHENUM} mkdir -p $DL_DIR/${BRANCH}-${FLAVOR}-b${CACHENUM}
pushd $DL_DIR/${BRANCH}-${FLAVOR}-b${CACHENUM} pushd $DL_DIR/${BRANCH}-${FLAVOR}-b${CACHENUM} > /dev/null
echo "Downloading.." echo "== Downloading.. =="
for FILE in ${PROBES[@]}; do for FILE in ${PROBES[@]}; do
if ! wget $DL_URL/$BRANCH/$FLAVOR/${CACHENUM}/$FILE; then if ! $WGET $DL_URL/$BRANCH/$FLAVOR/${CACHENUM}/$FILE; then
echo "download of $BRANCH-$FLAVOR-$METHOD-b${CACHENUM} failed!" echo "!! download of $BRANCH-$FLAVOR-$METHOD-b${CACHENUM} failed !!"
exit $? exit $?
fi fi
done done
popd popd > /dev/null
else else
echo "Cached probe files located" echo "== Cached probe files located =="
fi fi
echo "Staging for NAND probe" echo "== Staging for NAND probe =="
ln -s ../../$DL_DIR/${BRANCH}-${FLAVOR}-b${CACHENUM}/ $IMAGESDIR ln -s ../../$DL_DIR/${BRANCH}-${FLAVOR}-b${CACHENUM}/ $IMAGESDIR
rm ${IMAGESDIR}/ubi_type if [[ -f ${IMAGESDIR}/ubi_type ]]; then rm ${IMAGESDIR}/ubi_type; fi
detect_nand detect_nand
if [[ ! -f "$DL_DIR/$BRANCH-$FLAVOR-b${CACHENUM}/$UBI_PREFIX-$UBI_TYPE.$UBI_SUFFIX" ]]; then 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." echo "== Downloading new UBI, this will be cached for future flashes. =="
pushd $DL_DIR/${BRANCH}-${FLAVOR}-b${CACHENUM} pushd $DL_DIR/${BRANCH}-${FLAVOR}-b${CACHENUM} > /dev/null
if ! wget $DL_URL/$BRANCH/$FLAVOR/${CACHENUM}/$UBI_PREFIX-$UBI_TYPE.$UBI_SUFFIX; then if ! $WGET $DL_URL/$BRANCH/$FLAVOR/${CACHENUM}/$UBI_PREFIX-$UBI_TYPE.$UBI_SUFFIX; then
echo "download of $BRANCH-$FLAVOR-$METHOD-b${CACHENUM} failed!" echo "!! download of $BRANCH-$FLAVOR-$METHOD-b${CACHENUM} failed !!"
exit $? exit $?
fi fi
popd popd > /dev/null
else else
echo "Cached UBI located" echo "== Cached UBI located =="
fi fi
} }

View File

@ -67,6 +67,7 @@ wait_for_fel() {
return 1 return 1
} }
#------------------------------------------------------------
detect_nand() { detect_nand() {
local tmpdir=`mktemp -d -t chip-uboot-script-XXXXXX` local tmpdir=`mktemp -d -t chip-uboot-script-XXXXXX`
local ubootcmds=$tmpdir/uboot.cmds local ubootcmds=$tmpdir/uboot.cmds
@ -79,6 +80,7 @@ reset" > $ubootcmds
if ! wait_for_fel; then 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"
exit 1
fi fi
$FEL spl $IMAGESDIR/sunxi-spl.bin $FEL spl $IMAGESDIR/sunxi-spl.bin
@ -91,6 +93,7 @@ reset" > $ubootcmds
if ! wait_for_fel; then 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"
exit 1
fi fi
$FEL read 0x7c00 0x100 $tmpdir/nand-info $FEL read 0x7c00 0x100 $tmpdir/nand-info
@ -104,6 +107,7 @@ reset" > $ubootcmds
rm -rf $tmpdir rm -rf $tmpdir
} }
#------------------------------------------------------------
flash_images() { flash_images() {
local tmpdir=`mktemp -d -t chip-uboot-script-XXXXXX` local tmpdir=`mktemp -d -t chip-uboot-script-XXXXXX`
local ubootcmds=$tmpdir/uboot.cmds local ubootcmds=$tmpdir/uboot.cmds
@ -148,6 +152,7 @@ flash_images() {
if ! wait_for_fel; then 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"
exit 1
fi fi
$FEL spl $IMAGESDIR/sunxi-spl.bin $FEL spl $IMAGESDIR/sunxi-spl.bin
@ -186,6 +191,7 @@ wait_for_linuxboot() {
return 1 return 1
} }
#------------------------------------------------------------
ready_to_roll() { ready_to_roll() {
echo -e "\n\nFLASH VERIFICATION COMPLETE.\n\n" echo -e "\n\nFLASH VERIFICATION COMPLETE.\n\n"