1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #2408 from haukepetersen/opt_unified_openocd

dist: added a unified OpenOCD script
This commit is contained in:
Hauke Petersen 2015-02-10 17:30:23 +01:00
commit e3078269cd
64 changed files with 294 additions and 601 deletions

View File

@ -23,11 +23,12 @@ export AS = $(PREFIX)as
export LINK = $(PREFIX)gcc
export SIZE = $(PREFIX)size
export OBJCOPY = $(PREFIX)objcopy
export DBG = $(PREFIX)gdb
export TERMPROG = $(RIOTBASE)/dist/tools/pyterm/pyterm
export FLASHER = $(RIOTBOARD)/$(BOARD)/dist/flash.sh
export DEBUGGER = $(RIOTBOARD)/$(BOARD)/dist/debug.sh
export DEBUGSERVER = $(RIOTBOARD)/$(BOARD)/dist/debug-server.sh
export RESET = $(RIOTBOARD)/$(BOARD)/dist/reset.sh
export FLASHER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export DEBUGGER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export DEBUGSERVER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export RESET = $(RIOTBASE)/dist/tools/openocd/openocd.sh
# define build specific options
CPU_USAGE = -mcpu=cortex-m0
@ -38,11 +39,12 @@ export ASFLAGS += -ggdb -g3 $(CPU_USAGE) $(FPU_USAGE) -mlittle-endian
export LINKFLAGS += -g3 -ggdb -std=gnu99 $(CPU_USAGE) $(FPU_USAGE) -mlittle-endian -static -lgcc -mthumb -mno-thumb-interwork -nostartfiles
# $(LINKERSCRIPT) is specified in cpu/Makefile.include
export LINKFLAGS += -T$(LINKERSCRIPT)
export OFLAGS = -O binary
export HEXFILE = $(ELFFILE:.elf=.bin)
export OFLAGS = -O ihex
export TERMFLAGS += -p "$(PORT)"
export FFLAGS = $(HEXFILE)
export DEBUGGER_FLAGS = $(ELFFILE)
export FFLAGS = flash
export DEBUGGER_FLAGS = debug
export DEBUGSERVER_FLAGS = debug-server
export RESET_FLAGS = reset
# unwanted (CXXUWFLAGS) and extra (CXXEXFLAGS) flags for c++
export CXXUWFLAGS +=

View File

@ -1,17 +0,0 @@
#!/bin/sh
if [ -L "$0" ]; then
FILE=$(readlink "$0")
else
FILE="$0"
fi
BIN_FOLDER=$(dirname "${FILE}")
echo "##"
echo "## Starting debug server"
echo "##"
openocd -f "${BIN_FOLDER}/openocd.cfg" \
-c "init" \
-c "targets" \
-c "reset halt" \

View File

@ -1,19 +0,0 @@
#!/bin/sh
if [ ! -f "$1" ]; then
echo "ELF-file $1 does not exist"
exit 1
fi
if [ -L "$0" ]; then
FILE=$(readlink "$0")
else
FILE="$0"
fi
BIN_FOLDER=$(dirname "${FILE}")
echo "##"
echo "## Debugging $1"
echo "##"
arm-none-eabi-gdb -tui -command="${BIN_FOLDER}/gdb.cfg" $1

View File

@ -1,27 +0,0 @@
#!/bin/sh
if [ ! -f "$1" ]; then
echo "Binary file $1 does not exist"
exit 1
fi
if [ -L "$0" ]; then
FILE=$(readlink "$0")
else
FILE="$0"
fi
BIN_FOLDER=$(dirname "${FILE}")
echo "##"
echo "## Flashing $1"
echo "##"
openocd -f "${BIN_FOLDER}/openocd.cfg" \
-c "init" \
-c "targets" \
-c "halt" \
-c "flash banks" \
-c "flash write_image erase $1 0" \
-c "verify_image $1" \
-c "reset run"\
-c "shutdown"

View File

@ -1 +0,0 @@
target extended-remote 127.0.0.1:3333

View File

@ -1,10 +1,5 @@
# nRF51822 Target
source [find interface/stlink-v2.cfg]
transport select hla_swd
set WORKAREASIZE 0x4000
source [find target/nrf51.cfg]
# use hardware reset, connect under reset
#reset_config srst_only srst_nogate

View File

@ -1,17 +0,0 @@
#!/bin/sh
if [ -L "$0" ]; then
FILE=$(readlink "$0")
else
FILE="$0"
fi
BIN_FOLDER=$(dirname "${FILE}")
echo "##"
echo "## Resetting $BOARD"
echo "##"
openocd -f "${BIN_FOLDER}/openocd.cfg" \
-c "init" \
-c "reset run" \
-c "shutdown"

View File

@ -23,10 +23,12 @@ export AS = $(PREFIX)as
export LINK = $(PREFIX)gcc
export SIZE = $(PREFIX)size
export OBJCOPY = $(PREFIX)objcopy
export DBG = $(PREFIX)gdb
export TERMPROG = $(RIOTBASE)/dist/tools/pyterm/pyterm
export FLASHER = $(RIOTBOARD)/$(BOARD)/dist/flash.sh
export DEBUGGER = $(RIOTBOARD)/$(BOARD)/dist/debug.sh
export RESET = $(RIOTBOARD)/$(BOARD)/dist/reset.sh
export FLASHER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export DEBUGGER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export DEBUGSERVER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export RESET = $(RIOTBASE)/dist/tools/openocd/openocd.sh
# define build specific options
export CPU_USAGE = -mcpu=cortex-m3
@ -43,9 +45,11 @@ export LINKFLAGS += -ggdb -g3 -std=gnu99 $(CPU_USAGE) $(FPU_USAGE) -mlittle-endi
# $(LINKERSCRIPT) is specified in cpu/Makefile.include
export LINKFLAGS += -T$(LINKERSCRIPT)
export OFLAGS = -O ihex
export FFLAGS = $(HEXFILE)
export DEBUGGER_FLAGS = $(RIOTBOARD)/$(BOARD)/dist/gdb.conf $(ELFFILE)
export TERMFLAGS = -p $(PORT)
export TERMFLAGS += -p "$(PORT)"
export FFLAGS = flash
export DEBUGGER_FLAGS = debug
export DEBUGSERVER_FLAGS = debug-server
export RESET_FLAGS = reset
# use the nano-specs of the NewLib when available
ifeq ($(shell $(LINK) -specs=nano.specs -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)

View File

@ -1,20 +0,0 @@
#!/bin/bash
openocd -f "${RIOTBOARD}/${BOARD}/dist/${BOARD}_jtag.cfg" \
-f "target/stm32f1x.cfg" \
-c "tcl_port 6333" \
-c "telnet_port 4444" \
-c "init" \
-c "targets" \
-c "reset halt" \
-l /dev/null &
# save pid to terminate afterwards
OCD_PID=$?
# needed for openocd to set up
sleep 5
arm-none-eabi-gdb -tui --command=${1} ${2}
kill ${OCD_PID}

View File

@ -1,12 +0,0 @@
#!/bin/bash
openocd -f "${RIOTBOARD}/${BOARD}/dist/${BOARD}_jtag.cfg" \
-f "target/stm32f1x.cfg" \
-c "init" \
-c "targets" \
-c "reset halt" \
-c "reset init" \
-c "flash write_image erase $1" \
-c "verify_image $1" \
-c "reset run"\
-c "shutdown"

View File

@ -1,3 +0,0 @@
target remote localhost:3333
monitor reset halt
load

View File

@ -11,3 +11,5 @@ jtag_ntrst_delay 100
# use combined on interfaces or targets that can't set TRST/SRST separately
reset_config trst_and_srst
source [find target/stm32f1x.cfg]

View File

@ -1,7 +0,0 @@
#!/bin/bash
openocd -f "${RIOTBOARD}/${BOARD}/dist/${BOARD}_jtag.cfg" \
-f "target/stm32f1x.cfg" \
-c "init" \
-c "reset run" \
-c "shutdown"

View File

@ -23,10 +23,12 @@ export AS = $(PREFIX)as
export LINK = $(PREFIX)gcc
export SIZE = $(PREFIX)size
export OBJCOPY = $(PREFIX)objcopy
export DBG = $(PREFIX)gdb
export TERMPROG = $(RIOTBASE)/dist/tools/pyterm/pyterm
export FLASHER = $(RIOTBOARD)/$(BOARD)/dist/flash.sh
export DEBUGGER = $(RIOTBOARD)/$(BOARD)/dist/debug.sh
export RESET = $(RIOTBOARD)/$(BOARD)/dist/reset.sh
export FLASHER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export DEBUGGER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export DEBUGSERVER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export RESET = $(RIOTBASE)/dist/tools/openocd/openocd.sh
# define build specific options
export CPU_USAGE = -mcpu=cortex-m3
@ -43,9 +45,11 @@ export LINKFLAGS += -ggdb -g3 -std=gnu99 $(CPU_USAGE) $(FPU_USAGE) -mlittle-endi
# $(LINKERSCRIPT) is specified in cpu/Makefile.include
export LINKFLAGS += -T$(LINKERSCRIPT)
export OFLAGS = -O ihex
export FFLAGS = $(HEXFILE)
export DEBUGGER_FLAGS = $(RIOTBOARD)/$(BOARD)/dist/gdb.conf $(ELFFILE)
export TERMFLAGS = -p $(PORT) -b 500000
export FFLAGS = flash
export DEBUGGER_FLAGS = debug
export DEBUGSERVER_FLAGS = debug-server
export RESET_FLAGS = reset
# use the nano-specs of the NewLib when available
ifeq ($(shell $(LINK) -specs=nano.specs -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)

View File

@ -1,20 +0,0 @@
#!/bin/bash
openocd -f "${RIOTBOARD}/${BOARD}/dist/${BOARD}_jtag.cfg" \
-f "target/stm32f1x.cfg" \
-c "tcl_port 6333" \
-c "telnet_port 4444" \
-c "init" \
-c "targets" \
-c "reset halt" \
-l /dev/null &
# save pid to terminate afterwards
OCD_PID=$?
# needed for openocd to set up
sleep 5
arm-none-eabi-gdb -tui --command=${1} ${2}
kill ${OCD_PID}

View File

@ -1,12 +0,0 @@
#!/bin/bash
openocd -f "${RIOTBOARD}/${BOARD}/dist/${BOARD}_jtag.cfg" \
-f "target/stm32f1x.cfg" \
-c "init" \
-c "targets" \
-c "reset halt" \
-c "reset init" \
-c "flash write_image erase $1" \
-c "verify_image $1" \
-c "reset run"\
-c "shutdown"

View File

@ -1,3 +0,0 @@
target remote localhost:3333
monitor reset halt
load

View File

@ -4,3 +4,5 @@ ftdi_vid_pid 0x0403 0x6010
ftdi_layout_init 0x0c08 0x0c2b
ftdi_layout_signal nTRST -data 0x0800
ftdi_layout_signal nSRST -data 0x0400
source [find target/stm32f1x.cfg]

View File

@ -1,7 +0,0 @@
#!/bin/bash
openocd -f "${RIOTBOARD}/${BOARD}/dist/${BOARD}_jtag.cfg" \
-f "target/stm32f1x.cfg" \
-c "init" \
-c "reset run" \
-c "shutdown"

View File

@ -23,11 +23,12 @@ export AS = $(PREFIX)as
export LINK = $(PREFIX)gcc
export SIZE = $(PREFIX)size
export OBJCOPY = $(PREFIX)objcopy
export DBG = $(PREFIX)gdb
export TERMPROG = $(RIOTBASE)/dist/tools/pyterm/pyterm
export FLASHER = $(RIOTBOARD)/$(BOARD)/dist/flash.sh
export DEBUGGER = $(RIOTBOARD)/$(BOARD)/dist/debug.sh
export DEBUGSERVER = $(RIOTBOARD)/$(BOARD)/dist/debug-server.sh
export RESET = $(RIOTBOARD)/$(BOARD)/dist/reset.sh
export FLASHER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export DEBUGGER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export DEBUGSERVER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export RESET = $(RIOTBASE)/dist/tools/openocd/openocd.sh
# unwanted (CXXUWFLAGS) and extra (CXXEXFLAGS) flags for c++
export CXXUWFLAGS +=
@ -42,10 +43,12 @@ export ASFLAGS += -ggdb -g3 $(CPU_USAGE) $(FPU_USAGE) -mlittle-endian
export LINKFLAGS += -ggdb -g3 -std=gnu99 $(CPU_USAGE) $(FPU_USAGE) -mlittle-endian -static -lgcc -mthumb -mno-thumb-interwork -nostartfiles
# $(LINKERSCRIPT) is specified in cpu/Makefile.include
export LINKFLAGS += -T$(LINKERSCRIPT)
export OFLAGS = -O binary
export FFLAGS = $(HEXFILE)
export DEBUGGER_FLAGS = $(RIOTBOARD)/$(BOARD)/dist/gdb.conf $(ELFFILE)
export OFLAGS = -O ihex
export TERMFLAGS += -p "$(PORT)"
export FFLAGS = flash
export DEBUGGER_FLAGS = debug
export DEBUGSERVER_FLAGS = debug-server
export RESET_FLAGS = reset
# use the nano-specs of the NewLib when available
#ifeq ($(shell $(LINK) -specs=nano.specs -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)

View File

@ -1,10 +0,0 @@
#!/bin/sh
echo "##"
echo "## Starting debug server"
echo "##"
openocd -f board/st_nucleo_f334r8.cfg \
-c "init" \
-c "targets" \
-c "reset halt"

View File

@ -1,11 +0,0 @@
#!/bin/sh
if [ ! -f "$2" ]; then
echo "ELF-file $2 does not exist"
exit 1
fi
echo "##"
echo "## Debugging $2"
echo "##"
arm-none-eabi-gdb -tui -command="$1" $2

View File

@ -1,13 +0,0 @@
#!/bin/bash
echo "##"
echo "## Flashing $1"
echo "##"
openocd -f board/st_nucleo_f334r8.cfg \
-c "init" \
-c "targets" \
-c "reset halt" \
-c "program $1 0x8000000 verify" \
-c "reset run"\
-c "shutdown"

View File

@ -1 +0,0 @@
tar extended-remote :3333

1
boards/nucleo-f334/dist/openocd.cfg vendored Normal file
View File

@ -0,0 +1 @@
source [find board/st_nucleo_f334r8.cfg]

View File

@ -1,10 +0,0 @@
#!/bin/bash
echo "##"
echo "## Resetting $1"
echo "##"
openocd -f board/st_nucleo_f334r8.cfg \
-c "init" \
-c "reset run"\
-c "shutdown"

View File

@ -23,11 +23,12 @@ export AS = $(PREFIX)as
export LINK = $(PREFIX)gcc
export SIZE = $(PREFIX)size
export OBJCOPY = $(PREFIX)objcopy
export DBG = $(PREFIX)gdb
export TERMPROG = $(RIOTBASE)/dist/tools/pyterm/pyterm
export FLASHER = $(RIOTBOARD)/$(BOARD)/dist/flash.sh
export DEBUGGER = $(RIOTBOARD)/$(BOARD)/dist/debug.sh
export DEBUGSERVER = $(RIOTBOARD)/$(BOARD)/dist/debug-server.sh
export RESET = $(RIOTBOARD)/$(BOARD)/dist/reset.sh
export FLASHER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export DEBUGGER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export DEBUGSERVER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export RESET = $(RIOTBASE)/dist/tools/openocd/openocd.sh
# unwanted (CXXUWFLAGS) and extra (CXXEXFLAGS) flags for c++
export CXXUWFLAGS +=
@ -42,10 +43,12 @@ export ASFLAGS += -ggdb -g3 $(CPU_USAGE) $(FPU_USAGE) -mlittle-endian
export LINKFLAGS += -ggdb -g3 -std=gnu99 $(CPU_USAGE) $(FPU_USAGE) -mlittle-endian -static -lgcc -mthumb -mno-thumb-interwork -nostartfiles
# $(LINKERSCRIPT) is specified in cpu/Makefile.include
export LINKFLAGS += -T$(LINKERSCRIPT)
export OFLAGS = -O binary
export FFLAGS = $(HEXFILE)
export DEBUGGER_FLAGS = $(RIOTBOARD)/$(BOARD)/dist/gdb.conf $(ELFFILE)
export OFLAGS = -O ihex
export TERMFLAGS += -p "$(PORT)"
export FFLAGS = flash
export DEBUGGER_FLAGS = debug
export DEBUGSERVER_FLAGS = debug-server
export RESET_FLAGS = reset
# use the nano-specs of the NewLib when available
ifeq ($(shell $(LINK) -specs=nano.specs -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)

View File

@ -1,12 +0,0 @@
#!/bin/sh
echo "##"
echo "## Starting debug server"
echo "##"
# Needs OpenOCD version 0.9.0 built after Jan. 26th 2015
openocd -f "board/st_nucleo_l1.cfg" \
-c "init" \
-c "targets" \
-c "reset halt"

View File

@ -1,11 +0,0 @@
#!/bin/sh
if [ ! -f "$2" ]; then
echo "ELF-file $2 does not exist"
exit 1
fi
echo "##"
echo "## Debugging $2"
echo "##"
arm-none-eabi-gdb -tui -command="$1" $2

View File

@ -1,15 +0,0 @@
#!/bin/bash
echo "##"
echo "## Flashing $1"
echo "##"
# Needs OpenOCD version 0.9.0 built after Jan. 26th 2015
openocd -f "board/st_nucleo_l1.cfg" \
-c "init" \
-c "targets" \
-c "reset halt" \
-c "program $1 0x8000000 verify" \
-c "reset run"\
-c "shutdown"

View File

@ -1 +0,0 @@
tar extended-remote :3333

1
boards/nucleo-l1/dist/openocd.cfg vendored Normal file
View File

@ -0,0 +1 @@
source [find board/st_nucleo_l1.cfg]

View File

@ -1,12 +0,0 @@
#!/bin/bash
echo "##"
echo "## Resetting $1"
echo "##"
# Needs OpenOCD version 0.9.0 built after Jan. 26th 2015
openocd -f "board/st_nucleo_l1.cfg" \
-c "init" \
-c "reset run"\
-c "shutdown"

View File

@ -14,9 +14,12 @@ export AS = $(PREFIX)as
export LINK = $(PREFIX)gcc
export SIZE = $(PREFIX)size
export OBJCOPY = $(PREFIX)objcopy
export TERMPROG = $(RIOTBASE)/dist/tools/pyterm/pyterm -p
export FLASHER = $(RIOTBOARD)/$(BOARD)/dist/flash.sh
export DEBUGGER = $(RIOTBOARD)/$(BOARD)/dist/debug.sh
export DBG = $(PREFIX)gdb
export TERMPROG = $(RIOTBASE)/dist/tools/pyterm/pyterm
export FLASHER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export DEBUGGER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export DEBUGSERVER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export RESET = $(RIOTBASE)/dist/tools/openocd/openocd.sh
# define build specific options
export CPU_USAGE = -mcpu=cortex-m0plus
@ -27,10 +30,12 @@ export ASFLAGS += -ggdb -g3 $(CPU_USAGE) $(FPU_USAGE) -mlittle-endian
export LINKFLAGS += -g3 -ggdb -std=gnu99 $(CPU_USAGE) $(FPU_USAGE) -mlittle-endian -static -lgcc -mthumb -mno-thumb-interwork -nostartfiles
# linkerscript specified in cpu/Makefile.include
export LINKFLAGS += -T$(LINKERSCRIPT)
export OFLAGS += -O binary
export FFLAGS += $(HEXFILE)
export DEBUGGER_FLAGS = $(RIOTBOARD)/$(BOARD)/dist/gdb.conf $(ELFFILE)
export TERMFLAGS += "$(PORT)"
export OFLAGS = -O ihex
export TERMFLAGS += -p "$(PORT)"
export FFLAGS = flash
export DEBUGGER_FLAGS = debug
export DEBUGSERVER_FLAGS = debug-server
export RESET_FLAGS = reset
# unwanted (CXXUWFLAGS) and extra (CXXEXFLAGS) flags for c++
export CXXUWFLAGS +=
@ -42,5 +47,5 @@ export LINKFLAGS += -specs=nano.specs -lc -lnosys
endif
# export board specific includes to the global includes-listing
export INCLUDES += -I$(RIOTBOARD)/$(BOARD)/include/
export INCLUDES += -I$(RIOTBOARD)/$(BOARD)/include/
include $(RIOTBOARD)/$(BOARD)/Makefile.dep

View File

@ -1,19 +0,0 @@
#!/bin/bash
openocd -f "board/atmel_samr21_xplained_pro.cfg" \
-c "tcl_port 6333" \
-c "telnet_port 4444" \
-c "init" \
-c "targets" \
-c "reset halt" \
-l /dev/null &
# save pid to terminate afterwards
OCD_PID=$?
# needed for openocd to set up
sleep 5
arm-none-eabi-gdb -tui --command=${1} ${2}
kill ${OCD_PID}

View File

@ -1,11 +0,0 @@
#!/bin/bash
openocd -f "board/atmel_samr21_xplained_pro.cfg" \
-c "init" \
-c "targets" \
-c "reset halt" \
-c "reset init" \
-c "flash write_image erase $1" \
-c "verify_image $1" \
-c "reset run" \
-c "shutdown"

View File

@ -1,2 +0,0 @@
target remote localhost:3333
monitor reset halt

1
boards/samr21-xpro/dist/openocd.cfg vendored Normal file
View File

@ -0,0 +1 @@
source [find board/atmel_samr21_xplained_pro.cfg]

View File

@ -23,10 +23,12 @@ export AS = $(PREFIX)as
export LINK = $(PREFIX)gcc
export SIZE = $(PREFIX)size
export OBJCOPY = $(PREFIX)objcopy
export DBG = $(PREFIX)gdb
export TERMPROG = $(RIOTBASE)/dist/tools/pyterm/pyterm
export FLASHER = $(RIOTBOARD)/$(BOARD)/dist/flash.sh
export DEBUGGER = $(RIOTBOARD)/$(BOARD)/dist/debug.sh
export RESET = $(RIOTBOARD)/$(BOARD)/dist/reset.sh
export FLASHER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export DEBUGGER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export DEBUGSERVER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export RESET = $(RIOTBASE)/dist/tools/openocd/openocd.sh
# define build specific options
CPU_USAGE = -mcpu=cortex-m0
@ -39,6 +41,10 @@ export LINKFLAGS += -g3 -ggdb -std=gnu99 $(CPU_USAGE) $(FPU_USAGE) -mlittle-endi
export LINKFLAGS += -T$(LINKERSCRIPT)
export OFLAGS = -O ihex
export TERMFLAGS += -p "$(PORT)"
export FFLAGS = flash
export DEBUGGER_FLAGS = debug
export DEBUGSERVER_FLAGS = debug-server
export RESET_FLAGS = reset
# unwanted (CXXUWFLAGS) and extra (CXXEXFLAGS) flags for c++
export CXXUWFLAGS +=

View File

@ -1,27 +0,0 @@
#!/bin/sh
# check if GDB_PORT is already defined
if [ -z ${GDB_PORT} ]; then
# set to gdb standard port
GDB_PORT=3333
fi
echo "Listening for GDB connection on port ${GDB_PORT}"
openocd -f "board/stm32f0discovery.cfg" \
-c "tcl_port 6333" \
-c "telnet_port 4444" \
-c "gdb_port ${GDB_PORT}" \
-c "init" \
-c "targets" \
-c "reset halt" \
-l /dev/null &
# save pid to terminate afterwards
OCD_PID=$?
# needed for openocd to set up
sleep 2
arm-none-eabi-gdb -tui -command="${RIOTBOARD}/${BOARD}/dist/gdb.cfg" ${ELFFILE}
kill ${OCD_PID}

View File

@ -1,13 +0,0 @@
#!/bin/sh
openocd -f "board/stm32f0discovery.cfg" \
-c 'tcl_port 0' \
-c 'gdb_port 0' \
-c 'telnet_port 0' \
-c "init" \
-c "targets" \
-c "reset halt" \
-c "flash write_image erase ${HEXFILE} 0" \
-c "verify_image ${HEXFILE}" \
-c "reset run"\
-c "shutdown"

View File

@ -1 +0,0 @@
target extended-remote :3333

View File

@ -0,0 +1 @@
source [find board/stm32f0discovery.cfg]

View File

@ -1,9 +0,0 @@
#!/bin/sh
openocd -f "board/stm32f0discovery.cfg" \
-c 'tcl_port 0' \
-c 'gdb_port 0' \
-c 'telnet_port 0' \
-c "init" \
-c "reset run" \
-c "shutdown"

View File

@ -23,10 +23,12 @@ export AS = $(PREFIX)as
export LINK = $(PREFIX)gcc
export SIZE = $(PREFIX)size
export OBJCOPY = $(PREFIX)objcopy
export DBG = $(PREFIX)gdb
export TERMPROG = $(RIOTBASE)/dist/tools/pyterm/pyterm
export FLASHER = $(RIOTBOARD)/$(BOARD)/dist/flash.sh
export DEBUGGER = $(RIOTBOARD)/$(BOARD)/dist/debug.sh
export RESET = $(RIOTBOARD)/$(BOARD)/dist/reset.sh
export FLASHER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export DEBUGGER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export DEBUGSERVER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export RESET = $(RIOTBASE)/dist/tools/openocd/openocd.sh
# define build specific options
CPU_USAGE = -mcpu=cortex-m4
@ -36,8 +38,12 @@ export CFLAGS += -ffunction-sections -fdata-sections -fno-builtin
export ASFLAGS += -ggdb -g3 $(CPU_USAGE) $(FPU_USAGE) -mlittle-endian
export LINKFLAGS += -g3 -ggdb -std=gnu99 $(CPU_USAGE) $(FPU_USAGE) -mlittle-endian -static -lgcc -mthumb -mno-thumb-interwork -nostartfiles
export LINKFLAGS += -T$(LINKERSCRIPT)
export OFLAGS = -O binary
export OFLAGS = -O ihex
export TERMFLAGS += -p "$(PORT)"
export FFLAGS = flash
export DEBUGGER_FLAGS = debug
export DEBUGSERVER_FLAGS = debug-server
export RESET_FLAGS = reset
# unwanted (CXXUWFLAGS) and extra (CXXEXFLAGS) flags for c++
export CXXUWFLAGS +=

View File

@ -1,32 +0,0 @@
#!/bin/sh
echo "##"
echo "## Debugging ${ELFFILE}"
echo "##"
# if GDB_PORT does not exist or holds empty string
if [ -z ${GDB_PORT} ]; then
# set to gdb standard port
GDB_PORT=3333
else
echo "Listening for GDB connection on port ${GDB_PORT}"
fi
openocd -f "board/stm32f3discovery.cfg" \
-c "tcl_port 6333" \
-c "telnet_port 4444" \
-c "gdb_port ${GDB_PORT}" \
-c "init" \
-c "targets" \
-c "reset halt" \
-l /dev/null &
# save pid to terminate afterwards
OCD_PID=$?
# needed for openocd to set up
sleep 2
arm-none-eabi-gdb -tui -command=${RIOTBOARD}/${BOARD}/dist/gdb.conf ${ELFFILE}
kill ${OCD_PID}

View File

@ -1,16 +0,0 @@
#!/bin/bash
echo "##"
echo "## Flashing ${HEXFILE}"
echo "##"
openocd -f "board/stm32f3discovery.cfg" \
-c "tcl_port 0" \
-c "telnet_port 0" \
-c "gdb_port 0" \
-c "init" \
-c "targets" \
-c "reset halt" \
-c "program ${HEXFILE} 0x08000000 verify" \
-c "reset run"\
-c "shutdown"

View File

@ -1 +0,0 @@
tar extended-remote :3333

View File

@ -0,0 +1 @@
source [find board/stm32f3discovery.cfg]

View File

@ -1,13 +0,0 @@
#!/bin/bash
echo "##"
echo "## Resetting ${BOARD}"
echo "##"
openocd -f "board/stm32f3discovery.cfg" \
-c "tcl_port 0" \
-c "telnet_port 0" \
-c "gdb_port 0" \
-c "init" \
-c "reset run"\
-c "shutdown"

View File

@ -23,10 +23,12 @@ export AS = $(PREFIX)as
export LINK = $(PREFIX)gcc
export SIZE = $(PREFIX)size
export OBJCOPY = $(PREFIX)objcopy
export DBG = $(PREFIX)gdb
export TERMPROG = $(RIOTBASE)/dist/tools/pyterm/pyterm
export FLASHER = $(RIOTBOARD)/$(BOARD)/dist/flash.sh
export DEBUGGER = $(RIOTBOARD)/$(BOARD)/dist/debug.sh
export RESET = $(RIOTBOARD)/$(BOARD)/dist/reset.sh
export FLASHER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export DEBUGGER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export DEBUGSERVER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export RESET = $(RIOTBASE)/dist/tools/openocd/openocd.sh
# define build specific options
CPU_USAGE = -mcpu=cortex-m4
@ -39,8 +41,10 @@ export LINKFLAGS += -g3 -ggdb -std=gnu99 $(CPU_USAGE) $(FPU_USAGE) -mlittle-endi
export LINKFLAGS += -T$(LINKERSCRIPT)
export OFLAGS = -O ihex
export TERMFLAGS += -p "$(PORT)"
export FFLAGS = $(HEXFILE)
export DEBUGGER_FLAGS = $(RIOTBOARD)/$(BOARD)/dist/gdb.cfg $(ELFFILE)
export FFLAGS = flash
export DEBUGGER_FLAGS = debug
export DEBUGSERVER_FLAGS = debug-server
export RESET_FLAGS = reset
# unwanted (CXXUWFLAGS) and extra (CXXEXFLAGS) flags for c++
export CXXUWFLAGS +=

View File

@ -1,19 +0,0 @@
#!/bin/sh
openocd -f "board/stm32f4discovery.cfg" \
-c "tcl_port 6333" \
-c "telnet_port 4444" \
-c "init" \
-c "targets" \
-c "reset halt" \
-l /dev/null &
# save pid to terminate afterwards
OCD_PID=$?
# needed for openocd to set up
sleep 2
arm-none-eabi-gdb -tui -command=$1 $2
kill ${OCD_PID}

View File

@ -1,15 +0,0 @@
#!/bin/sh
openocd -f "board/stm32f4discovery.cfg" \
-c 'tcl_port 0' \
-c 'gdb_port 0' \
-c 'telnet_port 0' \
-c "init" \
-c "targets" \
-c "reset" \
-c "halt" \
-c "flash protect 0 0 11 off" \
-c "flash write_image erase $1 0 ihex" \
-c "verify_image $1" \
-c "reset run"\
-c "shutdown"

View File

@ -1 +0,0 @@
target extended-remote :3333

View File

@ -0,0 +1 @@
source [find board/stm32f4discovery.cfg]

View File

@ -1,9 +0,0 @@
#!/bin/sh
openocd -f "board/stm32f4discovery.cfg" \
-c 'tcl_port 0' \
-c 'gdb_port 0' \
-c 'telnet_port 0' \
-c "init" \
-c "reset run" \
-c "shutdown"

View File

@ -23,11 +23,12 @@ export AS = $(PREFIX)as
export LINK = $(PREFIX)gcc
export SIZE = $(PREFIX)size
export OBJCOPY = $(PREFIX)objcopy
export DBG = $(PREFIX)gdb
export TERMPROG = $(RIOTBASE)/dist/tools/pyterm/pyterm
export FLASHER = $(RIOTBOARD)/$(BOARD)/dist/flash.sh
export DEBUGGER = $(RIOTBOARD)/$(BOARD)/dist/debug.sh
export DEBUGSERVER = $(RIOTBOARD)/$(BOARD)/dist/debug-server.sh
export RESET = $(RIOTBOARD)/$(BOARD)/dist/reset.sh
export FLASHER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export DEBUGGER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export DEBUGSERVER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export RESET = $(RIOTBASE)/dist/tools/openocd/openocd.sh
# define build specific options
CPU_USAGE = -mcpu=cortex-m0
@ -38,11 +39,12 @@ export ASFLAGS += -ggdb -g3 $(CPU_USAGE) $(FPU_USAGE) -mlittle-endian
export LINKFLAGS += -g3 -ggdb -std=gnu99 $(CPU_USAGE) $(FPU_USAGE) -mlittle-endian -static -lgcc -mthumb -mno-thumb-interwork -nostartfiles
# $(LINKERSCRIPT) is specified in cpu/Makefile.include
export LINKFLAGS += -T$(LINKERSCRIPT)
export OFLAGS = -O binary
export HEXFILE = $(ELFFILE:.elf=.bin)
export OFLAGS = -O ihex
export TERMFLAGS += -p "$(PORT)"
export FFLAGS = $(HEXFILE)
export DEBUGGER_FLAGS = $(ELFFILE)
export FFLAGS = flash
export DEBUGGER_FLAGS = debug
export DEBUGSERVER_FLAGS = debug-server
export RESET_FLAGS = reset
# unwanted (CXXUWFLAGS) and extra (CXXEXFLAGS) flags for c++
export CXXUWFLAGS +=

View File

@ -1,17 +0,0 @@
#!/bin/sh
if [ -L "$0" ]; then
FILE=$(readlink "$0")
else
FILE="$0"
fi
BIN_FOLDER=$(dirname "${FILE}")
echo "##"
echo "## Starting debug server"
echo "##"
openocd -f "${BIN_FOLDER}/openocd.cfg" \
-c "init" \
-c "targets" \
-c "reset halt" \

View File

@ -1,19 +0,0 @@
#!/bin/sh
if [ ! -f "$1" ]; then
echo "ELF-file $1 does not exist"
exit 1
fi
if [ -L "$0" ]; then
FILE=$(readlink "$0")
else
FILE="$0"
fi
BIN_FOLDER=$(dirname "${FILE}")
echo "##"
echo "## Debugging $1"
echo "##"
arm-none-eabi-gdb -tui -command="${BIN_FOLDER}/gdb.cfg" $1

View File

@ -1,27 +0,0 @@
#!/bin/sh
if [ ! -f "$1" ]; then
echo "Binary file $1 does not exist"
exit 1
fi
if [ -L "$0" ]; then
FILE=$(readlink "$0")
else
FILE="$0"
fi
BIN_FOLDER=$(dirname "${FILE}")
echo "##"
echo "## Flashing $1"
echo "##"
openocd -f "${BIN_FOLDER}/openocd.cfg" \
-c "init" \
-c "targets" \
-c "flash banks" \
-c "reset halt" \
-c "flash write_image erase $1 0" \
-c "verify_image $1" \
-c "reset run"\
-c "shutdown"

View File

@ -1 +0,0 @@
target extended-remote 127.0.0.1:3333

View File

@ -1,10 +1,5 @@
# nRF51822 Target
source [find interface/stlink-v2.cfg]
transport select hla_swd
set WORKAREASIZE 0x4000
source [find target/nrf51.cfg]
# use hardware reset, connect under reset
#reset_config srst_only srst_nogate

View File

@ -1,17 +0,0 @@
#!/bin/sh
if [ -L "$0" ]; then
FILE=$(readlink "$0")
else
FILE="$0"
fi
BIN_FOLDER=$(dirname "${FILE}")
echo "##"
echo "## Resetting $BOARD"
echo "##"
openocd -f "${BIN_FOLDER}/openocd.cfg" \
-c "init" \
-c "reset run" \
-c "shutdown"

184
dist/tools/openocd/openocd.sh vendored Executable file
View File

@ -0,0 +1,184 @@
#!/bin/sh
#
# Unified OpenOCD script for RIOT
#
# This script is supposed to be called from RIOTs make system,
# as it depends on certain environment variables. An OpenOCD
# configuration file must be present in a the boards dist folder.
#
# The script supports the following actions:
#
# flash: flash a given hexfile to the target.
# hexfile is expected in ihex format and is pointed to
# by HEXFILE environment variable
#
# options:
# HEXFILE: path to the hexfile that is flashed
#
# debug: starts OpenOCD as GDB server in the background and
# connects to the server with the GDB client specified by
# the board (DBG environment variable)
#
# options:
# GDB_PORT: port opened for GDB connections
# TCL_PORT: port opened for TCL connections
# TELNET_PORT: port opened for telnet connections
# TUI: if TUI!=null, the -tui option will be used
#
# debug-server: starts OpenOCD as GDB server, but does not connect to
# to it with any frontend. This might be useful when using
# IDEs.
#
# options:
# GDB_PORT: port opened for GDB connections
# TCL_PORT: port opened for TCL connections
# TELNET_PORT: port opened for telnet connections
#
# reset: triggers a hardware reset of the target board
#
#
# @author Hauke Peteresen <hauke.petersen@fu-berlin.de>
# default GDB port
_GDB_PORT=3333
# default telnet port
_TELNET_PORT=4444
# default TCL port
_TCL_PORT=6333
# path to OpenOCD configuration file
CONFIG=${RIOTBOARD}/${BOARD}/dist/openocd.cfg
#
# a couple of tests for certain configuration options
#
test_config() {
if [ ! -f ${CONFIG} ]; then
echo "Error: Unable to locate OpenOCD configuration file"
echo " (${CONFIG})"
exit 1
fi
}
test_hexfile() {
if [ ! -f ${HEXFILE} ]; then
echo "Error: Unable to locate HEXFILE"
echo " (${HEXFILE})"
exit 1
fi
}
test_elffile() {
if [ ! -f ${ELFFILE} ]; then
echo "Error: Unable to locate ELFFILE"
echo " (${ELFFILE})"
exit 1
fi
}
test_ports() {
if [ -z ${GDB_PORT} ]; then
GDB_PORT=${_GDB_PORT}
fi
if [ -z ${TELNET_PORT} ]; then
TELNET_PORT=${_TELNET_PORT}
fi
if [ -z ${TCL_PORT} ]; then
TCL_PORT=${_TCL_PORT}
fi
}
test_tui() {
if [ -n "${TUI}" ]; then
TUI=-tui
fi
}
#
# now comes the actual actions
#
do_flash() {
test_config
test_hexfile
# flash device
openocd -f ${CONFIG} \
-c "tcl_port 0" \
-c "telnet_port 0" \
-c "gdb_port 0" \
-c "init" \
-c "targets" \
-c "reset halt" \
-c "program ${HEXFILE} verify" \
-c "reset run"
}
do_debug() {
test_config
test_elffile
test_ports
test_tui
# start OpenOCD as GDB server
openocd -f ${CONFIG} \
-c "tcl_port ${TCL_PORT}" \
-c "telnet_port ${TELNET_PORT}" \
-c "gdb_port ${GDB_PORT}" \
-c "init" \
-c "targets" \
-c "reset halt" \
-l /dev/null &
# save PID for terminating the server afterwards
OCD_PID=$?
# connect to the GDB server
${DBG} ${TUI} -ex "tar ext :${GDB_PORT}" ${ELFFILE}
# clean up
kill ${OCD_PID}
}
do_debugserver() {
test_config
test_ports
# start OpenOCD as GDB server
openocd -f ${CONFIG} \
-c "tcl_port ${TCL_PORT}" \
-c "telnet_port ${TELNET_PORT}" \
-c "gdb_port ${GDB_PORT}" \
-c "init" \
-c "targets" \
-c "reset halt"
}
do_reset() {
test_config
# start OpenOCD and invoke board reset
openocd -f ${CONFIG} \
-c "tcl_port 0" \
-c "telnet_port 0" \
-c "gdb_port 0" \
-c "init" \
-c "reset run" \
-c "shutdown"
}
#
# parameter dispatching
#
case "$1" in
flash)
echo "### Flashing Target ###"
do_flash
;;
debug)
echo "### Starting Debugging ###"
do_debug
;;
debug-server)
echo "### Starting GDB Server ###"
do_debugserver
;;
reset)
echo "### Resetting Target ###"
do_reset
;;
*)
echo "Usage: $0 {flash|debug|debug-server|reset} [PARAM]"
;;
esac