From 0b664453dc19dea31b8045884e46cbf02a8c2704 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= <gaetan.harter@fu-berlin.de>
Date: Mon, 26 Mar 2018 20:08:49 +0200
Subject: [PATCH] hifive1/flasher.sh: get flash file from cli

Get FLASH_FILE from command line instead of environment variable.

The documentation was claiming ELFFILE was given as a command line argument
already, but is was not.

This is the same change as with `openocd.sh`.
---
 boards/hifive1/dist/flasher.sh | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/boards/hifive1/dist/flasher.sh b/boards/hifive1/dist/flasher.sh
index df2b36eee5..1f73cea801 100644
--- a/boards/hifive1/dist/flasher.sh
+++ b/boards/hifive1/dist/flasher.sh
@@ -19,15 +19,18 @@
 #
 # The script supports the following actions:
 #
-# flash:        flash a given ELF file to the target.
+# flash:        flash <image_file>
+#               flash given file to the target.
 #
 #               options:
-#               IMAGE_FILE: Filename of the file that will be flashed
+#               <image_file>:   Filename of the file that will be flashed
 #               PRE_FLASH_CHECK_SCRIPT: a command to run before flashing to
-#               verify the integrity of the image to be flashed. ELFFILE is
+#               verify the integrity of the image to be flashed. <image_file> is
 #               passed as a command line argument to this command.
-#               Even though the file name variable is named ELFFILE, flashing
-#               works with any file format recognized by OpenOCD (elf, ihex, s19, bin).
+#
+#               Flashing works with any file format recognized by OpenOCD
+#               (elf, ihex, s19, bin).
+#
 #
 # @author       Hauke Peteresen <hauke.petersen@fu-berlin.de>
 # @author       Joakim Nohlgård <joakim.nohlgard@eistec.se>
@@ -42,10 +45,6 @@
 # Default offset is 0, meaning the image will be flashed at the address that it
 # was linked at.
 : ${IMAGE_OFFSET:=0}
-# Image file used for flashing. Must be in a format that OpenOCD can handle (ELF,
-# Intel hex, S19, or raw binary)
-# Default is to use $ELFFILE
-: ${IMAGE_FILE:=${ELFFILE}}
 # Type of image, leave empty to let OpenOCD automatically detect the type from
 # the file (default).
 # Valid values: elf, hex, s19, bin (see OpenOCD manual for more information)
@@ -84,6 +83,7 @@ test_imagefile() {
 # now comes the actual actions
 #
 do_flash() {
+    IMAGE_FILE=$1
     test_config
     test_imagefile
     if [ -n "${PRE_FLASH_CHECK_SCRIPT}" ]; then
@@ -119,14 +119,15 @@ do_flash() {
 # parameter dispatching
 #
 ACTION="$1"
+shift # pop $1 from $@
 
 case "${ACTION}" in
   flash)
     echo "### Flashing Target ###"
-    do_flash
+    do_flash "$@"
     ;;
   *)
-    echo "Usage: $0 flash"
+    echo "Usage: $0 flash <flashfile>"
     exit 2
     ;;
 esac
-- 
GitLab