Added local flash option
This commit is contained in:
parent
0a91687a6d
commit
9211092c4a
@ -25,7 +25,7 @@ UBI_PREFIX="chip"
|
|||||||
UBI_SUFFIX="ubi.sparse"
|
UBI_SUFFIX="ubi.sparse"
|
||||||
UBI_TYPE="400000-4000-680"
|
UBI_TYPE="400000-4000-680"
|
||||||
|
|
||||||
while getopts "sgpbfnrhB:N:F:" opt; do
|
while getopts "sgpbfnrhB:N:F:L:" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
s)
|
s)
|
||||||
echo "== Server selected =="
|
echo "== Server selected =="
|
||||||
@ -67,6 +67,10 @@ while getopts "sgpbfnrhB:N:F:" opt; do
|
|||||||
FORMAT="$OPTARG"
|
FORMAT="$OPTARG"
|
||||||
echo "== Format ${FORMAT} selected =="
|
echo "== Format ${FORMAT} selected =="
|
||||||
;;
|
;;
|
||||||
|
L)
|
||||||
|
LOCALDIR="$OPTARG"
|
||||||
|
echo "== Local directory '${LOCALDIR}' selected =="
|
||||||
|
;;
|
||||||
h)
|
h)
|
||||||
echo ""
|
echo ""
|
||||||
echo "== Help =="
|
echo "== Help =="
|
||||||
@ -81,6 +85,7 @@ while getopts "sgpbfnrhB:N:F:" opt; do
|
|||||||
echo " -B -- Branch(optional) [eg. -B testing]"
|
echo " -B -- Branch(optional) [eg. -B testing]"
|
||||||
echo " -N -- Build#(optional) [eg. -N 150]"
|
echo " -N -- Build#(optional) [eg. -N 150]"
|
||||||
echo " -F -- Format(optional) [eg. -F Toshiba_4G_MLC]"
|
echo " -F -- Format(optional) [eg. -F Toshiba_4G_MLC]"
|
||||||
|
echo " -L -- Local (optional) [eg. -L ../img/buildroot/]"
|
||||||
echo ""
|
echo ""
|
||||||
echo ""
|
echo ""
|
||||||
exit 0
|
exit 0
|
||||||
@ -104,7 +109,7 @@ function dl_probe {
|
|||||||
CACHENUM=$(curl -s $DL_URL/$BRANCH/$FLAVOR/latest)
|
CACHENUM=$(curl -s $DL_URL/$BRANCH/$FLAVOR/latest)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -d "$DL_DIR/$BRANCH-$FLAVOR-b${CACHENUM}" ]]; then
|
if [[ ! -d "$DL_DIR/$BRANCH-$FLAVOR-b${CACHENUM}" ]] && [[ -z $LOCALDIR ]]; then
|
||||||
echo "== New image available =="
|
echo "== New image available =="
|
||||||
|
|
||||||
rm -rf $DL_DIR/$BRANCH-$FLAVOR*
|
rm -rf $DL_DIR/$BRANCH-$FLAVOR*
|
||||||
@ -121,43 +126,46 @@ function dl_probe {
|
|||||||
done
|
done
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
else
|
else
|
||||||
echo "== Cached probe files located =="
|
echo "== Local/cached probe files located =="
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "== Staging for NAND probe =="
|
echo "== Staging for NAND probe =="
|
||||||
|
if [ -z LOCALDIR ];then
|
||||||
ln -s ../../$DL_DIR/${BRANCH}-${FLAVOR}-b${CACHENUM}/ $IMAGESDIR
|
ln -s ../../$DL_DIR/${BRANCH}-${FLAVOR}-b${CACHENUM}/ $IMAGESDIR
|
||||||
|
else
|
||||||
|
ln -s ../../$LOCALDIR $IMAGESDIR
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -f ${IMAGESDIR}/ubi_type ]]; then rm ${IMAGESDIR}/ubi_type; fi
|
if [[ -f ${IMAGESDIR}/ubi_type ]]; then rm ${IMAGESDIR}/ubi_type; fi
|
||||||
|
|
||||||
if [ -z $FORMAT ]; then
|
if [ -z $FORMAT ]; then
|
||||||
detect_nand
|
detect_nand || exit 1
|
||||||
else
|
else
|
||||||
case $FORMAT in
|
case $FORMAT in
|
||||||
"Hynix_8G_MLC")
|
"Hynix_8G_MLC")
|
||||||
export nand_erasesize=400000
|
export nand_erasesize=400000
|
||||||
export nand_oobsize=680
|
export nand_oobsize=680
|
||||||
export nand_writesize=4000
|
export nand_writesize=4000
|
||||||
UBI_TYPE="400000-4000-680"
|
|
||||||
;;
|
;;
|
||||||
"Toshiba_4G_MLC")
|
"Toshiba_4G_MLC")
|
||||||
export nand_erasesize=400000
|
export nand_erasesize=400000
|
||||||
export nand_oobsize=500
|
export nand_oobsize=500
|
||||||
export nand_writesize=4000
|
export nand_writesize=4000
|
||||||
UBI_TYPE="400000-4000-500"
|
|
||||||
;;
|
;;
|
||||||
"Toshiba_512M_MLC")
|
"Toshiba_512M_MLC")
|
||||||
export nand_erasesize=40000
|
export nand_erasesize=40000
|
||||||
export nand_oobsize=100
|
export nand_oobsize=100
|
||||||
export nand_writesize=1000
|
export nand_writesize=1000
|
||||||
UBI_TYPE="400000-1000-100"
|
|
||||||
;;
|
;;
|
||||||
\?)
|
\?)
|
||||||
echo "== Invalid format: $FORMAT ==" >&2
|
echo "== Invalid format: $FORMAT ==" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
UBI_TYPE="$nand_erasesize-$nand_writesize-$nand_oobsize"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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" ]] && [ -z $LOCALDIR ]; 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} > /dev/null
|
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
|
||||||
@ -166,7 +174,16 @@ function dl_probe {
|
|||||||
fi
|
fi
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
else
|
else
|
||||||
|
if [ -z $LOCALDIR ]; then
|
||||||
echo "== Cached UBI located =="
|
echo "== Cached UBI located =="
|
||||||
|
else
|
||||||
|
if [[ ! -f "$IMAGESDIR/$UBI_PREFIX-$UBI_TYPE.$UBI_SUFFIX" ]]; then
|
||||||
|
echo "Could not locate UBI files"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "== Cached UBI located =="
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
26
common.sh
26
common.sh
@ -69,7 +69,6 @@ wait_for_fel() {
|
|||||||
|
|
||||||
#------------------------------------------------------------
|
#------------------------------------------------------------
|
||||||
detect_nand() {
|
detect_nand() {
|
||||||
local RC=0
|
|
||||||
|
|
||||||
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
|
||||||
@ -78,38 +77,37 @@ detect_nand() {
|
|||||||
echo "nand info
|
echo "nand info
|
||||||
env export -t -s 0x100 0x7c00 nand_erasesize nand_writesize nand_oobsize
|
env export -t -s 0x100 0x7c00 nand_erasesize nand_writesize nand_oobsize
|
||||||
reset" > $ubootcmds
|
reset" > $ubootcmds
|
||||||
mkimage -A arm -T script -C none -n "detect NAND" -d $ubootcmds $ubootscr || RC=1
|
mkimage -A arm -T script -C none -n "detect NAND" -d $ubootcmds $ubootscr || return 1
|
||||||
|
|
||||||
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"
|
||||||
RC=1
|
return 1
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
$FEL spl $IMAGESDIR/sunxi-spl.bin || RC=1
|
$FEL spl $IMAGESDIR/sunxi-spl.bin || return 1
|
||||||
# wait for DRAM initialization to complete
|
# wait for DRAM initialization to complete
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
$FEL write $UBOOTMEMADDR $IMAGESDIR/u-boot-dtb.bin || RC=1
|
$FEL write $UBOOTMEMADDR $IMAGESDIR/u-boot-dtb.bin || return 1
|
||||||
$FEL write $UBOOTSCRMEMADDR $ubootscr || RC=1
|
$FEL write $UBOOTSCRMEMADDR $ubootscr || return 1
|
||||||
$FEL exe $UBOOTMEMADDR || RC=1
|
$FEL exe $UBOOTMEMADDR || return 1
|
||||||
|
|
||||||
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
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
$FEL read 0x7c00 0x100 $tmpdir/nand-info || RC=1
|
$FEL read 0x7c00 0x100 $tmpdir/nand-info || return 1
|
||||||
|
|
||||||
echo "NAND detected:"
|
echo "NAND detected:"
|
||||||
cat $tmpdir/nand-info || RC=1
|
cat $tmpdir/nand-info || return 1
|
||||||
UBI_TYPE="$(cat $tmpdir/nand-info | awk -F= '/erase/ {print $2}')-$(cat $tmpdir/nand-info | awk -F= '/write/ {print $2}')-$(cat $tmpdir/nand-info | awk -F= '/oob/ {print $2}')"
|
UBI_TYPE="$(cat $tmpdir/nand-info | awk -F= '/erase/ {print $2}')-$(cat $tmpdir/nand-info | awk -F= '/write/ {print $2}')-$(cat $tmpdir/nand-info | awk -F= '/oob/ {print $2}')"
|
||||||
echo "${UBI_TYPE}" > $IMAGESDIR/ubi_type || RC=1
|
echo "${UBI_TYPE}" > $IMAGESDIR/ubi_type || return 1
|
||||||
source $tmpdir/nand-info || RC=1
|
source $tmpdir/nand-info || return 1
|
||||||
|
|
||||||
rm -rf $tmpdir
|
rm -rf $tmpdir
|
||||||
|
|
||||||
return $RC
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
#------------------------------------------------------------
|
#------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user