Skip to content
Snippets Groups Projects
Unverified Commit a0b97ad7 authored by Gaëtan Harter's avatar Gaëtan Harter
Browse files

openocd: get flash and debug files from cli

Get FLASH_FILE and ELFFILE from command line instead of environment variable.

The documentation was claiming ELFFILE was given as a command line argument
already, but is was not.
parent 6551d8aa
No related branches found
No related tags found
No related merge requests found
...@@ -11,7 +11,7 @@ include $(RIOTMAKE)/tools/serial.inc.mk ...@@ -11,7 +11,7 @@ include $(RIOTMAKE)/tools/serial.inc.mk
DEBUG_ADAPTER ?= dap DEBUG_ADAPTER ?= dap
# this board uses openocd # this board uses openocd
export IMAGE_FILE = $(HEXFILE) FFLAGS ?= flash $(HEXFILE)
include $(RIOTMAKE)/tools/openocd.inc.mk include $(RIOTMAKE)/tools/openocd.inc.mk
# generate image checksum from hex file # generate image checksum from hex file
......
...@@ -17,30 +17,33 @@ ...@@ -17,30 +17,33 @@
# #
# 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).
# #
# 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 <elfile>
# starts OpenOCD as GDB server in the background and
# connects to the server with the GDB client specified by # connects to the server with the GDB client specified by
# the board # the board
# #
# options: # options:
# <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)
# GDB_PORT: port opened for GDB connections # GDB_PORT: port opened for GDB connections
# TCL_PORT: port opened for TCL connections # TCL_PORT: port opened for TCL connections
# TELNET_PORT: port opened for telnet connections # TELNET_PORT: port opened for telnet connections
# DBG: debugger client command, default: 'gdb -q' # DBG: debugger client command, default: 'gdb -q'
# TUI: if TUI!=null, the -tui option will be used # 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 # debug-server: starts OpenOCD as GDB server, but does not connect to
# to it with any frontend. This might be useful when using # to it with any frontend. This might be useful when using
...@@ -93,10 +96,6 @@ ...@@ -93,10 +96,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)
...@@ -210,6 +209,7 @@ _flash_address() { ...@@ -210,6 +209,7 @@ _flash_address() {
# 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
...@@ -256,6 +256,7 @@ do_flash() { ...@@ -256,6 +256,7 @@ do_flash() {
} }
do_debug() { do_debug() {
ELFFILE=$1
test_config test_config
test_elffile test_elffile
# temporary file that saves OpenOCD pid # temporary file that saves OpenOCD pid
...@@ -330,15 +331,16 @@ do_reset() { ...@@ -330,15 +331,16 @@ do_reset() {
# 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 "$@"
;; ;;
debug) debug)
echo "### Starting Debugging ###" echo "### Starting Debugging ###"
do_debug do_debug "$@"
;; ;;
debug-server) debug-server)
echo "### Starting GDB Server ###" echo "### Starting GDB Server ###"
...@@ -350,6 +352,8 @@ case "${ACTION}" in ...@@ -350,6 +352,8 @@ case "${ACTION}" in
;; ;;
*) *)
echo "Usage: $0 {flash|debug|debug-server|reset}" echo "Usage: $0 {flash|debug|debug-server|reset}"
echo " flash <flashfile>"
echo " debug <elffile>"
exit 2 exit 2
;; ;;
esac esac
...@@ -3,8 +3,8 @@ export DEBUGGER = $(RIOTTOOLS)/openocd/openocd.sh ...@@ -3,8 +3,8 @@ export DEBUGGER = $(RIOTTOOLS)/openocd/openocd.sh
export DEBUGSERVER = $(RIOTTOOLS)/openocd/openocd.sh export DEBUGSERVER = $(RIOTTOOLS)/openocd/openocd.sh
export RESET ?= $(RIOTTOOLS)/openocd/openocd.sh export RESET ?= $(RIOTTOOLS)/openocd/openocd.sh
export FFLAGS ?= flash export FFLAGS ?= flash $(ELFFILE)
export DEBUGGER_FLAGS ?= debug export DEBUGGER_FLAGS ?= debug $(ELFFILE)
export DEBUGSERVER_FLAGS ?= debug-server export DEBUGSERVER_FLAGS ?= debug-server
export RESET_FLAGS ?= reset export RESET_FLAGS ?= reset
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment