diff --git a/boards/stm32f4discovery/Makefile.include b/boards/stm32f4discovery/Makefile.include index cecaf4cd56..c0940be84e 100644 --- a/boards/stm32f4discovery/Makefile.include +++ b/boards/stm32f4discovery/Makefile.include @@ -24,9 +24,9 @@ export LINK = $(PREFIX)gcc export SIZE = $(PREFIX)size export OBJCOPY = $(PREFIX)objcopy export TERMPROG = $(RIOTBASE)/dist/tools/pyterm/pyterm -export FLASHER = st-flash +export FLASHER = $(RIOTBOARD)/$(BOARD)/dist/flash.sh export DEBUGGER = $(RIOTBOARD)/$(BOARD)/dist/debug.sh -export DEBUGSERVER = st-util +export RESET = $(RIOTBOARD)/$(BOARD)/dist/reset.sh # define build specific options CPU_USAGE = -mcpu=cortex-m4 @@ -35,11 +35,12 @@ export CFLAGS += -ggdb -g3 -std=gnu99 -Os -Wall -Wstrict-prototypes $(CPU_USAGE) 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 -mthumb-interwork -nostartfiles +# $(LINKERSCRIPT) is specified in cpu/Makefile.include export LINKFLAGS += -T$(LINKERSCRIPT) -export OFLAGS = -O binary -export FFLAGS = write bin/$(BOARD)/$(APPLICATION).hex 0x8000000 -export DEBUGGER_FLAGS = $(RIOTBOARD)/$(BOARD)/dist/gdb.conf $(BINDIR)/$(APPLICATION).elf +export OFLAGS = -O ihex export TERMFLAGS += -p "$(PORT)" +export FFLAGS = $(HEXFILE) +export DEBUGGER_FLAGS = $(RIOTBOARD)/$(BOARD)/dist/gdb.cfg $(ELFFILE) # unwanted (CXXUWFLAGS) and extra (CXXEXFLAGS) flags for c++ export CXXUWFLAGS += diff --git a/boards/stm32f4discovery/dist/debug.sh b/boards/stm32f4discovery/dist/debug.sh index 1a0c4b0cd4..28c024a38f 100755 --- a/boards/stm32f4discovery/dist/debug.sh +++ b/boards/stm32f4discovery/dist/debug.sh @@ -1,4 +1,19 @@ #!/bin/sh -echo "Debugging $1" +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} diff --git a/boards/stm32f4discovery/dist/flash.sh b/boards/stm32f4discovery/dist/flash.sh new file mode 100755 index 0000000000..10b482c02f --- /dev/null +++ b/boards/stm32f4discovery/dist/flash.sh @@ -0,0 +1,16 @@ +#!/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 erase_address 0x08000000 0x100000" \ + -c "flash write_image erase $1 0 ihex" \ + -c "verify_image $1" \ + -c "reset run"\ + -c "shutdown" diff --git a/boards/stm32f4discovery/dist/gdb.cfg b/boards/stm32f4discovery/dist/gdb.cfg new file mode 100644 index 0000000000..6dacee6e06 --- /dev/null +++ b/boards/stm32f4discovery/dist/gdb.cfg @@ -0,0 +1 @@ +target extended-remote :3333 diff --git a/boards/stm32f4discovery/dist/gdb.conf b/boards/stm32f4discovery/dist/gdb.conf deleted file mode 100644 index 7257c72805..0000000000 --- a/boards/stm32f4discovery/dist/gdb.conf +++ /dev/null @@ -1 +0,0 @@ -tar extended-remote :4242 diff --git a/boards/stm32f4discovery/dist/reset.sh b/boards/stm32f4discovery/dist/reset.sh new file mode 100755 index 0000000000..6d4aeeb269 --- /dev/null +++ b/boards/stm32f4discovery/dist/reset.sh @@ -0,0 +1,9 @@ +#!/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"