aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcomputermouth <computermouth@crunchbangplusplus.org>2016-12-21 15:00:38 -0800
committercomputermouth <computermouth@crunchbangplusplus.org>2016-12-21 15:00:38 -0800
commit52634b43aa732cfdc9c64153db63d7fa3e0c0c0f (patch)
tree8b3f4f769f62a8ad1e021fd71e0e2ef349b740dc
parentAdd MIT license (diff)
downloadCHIP-tools-52634b43aa732cfdc9c64153db63d7fa3e0c0c0f.tar.bz2
CHIP-tools-52634b43aa732cfdc9c64153db63d7fa3e0c0c0f.zip
Permit users to set different binaries for the utilities
-rwxr-xr-xchip-create-nand-images.sh17
-rwxr-xr-xcommon.sh32
2 files changed, 30 insertions, 19 deletions
diff --git a/chip-create-nand-images.sh b/chip-create-nand-images.sh
index f3e7c5c..e604e4e 100755
--- a/chip-create-nand-images.sh
+++ b/chip-create-nand-images.sh
@@ -1,10 +1,15 @@
-#!/bin/bash -x
-
-FEL=sunxi-fel
+#!/bin/bash
SCRIPTDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
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"
ROOTFSTAR="$2"
OUTPUTDIR="$3"
@@ -59,7 +64,7 @@ prepare_ubi() {
mkdir -p $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]
mode=ubi
vol_id=0
@@ -93,7 +98,7 @@ prepare_spl() {
local padding=$tmpdir/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 paddingsize=$((64-(splsize/(pagesize+oobsize))))
@@ -101,7 +106,7 @@ prepare_spl() {
while [ $i -lt $repeat ]; do
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
if [ "$i" -eq "0" ]; then
diff --git a/common.sh b/common.sh
index befead6..4a26564 100755
--- a/common.sh
+++ b/common.sh
@@ -1,7 +1,12 @@
#!/bin/bash
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
UBOOTMEMADDR=0x4a000000
UBOOTSCRMEMADDR=0x43100000
@@ -9,13 +14,14 @@ nand_erasesize=400000
nand_writesize=4000
nand_oobsize=680
-if [[ -z $(which $FEL) ]]; then
- echo " Error: Unable to locate FEL utility."
- echo " Install FEL with:"
- echo " CHIP-SDK setup script [github.com/NextThingCo/CHIP-SDK]"
- echo " - or build from source [github.com/linux-sunxi/sunxi-tools]"
- exit 1
-fi
+for TOOL in ${TOOLS[@]}; do
+ if [[ -z $(which $TOOL) ]]; then
+ echo " Error: Unable to locate $TOOL utility."
+ echo " Install $TOOL with:"
+ echo " CHIP-SDK setup script [github.com/NextThingCo/CHIP-SDK]"
+ exit 1
+ fi
+done
#------------------------------------------------------------
onMac() {
@@ -39,7 +45,7 @@ filesize() {
wait_for_fastboot() {
echo -n "waiting for fastboot...";
for ((i=$TIMEOUT; i>0; i--)) {
- if [[ ! -z "$(fastboot -i 0x1f3a $@ devices)" ]]; then
+ if [[ ! -z "$(${FASTBOOT} -i 0x1f3a $@ devices)" ]]; then
echo "OK";
return 0;
fi
@@ -77,7 +83,7 @@ detect_nand() {
echo "nand info
env export -t -s 0x100 0x7c00 nand_erasesize nand_writesize nand_oobsize
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
echo "ERROR: please make sure CHIP is connected and jumpered in FEL mode"
@@ -188,7 +194,7 @@ flash_images() {
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
echo "ERROR: please make sure CHIP is connected and jumpered in FEL mode"
@@ -205,8 +211,8 @@ flash_images() {
$FEL exe $UBOOTMEMADDR || RC=1
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 continue > /dev/null
+ ${FASTBOOT} -i 0x1f3a -u flash UBI $IMAGESDIR/chip-$nand_erasesize-$nand_writesize-$nand_oobsize.ubi.sparse || RC=1
+ ${FASTBOOT} -i 0x1f3a continue > /dev/null
else
echo "failed to flash the UBI image"
RC=1