stm32f4discovery: use openocd for flashing

This commit is contained in:
Christian Mehlis 2014-11-23 00:16:52 +01:00
parent 319f1b25ae
commit bea0171754
6 changed files with 48 additions and 7 deletions

View File

@ -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 +=

View File

@ -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}

16
boards/stm32f4discovery/dist/flash.sh vendored Executable file
View File

@ -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"

1
boards/stm32f4discovery/dist/gdb.cfg vendored Normal file
View File

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

View File

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

9
boards/stm32f4discovery/dist/reset.sh vendored Executable file
View File

@ -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"