From f0ef22232b4e6bf7030aefd7f029a4a320c47b91 Mon Sep 17 00:00:00 2001 From: smlng <s@mlng.net> Date: Wed, 1 Nov 2017 17:09:10 +0100 Subject: [PATCH] bluepill: dfu-util support --- boards/bluepill/Makefile.include | 19 +++++++++++- cpu/stm32f1/ldscripts/stm32f103c8_bluepill.ld | 29 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 cpu/stm32f1/ldscripts/stm32f103c8_bluepill.ld diff --git a/boards/bluepill/Makefile.include b/boards/bluepill/Makefile.include index b666f26bc5..394d1257ac 100644 --- a/boards/bluepill/Makefile.include +++ b/boards/bluepill/Makefile.include @@ -9,5 +9,22 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*))) # setup serial terminal include $(RIOTMAKE)/tools/serial.inc.mk -# this board uses openocd +# optionally, use dfu-util to flash via usb +# note: needs a bootloader flashed before, config below is compatible +# with blackmagic_dfu, see https://github.com/blacksphere/blackmagic/ +# To stop bootloader from loading an existing firmware, pull down +# (ground) GPIO B1. +ifeq ($(PROGRAMMER),dfu-util) + export LINKER_SCRIPT = stm32f103c8_bluepill.ld + export BINFILE = $(patsubst %.elf,%.bin,$(ELFFILE)) + + export FLASHER = dfu-util + export DEBUGGER = # no debugger + export RESET = # dfu-util has no support for resetting the device + + export OFLAGS = -O binary + export FFLAGS = -d 1d50:6017 -s 0x08002000:leave -D "$(HEXFILE)" +else +# this board uses openocd by default include $(RIOTMAKE)/tools/openocd.inc.mk +endif diff --git a/cpu/stm32f1/ldscripts/stm32f103c8_bluepill.ld b/cpu/stm32f1/ldscripts/stm32f103c8_bluepill.ld new file mode 100644 index 0000000000..4181d1d7a2 --- /dev/null +++ b/cpu/stm32f1/ldscripts/stm32f103c8_bluepill.ld @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2015 Alexander Melnikov <avmelnikoff@gmail.com> + * 2017 HAW Hamburg + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @addtogroup cpu_stm32f1 + * @{ + * + * @file + * @brief Memory definitions for the STM32F103C8 + * + * @author Alexander Melnikov <avmelnikoff@gmail.com> + * @author Sebastian Meiling <s@mlng.net> + * + * @} + */ + +MEMORY +{ + rom (rx) : ORIGIN = 0x08002000, LENGTH = 64K-0x2000 + ram (xrw) : ORIGIN = 0x20000000, LENGTH = 20K +} + +INCLUDE cortexm_base.ld -- GitLab