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`.
This commit is contained in:
Gaëtan Harter 2018-03-26 20:08:49 +02:00
parent a0b97ad737
commit 0b664453dc
No known key found for this signature in database
GPG Key ID: 76DF6BCF1B1F883B

View File

@ -19,15 +19,18 @@
# #
# The script supports the following actions: # 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: # 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 # 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. # 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 Hauke Peteresen <hauke.petersen@fu-berlin.de>
# @author Joakim Nohlgård <joakim.nohlgard@eistec.se> # @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 # Default offset is 0, meaning the image will be flashed at the address that it
# was linked at. # was linked at.
: ${IMAGE_OFFSET:=0} : ${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 # Type of image, leave empty to let OpenOCD automatically detect the type from
# the file (default). # the file (default).
# Valid values: elf, hex, s19, bin (see OpenOCD manual for more information) # Valid values: elf, hex, s19, bin (see OpenOCD manual for more information)
@ -84,6 +83,7 @@ test_imagefile() {
# now comes the actual actions # now comes the actual actions
# #
do_flash() { do_flash() {
IMAGE_FILE=$1
test_config test_config
test_imagefile test_imagefile
if [ -n "${PRE_FLASH_CHECK_SCRIPT}" ]; then if [ -n "${PRE_FLASH_CHECK_SCRIPT}" ]; then
@ -119,14 +119,15 @@ do_flash() {
# parameter dispatching # parameter dispatching
# #
ACTION="$1" ACTION="$1"
shift # pop $1 from $@
case "${ACTION}" in case "${ACTION}" in
flash) flash)
echo "### Flashing Target ###" echo "### Flashing Target ###"
do_flash do_flash "$@"
;; ;;
*) *)
echo "Usage: $0 flash" echo "Usage: $0 flash <flashfile>"
exit 2 exit 2
;; ;;
esac esac