Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion boards/calliope-mini/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions boards/calliope-mini/dist/flash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion boards/mbed_lpc1768/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion boards/mbed_lpc1768/dist/flash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
OS=`uname`
DID_MOUNT=false

BINFILE=$1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the calliope you specified HEXFILE=$1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I based myself on what file is actually used by the board:

make --no-print-directory -C examples/hello-world/ info-debug-variable-HEXFILE  BOARD=calliope-mini
.../examples/hello-world/bin/calliope-mini/hello-world.hex
make --no-print-directory -C examples/hello-world/ info-debug-variable-HEXFILE  BOARD=mbed_lpc1768
.../examples/hello-world/bin/mbed_lpc1768/hello-world.bin

The mbed board uses BINFILE as file to generate called HEXFILE currently

HEXFILE = $(BINFILE)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah so you want to match the variable name in the script with the actual file ending, right? So BINFILE where it is <appname>.bin and HEXFILE for <appname>.hex. Makes sense, was just confusing to use different variable names inside all those flash scripts.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to be coherent with the filename/extension yes.


# set the mount path depending on the OS
if [ ${OS} = "Linux" ]
then
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion boards/microbit/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions boards/microbit/dist/flash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion boards/seeeduino_arch-pro/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 18 additions & 12 deletions dist/tools/jlink/jlink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <binfile>
#
# flash given binary format file to the target.
#
# options:
# BINFILE: path to the binary file that is flashed
# <binfile>: path to the binary file that is flashed
#
# debug: debug <elffile>
#
# 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:
# <elffile>: 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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand All @@ -169,6 +172,7 @@ do_flash() {
}

do_debug() {
ELFFILE=$1
test_config
test_serial
test_elffile
Expand Down Expand Up @@ -275,5 +279,7 @@ case "${ACTION}" in
;;
*)
echo "Usage: $0 {flash|debug|debug-server|reset}"
echo " flash <flash_file>"
echo " debug <elffile>"
;;
esac
36 changes: 20 additions & 16 deletions dist/tools/openocd/openocd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,33 @@
#
# 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).
#
# 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
# the board
#
# 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
# 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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -256,6 +256,7 @@ do_flash() {
}

do_debug() {
ELFFILE=$1
test_config
test_elffile
# temporary file that saves OpenOCD pid
Expand Down Expand Up @@ -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 ###"
Expand All @@ -350,6 +352,8 @@ case "${ACTION}" in
;;
*)
echo "Usage: $0 {flash|debug|debug-server|reset}"
echo " flash <flash_file>"
echo " debug <elffile>"
exit 2
;;
esac
4 changes: 2 additions & 2 deletions makefiles/tools/jlink.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions makefiles/tools/openocd.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down