aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md7
-rwxr-xr-xscripts/uboot-script-gen38
2 files changed, 39 insertions, 6 deletions
diff --git a/README.md b/README.md
index 0df4e4b..f7da514 100644
--- a/README.md
+++ b/README.md
@@ -97,9 +97,10 @@ Where:\
-d specifies the "root" directory (paths in the config file are relative
to it), this is not a working directory (any output file locations
are specified in the config and any temporary files are in /tmp)\
--t specifies the u-boot command to load the binaries. "tftp" and "sd"
- are shorthands for "tftpb" and "load scsi 0:1", but actually any
- arbitrary command can be used, for instance -t "fatload" is valid.\
+-t specifies the u-boot command to load the binaries. "tftp", "sd" and
+ "scsi" are shorthands for "tftpb", "load mmc 0:1" and
+ "load scsi 0:1", but actually any arbitrary command can be used, for
+ instance -t "fatload" is valid.\
-o specifies the output filename for the uboot script and its source.\
diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen
index ef26da1..bc41d1f 100755
--- a/scripts/uboot-script-gen
+++ b/scripts/uboot-script-gen
@@ -196,7 +196,8 @@ function print_help
echo "where:"
echo " CONFIG_FILE - configuration file"
echo " UBOOT_TYPE can be:"
- echo " sd - alias for \"scsi load 0:1\" for uboot load commands"
+ echo " sd - alias for \"mmc load 0:1\" for uboot load commands"
+ echo " scsi - alias for \"scsi load 0:1\" for uboot load commands"
echo " tftp - alias for \"tftpb\" for uboot load cammnds"
echo " < > - used for uboot load commands"
echo " DIRECTORY - root directory where the files of CONFIG_FILE are located"
@@ -212,9 +213,12 @@ while getopts ":c:t:d:ho:" opt; do
case ${opt} in
t )
case $OPTARG in
- sd )
+ scsi )
LOAD_CMD="load scsi 0:1"
;;
+ sd )
+ LOAD_CMD="load mmc 0:1"
+ ;;
tftp )
LOAD_CMD="tftpb"
;;
@@ -276,7 +280,35 @@ then
then
DOM0_CMD="$DOM0_CMD root=/dev/ram0"
else
- DOM0_CMD="$DOM0_CMD root=/dev/sda2"
+ DEV=${LOAD_CMD%:*}
+ DEV=${DEV##* }
+ PAR=${LOAD_CMD#*:}
+
+ if [ -z "$DEV" ] || [ -z "$PAR" ]
+ then
+ echo "Could not parse device and partition."
+ echo "Please make sure the load command is correct or manually set DOM0_CMD in the config file."
+ exit 1
+ fi
+
+ PAR=$((PAR + 1))
+
+ if [[ $LOAD_CMD =~ mmc ]]
+ then
+ DOM0_CMD="$DOM0_CMD root=/dev/mmcblk${DEV}p${PAR}"
+ elif [[ $LOAD_CMD =~ scsi ]]
+ then
+ # converts number to a scsi device character
+ DEV=$((DEV + 97))
+ DEV=$(printf %x $DEV)
+ DEV=$(printf "\x$DEV")
+
+ DOM0_CMD="$DOM0_CMD root=/dev/sd${DEV}${PAR}"
+ else
+ echo "Only mmc and scsi are supported for automatically setting the root partition."
+ echo "Manually set DOM0_CMD with the root device in the config file to bypass this."
+ exit 1
+ fi
fi
fi
i=0