From 0c586722a542f3a303bdfba9d9e9eaf16d7ac86a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Mon, 26 Mar 2018 18:26:38 +0200 Subject: [PATCH 1/5] calliope-mini/flash: get HEXFILE from cli --- boards/calliope-mini/Makefile.include | 2 +- boards/calliope-mini/dist/flash.sh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/boards/calliope-mini/Makefile.include b/boards/calliope-mini/Makefile.include index 6f969e2c20a8..fa17c4159139 100644 --- a/boards/calliope-mini/Makefile.include +++ b/boards/calliope-mini/Makefile.include @@ -10,7 +10,7 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) PROGRAMMER ?= fscopy ifeq (fscopy,$(PROGRAMMER)) - export FFLAGS = + export FFLAGS = $(HEXFILE) export DEBUGGER_FLAGS = export FLASHER = $(RIOTBOARD)/$(BOARD)/dist/flash.sh diff --git a/boards/calliope-mini/dist/flash.sh b/boards/calliope-mini/dist/flash.sh index 9b4630f96652..fa8ce4f26cf1 100755 --- a/boards/calliope-mini/dist/flash.sh +++ b/boards/calliope-mini/dist/flash.sh @@ -18,6 +18,8 @@ OS=`uname` DID_MOUNT=false NAME="MINI" +HEXFILE=$1 + # set the mount path depending on the OS if [ ${OS} = "Linux" ] then From 57245d58289d89be2f7294db51be7ff60cad684f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Mon, 26 Mar 2018 18:29:25 +0200 Subject: [PATCH 2/5] mbed_lpc1768/flash: get BINFILE from cli --- boards/mbed_lpc1768/Makefile.include | 2 +- boards/mbed_lpc1768/dist/flash.sh | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/boards/mbed_lpc1768/Makefile.include b/boards/mbed_lpc1768/Makefile.include index 3adfc67b2192..e5511e48d720 100644 --- a/boards/mbed_lpc1768/Makefile.include +++ b/boards/mbed_lpc1768/Makefile.include @@ -6,7 +6,7 @@ export DEBUGGER = export DEBUGSERVER = HEXFILE = $(BINFILE) -export FFLAGS = +export FFLAGS = $(HEXFILE) export DEBUGGER_FLAGS = # define the default port depending on the host OS diff --git a/boards/mbed_lpc1768/dist/flash.sh b/boards/mbed_lpc1768/dist/flash.sh index 1eaeebec93d4..4ff2af9845a2 100755 --- a/boards/mbed_lpc1768/dist/flash.sh +++ b/boards/mbed_lpc1768/dist/flash.sh @@ -21,6 +21,8 @@ OS=`uname` DID_MOUNT=false +BINFILE=$1 + # set the mount path depending on the OS if [ ${OS} = "Linux" ] then @@ -55,7 +57,7 @@ fi # remove old binary rm -f ${MOUNT}/*.bin # copy new binary to device -cp ${HEXFILE} ${MOUNT} +cp ${BINFILE} ${MOUNT} # make sure hexfile was written sync From 64132ef817a72e13e54cf7a46d6b98b087cb4615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Mon, 26 Mar 2018 18:32:05 +0200 Subject: [PATCH 3/5] microbit/flash: get BINFILE from cli --- boards/microbit/Makefile.include | 2 +- boards/microbit/dist/flash.sh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/boards/microbit/Makefile.include b/boards/microbit/Makefile.include index 8eb617dd3b7d..e5907b533681 100644 --- a/boards/microbit/Makefile.include +++ b/boards/microbit/Makefile.include @@ -10,7 +10,7 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*))) PROGRAMMER ?= fscopy ifeq (fscopy,$(PROGRAMMER)) - export FFLAGS = + export FFLAGS = $(HEXFILE) export DEBUGGER_FLAGS = export FLASHER = $(RIOTBOARD)/$(BOARD)/dist/flash.sh diff --git a/boards/microbit/dist/flash.sh b/boards/microbit/dist/flash.sh index ceeeb0f00eb4..657307e5fb0b 100755 --- a/boards/microbit/dist/flash.sh +++ b/boards/microbit/dist/flash.sh @@ -18,6 +18,8 @@ OS=`uname` DID_MOUNT=false NAME="MICROBIT" +HEXFILE=$1 + # set the mount path depending on the OS if [ ${OS} = "Linux" ] then From bfa7a4747f9e5731dc6dff5ee86a7b7ad5b21ad5 Mon Sep 17 00:00:00 2001 From: cladmi Date: Thu, 11 Oct 2018 17:43:53 +0200 Subject: [PATCH 4/5] jlink: get flash and debug files from cli Get HEXFILE and ELFFILE from command line instead of environment variable. --- dist/tools/jlink/jlink.sh | 30 ++++++++++++++++++------------ makefiles/tools/jlink.inc.mk | 4 ++-- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/dist/tools/jlink/jlink.sh b/dist/tools/jlink/jlink.sh index 382c8986844b..047e95bbd76a 100755 --- a/dist/tools/jlink/jlink.sh +++ b/dist/tools/jlink/jlink.sh @@ -18,23 +18,25 @@ # # The script supports the following actions: # -# flash: flash a given hex file to the target. -# hexfile is expected in ihex format and is pointed to -# by BINFILE environment variable +# flash: flash +# +# flash given binary format file to the target. # # options: -# BINFILE: path to the binary file that is flashed +# : path to the binary file that is flashed +# +# debug: debug # -# debug: starts JLink as GDB server in the background and +# starts JLink as GDB server in the background and # connects to the server with the GDB client specified by # the board (DBG environment variable) # # options: +# : path to the ELF file to debug # GDB_PORT: port opened for GDB connections # TELNET_PORT: port opened for telnet connections # DBG: debugger client command, default: 'gdb -q' # TUI: if TUI!=null, the -tui option will be used -# ELFFILE: path to the ELF file to debug # # debug-server: starts JLink as GDB server, but does not connect to # to it with any frontend. This might be useful when using @@ -88,10 +90,10 @@ test_config() { fi } -test_hexfile() { - if [ ! -f "${HEXFILE}" ]; then - echo "Error: Unable to locate HEXFILE" - echo " (${HEXFILE})" +test_binfile() { + if [ ! -f "${BINFILE}" ]; then + echo "Error: Unable to locate BINFILE" + echo " (${BINFILE})" exit 1 fi } @@ -145,16 +147,17 @@ test_term() { # now comes the actual actions # do_flash() { + BINFILE=$1 test_config test_serial - test_hexfile + test_binfile # clear any existing contents in burn file /bin/echo -n "" > ${BINDIR}/burn.seg # create temporary burn file if [ ! -z "${JLINK_PRE_FLASH}" ]; then printf "${JLINK_PRE_FLASH}\n" >> ${BINDIR}/burn.seg fi - echo "loadbin ${HEXFILE} ${FLASH_ADDR}" >> ${BINDIR}/burn.seg + echo "loadbin ${BINFILE} ${FLASH_ADDR}" >> ${BINDIR}/burn.seg if [ ! -z "${JLINK_POST_FLASH}" ]; then printf "${JLINK_POST_FLASH}\n" >> ${BINDIR}/burn.seg fi @@ -169,6 +172,7 @@ do_flash() { } do_debug() { + ELFFILE=$1 test_config test_serial test_elffile @@ -275,5 +279,7 @@ case "${ACTION}" in ;; *) echo "Usage: $0 {flash|debug|debug-server|reset}" + echo " flash " + echo " debug " ;; esac diff --git a/makefiles/tools/jlink.inc.mk b/makefiles/tools/jlink.inc.mk index a53eb7cb9785..af9741807cdd 100644 --- a/makefiles/tools/jlink.inc.mk +++ b/makefiles/tools/jlink.inc.mk @@ -5,7 +5,7 @@ export RESET = $(RIOTTOOLS)/jlink/jlink.sh HEXFILE = $(BINFILE) -export FFLAGS ?= flash -export DEBUGGER_FLAGS ?= debug +export FFLAGS ?= flash $(HEXFILE) +export DEBUGGER_FLAGS ?= debug $(ELFFILE) export DEBUGSERVER_FLAGS ?= debug-server export RESET_FLAGS ?= reset From dbca7e1dd9d1bd246f4f64a84b6e48cd166769a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Mon, 26 Mar 2018 20:08:49 +0200 Subject: [PATCH 5/5] openocd: get flash and debug files from cli Get FLASH_FILE and ELFFILE from command line instead of environment variable. --- boards/seeeduino_arch-pro/Makefile.include | 2 +- dist/tools/openocd/openocd.sh | 36 ++++++++++++---------- makefiles/tools/openocd.inc.mk | 4 +-- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/boards/seeeduino_arch-pro/Makefile.include b/boards/seeeduino_arch-pro/Makefile.include index 4d78e552fdb0..aa957e7bcd13 100644 --- a/boards/seeeduino_arch-pro/Makefile.include +++ b/boards/seeeduino_arch-pro/Makefile.include @@ -11,7 +11,7 @@ include $(RIOTMAKE)/tools/serial.inc.mk DEBUG_ADAPTER ?= dap # this board uses openocd -export IMAGE_FILE = $(HEXFILE) +FFLAGS ?= flash $(HEXFILE) include $(RIOTMAKE)/tools/openocd.inc.mk # generate image checksum from hex file diff --git a/dist/tools/openocd/openocd.sh b/dist/tools/openocd/openocd.sh index 4973f8fb4563..e46db18c8148 100755 --- a/dist/tools/openocd/openocd.sh +++ b/dist/tools/openocd/openocd.sh @@ -17,30 +17,33 @@ # # The script supports the following actions: # -# flash: flash a given ELF file to the target. +# flash: flash +# flash given file to the target. # # options: -# IMAGE_FILE: Filename of the file that will be flashed +# : 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. 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). # -# debug: starts OpenOCD as GDB server in the background and +# Flashing works with any file format recognized by OpenOCD +# (elf, ihex, s19, bin). +# +# debug: debug +# starts OpenOCD as GDB server in the background and # connects to the server with the GDB client specified by # the board # # options: +# : path to the file to debug, must be in a format +# recognized by GDB (preferably ELF, it will not +# work with .bin, .hex or .s19 because they lack +# symbol information) # GDB_PORT: port opened for GDB connections # TCL_PORT: port opened for TCL connections # TELNET_PORT: port opened for telnet connections # DBG: debugger client command, default: 'gdb -q' # TUI: if TUI!=null, the -tui option will be used -# ELFFILE: path to the file to debug, must be in a format -# recognized by GDB (preferably ELF, it will not -# work with .bin, .hex or .s19 because they lack -# symbol information) # # debug-server: starts OpenOCD as GDB server, but does not connect to # to it with any frontend. This might be useful when using @@ -93,10 +96,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) @@ -210,6 +209,7 @@ _flash_address() { # now comes the actual actions # do_flash() { + IMAGE_FILE=$1 test_config test_imagefile if [ -n "${PRE_FLASH_CHECK_SCRIPT}" ]; then @@ -256,6 +256,7 @@ do_flash() { } do_debug() { + ELFFILE=$1 test_config test_elffile # temporary file that saves OpenOCD pid @@ -330,15 +331,16 @@ do_reset() { # parameter dispatching # ACTION="$1" +shift # pop $1 from $@ case "${ACTION}" in flash) echo "### Flashing Target ###" - do_flash + do_flash "$@" ;; debug) echo "### Starting Debugging ###" - do_debug + do_debug "$@" ;; debug-server) echo "### Starting GDB Server ###" @@ -350,6 +352,8 @@ case "${ACTION}" in ;; *) echo "Usage: $0 {flash|debug|debug-server|reset}" + echo " flash " + echo " debug " exit 2 ;; esac diff --git a/makefiles/tools/openocd.inc.mk b/makefiles/tools/openocd.inc.mk index 79d2e5390e50..a307d93f4697 100644 --- a/makefiles/tools/openocd.inc.mk +++ b/makefiles/tools/openocd.inc.mk @@ -3,8 +3,8 @@ export DEBUGGER = $(RIOTTOOLS)/openocd/openocd.sh export DEBUGSERVER = $(RIOTTOOLS)/openocd/openocd.sh export RESET ?= $(RIOTTOOLS)/openocd/openocd.sh -export FFLAGS ?= flash -export DEBUGGER_FLAGS ?= debug +export FFLAGS ?= flash $(ELFFILE) +export DEBUGGER_FLAGS ?= debug $(ELFFILE) export DEBUGSERVER_FLAGS ?= debug-server export RESET_FLAGS ?= reset