Browse Source

Formatting

chip/stable
computermouth 6 years ago
parent
commit
43ae8f730c
  1. 49
      chip-update-firmware.sh
  2. 6
      common.sh

49
chip-update-firmware.sh

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

6
common.sh

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

Loading…
Cancel
Save