1717#
1818# The script supports the following actions:
1919#
20- # flash: flash a given ELF file to the target.
20+ # flash: flash <image_file>
21+ # flash given file to the target.
2122#
2223# options:
23- # IMAGE_FILE: Filename of the file that will be flashed
24+ # <image_file>: Filename of the file that will be flashed
2425# PRE_FLASH_CHECK_SCRIPT: a command to run before flashing to
25- # verify the integrity of the image to be flashed. ELFFILE is
26+ # verify the integrity of the image to be flashed. <image_file> is
2627# passed as a command line argument to this command.
27- # Even though the file name variable is named ELFFILE, flashing
28- # works with any file format recognized by OpenOCD (elf, ihex, s19, bin).
2928#
30- # debug: starts OpenOCD as GDB server in the background and
29+ # Flashing works with any file format recognized by OpenOCD
30+ # (elf, ihex, s19, bin).
31+ #
32+ # debug: debug <elfile>
33+ # starts OpenOCD as GDB server in the background and
3134# connects to the server with the GDB client specified by
3235# the board
3336#
3437# options:
38+ # <elffile>: path to the file to debug, must be in a format
39+ # recognized by GDB (preferably ELF, it will not
40+ # work with .bin, .hex or .s19 because they lack
41+ # symbol information)
3542# GDB_PORT: port opened for GDB connections
3643# TCL_PORT: port opened for TCL connections
3744# TELNET_PORT: port opened for telnet connections
3845# DBG: debugger client command, default: 'gdb -q'
3946# TUI: if TUI!=null, the -tui option will be used
40- # ELFFILE: path to the file to debug, must be in a format
41- # recognized by GDB (preferably ELF, it will not
42- # work with .bin, .hex or .s19 because they lack
43- # symbol information)
4447#
4548# debug-server: starts OpenOCD as GDB server, but does not connect to
4649# to it with any frontend. This might be useful when using
9396# Default offset is 0, meaning the image will be flashed at the address that it
9497# was linked at.
9598: ${IMAGE_OFFSET:= 0}
96- # Image file used for flashing. Must be in a format that OpenOCD can handle (ELF,
97- # Intel hex, S19, or raw binary)
98- # Default is to use $ELFFILE
99- : ${IMAGE_FILE:= ${ELFFILE} }
10099# Type of image, leave empty to let OpenOCD automatically detect the type from
101100# the file (default).
102101# Valid values: elf, hex, s19, bin (see OpenOCD manual for more information)
@@ -210,6 +209,7 @@ _flash_address() {
210209# now comes the actual actions
211210#
212211do_flash () {
212+ IMAGE_FILE=$1
213213 test_config
214214 test_imagefile
215215 if [ -n " ${PRE_FLASH_CHECK_SCRIPT} " ]; then
@@ -256,6 +256,7 @@ do_flash() {
256256}
257257
258258do_debug () {
259+ ELFFILE=$1
259260 test_config
260261 test_elffile
261262 # temporary file that saves OpenOCD pid
@@ -330,15 +331,16 @@ do_reset() {
330331# parameter dispatching
331332#
332333ACTION=" $1 "
334+ shift # pop $1 from $@
333335
334336case " ${ACTION} " in
335337 flash)
336338 echo " ### Flashing Target ###"
337- do_flash
339+ do_flash " $@ "
338340 ;;
339341 debug)
340342 echo " ### Starting Debugging ###"
341- do_debug
343+ do_debug " $@ "
342344 ;;
343345 debug-server)
344346 echo " ### Starting GDB Server ###"
@@ -350,6 +352,8 @@ case "${ACTION}" in
350352 ;;
351353 * )
352354 echo " Usage: $0 {flash|debug|debug-server|reset}"
355+ echo " flash <flash_file>"
356+ echo " debug <elffile>"
353357 exit 2
354358 ;;
355359esac
0 commit comments