aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorBrian Woods2019-10-22 18:38:57 -0700
committerStefano Stabellini2019-10-23 10:28:11 -0700
commit06d92ee94ba7fa805b83491f7e408ad5b1b46ad4 (patch)
treee628fb79d143679156dc7f3dcaad76c13f332eea /scripts
parent4eb6ba90286ae298c536fcee95832c592be3661c (diff)
Add command line arguments for uboot-script-gen
Add some simple command line arguments and some dependency checking that makes running this outside of a container much easier. The environment variable LOAD_CMD has been removed and all the config options are done via command line arguemtnt for consistency. Signed-off-by: Brian Woods <brian.woods@xilinx.com> Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/imagebuilder_sd3
-rw-r--r--scripts/imagebuilder_tftp3
-rw-r--r--scripts/uboot-script-gen78
3 files changed, 77 insertions, 7 deletions
diff --git a/scripts/imagebuilder_sd b/scripts/imagebuilder_sd
index fc00716..460746e 100644
--- a/scripts/imagebuilder_sd
+++ b/scripts/imagebuilder_sd
@@ -5,6 +5,5 @@ mkdir /tmp/output
cp config /tmp/output
cp -r /home/builder/output/* /tmp/output
cd /tmp/output
-export LOAD_CMD="load scsi 0:1"
-bash /uboot-script-gen ./config
+bash /uboot-script-gen -c ./config -d ./ -t sd
bash /disk_image
diff --git a/scripts/imagebuilder_tftp b/scripts/imagebuilder_tftp
index 1dd2e3f..70b5379 100644
--- a/scripts/imagebuilder_tftp
+++ b/scripts/imagebuilder_tftp
@@ -5,5 +5,4 @@ mkdir /tmp/output
cp config /tmp/output
cp -r /home/builder/output/* /tmp/output
cd /tmp/output
-export LOAD_CMD="tftpb"
-bash /uboot-script-gen ./config
+bash /uboot-script-gen -c ./config -d ./ -t tftp
diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen
index 5b60737..a7d1a2f 100644
--- a/scripts/uboot-script-gen
+++ b/scripts/uboot-script-gen
@@ -2,6 +2,7 @@
offset=$((2*1024*1024))
filesize=0
+prog_req=(mkimage file)
function add_device_tree_kernel()
{
@@ -130,12 +131,83 @@ function check_compressed_file_type()
check_file_type $filename "$type"
}
-if test $# -lt 1
+function check_depends()
+{
+ for ((i=0; i<${#prog_req[@]}; i++))
+ do
+ if ! command -v ${prog_req[i]} > /dev/null
+ then
+ echo "Please install the needed program: ${prog_req[i]}."
+ exit 1
+ fi
+ done
+}
+
+function print_help
+{
+ echo "usage:"
+ echo " $0 -c CONFIG_FILE -t UBOOT_TYPE -d DIRECTORY"
+ echo " $0 -h"
+ 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 " tftp - alias for \"tftpb\" for uboot load cammnds"
+ echo " < > - used for uboot load commands"
+ echo " DIRECTORY - root directory of where the files of CONFIG_FILE"
+ echo " -h - prints out the help message and exits "
+ echo "Defaults:"
+ echo " CONFIG_FILE=$cfg_file, UBOOT_TYPE=\"LOAD_CMD\" env var, DIRECTORY=$uboot_dir"
+ echo "Example:"
+ echo " $0 -c ../config -d ./build42 -t \"scsi load 1:1\""
+}
+
+while getopts ":c:t:d:h" opt; do
+ case ${opt} in
+ t )
+ case $OPTARG in
+ sd )
+ LOAD_CMD="load scsi 0:1"
+ ;;
+ tftp )
+ LOAD_CMD="tftpb"
+ ;;
+ * )
+ LOAD_CMD="$OPTARG"
+ ;;
+ esac
+ ;;
+ c )
+ cfg_file=$OPTARG
+ ;;
+ d )
+ uboot_dir=$OPTARG
+ ;;
+ h )
+ print_help
+ exit 0
+ ;;
+ * )
+ echo "Unknown option, see \"$0 -h\""
+ exit 1
+ ;;
+ esac
+done
+shift $((OPTIND -1))
+
+if [ -z "$LOAD_CMD" ] || [ -z "$cfg_file" ] || [ -z "$uboot_dir" ]
then
- echo "Usage $0 <config_file>"
+ echo "Undefined arguments, see \"$0 -h\""
exit 1
fi
-source $1
+
+check_depends
+
+source "$cfg_file"
+
+# the cd is needed so that the relative paths will match once we use
+# tftp or move the files to a partition
+cd "$uboot_dir"
rm -f $UBOOT_SOURCE $UBOOT_SCRIPT
memaddr=$(( $MEMORY_START + $offset ))