From cb376bb3ad07ab88a0c02d6a241e5847510ce1be Mon Sep 17 00:00:00 2001 From: Brian Woods Date: Thu, 2 Sep 2021 16:52:17 -0700 Subject: Add support for setting LOAD_CMD in the config Reducing what's needed in the CLI arguments to a minimum to streamline usage. The current behavior does not change and setting it on the CLI arguments will overwrite what's in the config file. Signed-off-by: Brian Woods Reviewed-by: Stefano Stabellini Signed-off-by: Stefano Stabellini --- README.md | 6 ++++++ scripts/uboot-script-gen | 26 ++++++++++++++++++-------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index f8f8022..bf6e374 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ To use it, first write a config file like `config`: MEMORY_START="0x0" MEMORY_END="0x80000000" EFI=y +LOAD_CMD="tftpb" DEVICE_TREE="mpsoc.dtb" XEN="xen" @@ -62,6 +63,11 @@ FIT="boot.fit" Where: - MEMORY_START and MEMORY_END specify the start and end of RAM. +- LOAD_CMD specifies the u-boot command used to load the binaries. This + can be left out of the config and be (over)written by the -t CLI + argument. It has to be set either in the config file or CLI argument + though. + - EFI specifies if the bootefi boot command should be used over booti. If set to anything other than "n", "no", or "false" it will enable bootefi. diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen index a911238..e3f2753 100755 --- a/scripts/uboot-script-gen +++ b/scripts/uboot-script-gen @@ -272,16 +272,16 @@ function print_help { script=`basename "$0"` echo "usage:" - echo " $script -c CONFIG_FILE -t UBOOT_TYPE -d DIRECTORY [-o FILE] [-k KEY_DIR/HINT [-u U-BOOT_DTB]] [-e]" + echo " $script -c CONFIG_FILE -d DIRECTORY [-t LOAD_CMD] [-o FILE] [-k KEY_DIR/HINT [-u U-BOOT_DTB]] [-e]" echo " $script -h" echo "where:" echo " CONFIG_FILE - configuration file" - echo " UBOOT_TYPE can be:" + echo " DIRECTORY - root directory where the files of CONFIG_FILE are located" + echo " LOAD_CMD can be:" echo " sd - alias for \"load mmc 0:1\" for uboot load commands" echo " scsi - alias for \"load scsi 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" echo " FILE - output filename for the uboot script and its source, overrides option in CONFIG_FILE" echo " KEY_DIR - key directory used for signing a fit image" echo " HINT - the file name of the crt and key file minus the suffix (ex, hint.crt and hint.key)" @@ -300,16 +300,16 @@ while getopts ":c:t:d:ho:k:u:ef" opt; do t ) case $OPTARG in scsi ) - LOAD_CMD="load scsi 0:1" + load_opt="load scsi 0:1" ;; sd ) - LOAD_CMD="load mmc 0:1" + load_opt="load mmc 0:1" ;; tftp ) - LOAD_CMD="tftpb" + load_opt="tftpb" ;; * ) - LOAD_CMD="$OPTARG" + load_opt="$OPTARG" ;; esac ;; @@ -346,7 +346,7 @@ while getopts ":c:t:d:ho:k:u:ef" opt; do done shift $((OPTIND -1)) -if [ -z "$LOAD_CMD" ] || [ -z "$cfg_file" ] || [ -z "$uboot_dir" ] +if test ! "$cfg_file" -o ! "$uboot_dir" then echo "Undefined arguments, see \"$0 -h\"" exit 1 @@ -356,6 +356,16 @@ check_depends source "$cfg_file" +if test "$load_opt" +then + LOAD_CMD="$load_opt" +fi +if test ! "$LOAD_CMD" +then + echo "LOAD_CMD not set, either specify it in the config or set it with the -t option" + exit 1 +fi + # CLI ARG overrides what's in the config file if [ ! -z "$UBOOT_SCRIPT_ARG" ] then -- cgit v1.2.3