From 6f1950c30cfec0fee35a6c977166148274f037dd Mon Sep 17 00:00:00 2001 From: Brian Woods Date: Thu, 28 Jan 2021 19:28:15 -0800 Subject: Add/fix support for SCSI/SD aliases for load cmds With the -t option, the "sd" was an alias for the "load scsi 0:1" load command. Change that to a "load mmc 0:1" alias and then add a "scsi" alias which is "load scsi 0:1". To make sure these aliases and manually setting the load command works, a parsing the command and setting the correct partition and devs was also added. Signed-off-by: Brian Woods Signed-off-by: Stefano Stabellini Reviewed-by: Stefano Stabellini --- scripts/uboot-script-gen | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'scripts') 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 -- cgit v1.2.3