Permit users to set different binaries for the utilities

This commit is contained in:
computermouth 2016-12-21 15:00:38 -08:00
parent ba4f4587ef
commit 52634b43aa
2 changed files with 30 additions and 19 deletions

View File

@ -1,10 +1,15 @@
#!/bin/bash -x #!/bin/bash
FEL=sunxi-fel
SCRIPTDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) SCRIPTDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source $SCRIPTDIR/common.sh source $SCRIPTDIR/common.sh
if [[ -z $(which ${MKFS_UBIFS}) ]]; then
echo "Could not find ${MKFS_UBIFS} in path."
echo "Install it with the CHIP-SDK setup script."
echo "You will also need to run this script as root."
exit 1
fi
UBOOTDIR="$1" UBOOTDIR="$1"
ROOTFSTAR="$2" ROOTFSTAR="$2"
OUTPUTDIR="$3" OUTPUTDIR="$3"
@ -59,7 +64,7 @@ prepare_ubi() {
mkdir -p $rootfs mkdir -p $rootfs
tar -xf $rootfstar -C $rootfs tar -xf $rootfstar -C $rootfs
mkfs.ubifs -d $rootfs -m $pagesize -e $lebsize -c $maxlebcount -o $ubifs ${MKFS_UBIFS} -d $rootfs -m $pagesize -e $lebsize -c $maxlebcount -o $ubifs
echo "[rootfs] echo "[rootfs]
mode=ubi mode=ubi
vol_id=0 vol_id=0
@ -93,7 +98,7 @@ prepare_spl() {
local padding=$tmpdir/padding local padding=$tmpdir/padding
local splpadding=$tmpdir/nand-spl-padding local splpadding=$tmpdir/nand-spl-padding
sunxi-nand-image-builder -c 64/1024 -p $pagesize -o $oobsize -u 1024 -e $eraseblocksize -b -s $spl $nandspl ${SNIB} -c 64/1024 -p $pagesize -o $oobsize -u 1024 -e $eraseblocksize -b -s $spl $nandspl
local splsize=`filesize $nandspl` local splsize=`filesize $nandspl`
local paddingsize=$((64-(splsize/(pagesize+oobsize)))) local paddingsize=$((64-(splsize/(pagesize+oobsize))))
@ -101,7 +106,7 @@ prepare_spl() {
while [ $i -lt $repeat ]; do while [ $i -lt $repeat ]; do
dd if=/dev/urandom of=$padding bs=1024 count=$paddingsize dd if=/dev/urandom of=$padding bs=1024 count=$paddingsize
sunxi-nand-image-builder -c 64/1024 -p $pagesize -o $oobsize -u 1024 -e $eraseblocksize -b -s $padding $splpadding ${SNIB} -c 64/1024 -p $pagesize -o $oobsize -u 1024 -e $eraseblocksize -b -s $padding $splpadding
cat $nandspl $splpadding > $nandpaddedspl cat $nandspl $splpadding > $nandpaddedspl
if [ "$i" -eq "0" ]; then if [ "$i" -eq "0" ]; then

View File

@ -1,7 +1,12 @@
#!/bin/bash #!/bin/bash
TIMEOUT=30 TIMEOUT=30
FEL=sunxi-fel FEL=${FEL:-sunxi-fel}
FASTBOOT=${FASTBOOT:-fastboot}
MKIMAGE=${MKIMAGE:-mkimage}
MKFS_UBIFS=${MKFS_UBIFS:-mkfs.ubifs}
SNIB=${SNIB:-sunxi-nand-image-builder}
TOOLS=( ${FEL} ${FASTBOOT} ${MKIMAGE} ${SNIB})
SPLMEMADDR=0x43000000 SPLMEMADDR=0x43000000
UBOOTMEMADDR=0x4a000000 UBOOTMEMADDR=0x4a000000
UBOOTSCRMEMADDR=0x43100000 UBOOTSCRMEMADDR=0x43100000
@ -9,13 +14,14 @@ nand_erasesize=400000
nand_writesize=4000 nand_writesize=4000
nand_oobsize=680 nand_oobsize=680
if [[ -z $(which $FEL) ]]; then for TOOL in ${TOOLS[@]}; do
echo " Error: Unable to locate FEL utility." if [[ -z $(which $TOOL) ]]; then
echo " Install FEL with:" echo " Error: Unable to locate $TOOL utility."
echo " CHIP-SDK setup script [github.com/NextThingCo/CHIP-SDK]" echo " Install $TOOL with:"
echo " - or build from source [github.com/linux-sunxi/sunxi-tools]" echo " CHIP-SDK setup script [github.com/NextThingCo/CHIP-SDK]"
exit 1 exit 1
fi fi
done
#------------------------------------------------------------ #------------------------------------------------------------
onMac() { onMac() {
@ -39,7 +45,7 @@ filesize() {
wait_for_fastboot() { wait_for_fastboot() {
echo -n "waiting for fastboot..."; echo -n "waiting for fastboot...";
for ((i=$TIMEOUT; i>0; i--)) { for ((i=$TIMEOUT; i>0; i--)) {
if [[ ! -z "$(fastboot -i 0x1f3a $@ devices)" ]]; then if [[ ! -z "$(${FASTBOOT} -i 0x1f3a $@ devices)" ]]; then
echo "OK"; echo "OK";
return 0; return 0;
fi fi
@ -77,7 +83,7 @@ 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 || return 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"
@ -188,7 +194,7 @@ flash_images() {
echo "$RESET_COMMAND" >> $ubootcmds echo "$RESET_COMMAND" >> $ubootcmds
mkimage -A arm -T script -C none -n "flash $FLAVOR" -d $ubootcmds $ubootscr || RC=1 ${MKIMAGE} -A arm -T script -C none -n "flash $FLAVOR" -d $ubootcmds $ubootscr || RC=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"
@ -205,8 +211,8 @@ flash_images() {
$FEL exe $UBOOTMEMADDR || RC=1 $FEL exe $UBOOTMEMADDR || RC=1
if wait_for_fastboot; then if wait_for_fastboot; then
fastboot -i 0x1f3a -u flash UBI $IMAGESDIR/chip-$nand_erasesize-$nand_writesize-$nand_oobsize.ubi.sparse || RC=1 ${FASTBOOT} -i 0x1f3a -u flash UBI $IMAGESDIR/chip-$nand_erasesize-$nand_writesize-$nand_oobsize.ubi.sparse || RC=1
fastboot -i 0x1f3a continue > /dev/null ${FASTBOOT} -i 0x1f3a continue > /dev/null
else else
echo "failed to flash the UBI image" echo "failed to flash the UBI image"
RC=1 RC=1