From ee316431f5c6cb86a118b68aba5c5cb4894db425 Mon Sep 17 00:00:00 2001 From: Uwe Bonnes Date: Wed, 11 Dec 2019 21:25:28 +0100 Subject: [PATCH] stlink for st-bootloader: Reset with platform_request_boot() Both V2 and V21 switch to (ST) bootloader with powered reset. --- src/platforms/stlink/Makefile.inc | 6 +++++- src/platforms/stlink/stlink_common.c | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/platforms/stlink/Makefile.inc b/src/platforms/stlink/Makefile.inc index fe50dc1..32355c3 100644 --- a/src/platforms/stlink/Makefile.inc +++ b/src/platforms/stlink/Makefile.inc @@ -13,6 +13,7 @@ LDFLAGS_BOOT := $(LDFLAGS) --specs=nano.specs -lopencm3_stm32f1 \ -L../libopencm3/lib ifeq ($(ST_BOOTLOADER), 1) $(info Load address 0x08004000 for original ST-LinkV2 Bootloader) +CFLAGS += -DST_BOOTLOADER LDFLAGS = $(LDFLAGS_BOOT) -Wl,-Ttext=0x8004000 else LDFLAGS = $(LDFLAGS_BOOT) -Wl,-Ttext=0x8002000 @@ -34,8 +35,11 @@ SRC += cdcacm.c \ traceswoasync.c \ stlink_common.c \ +ifeq ($(ST_BOOTLOADER), 1) +all: blackmagic.bin blackmagic_dfu.bin blackmagic_dfu.hex +else all: blackmagic.bin blackmagic_dfu.bin blackmagic_dfu.hex dfu_upgrade.bin dfu_upgrade.hex - +endif blackmagic_dfu: usbdfu.o dfucore.o dfu_f1.o stlink_common.o @echo " LD $@" $(Q)$(CC) $^ -o $@ $(LDFLAGS_BOOT) diff --git a/src/platforms/stlink/stlink_common.c b/src/platforms/stlink/stlink_common.c index bee7a14..bb63ca2 100644 --- a/src/platforms/stlink/stlink_common.c +++ b/src/platforms/stlink/stlink_common.c @@ -93,6 +93,9 @@ uint32_t detect_rev(void) void platform_request_boot(void) { +#if defined(DST_BOOTLOADER) + scb_reset_system(); +#else uint32_t crl = GPIOA_CRL; /* Assert bootloader marker. * Enable Pull on GPIOA1. We don't rely on the external pin @@ -103,4 +106,5 @@ void platform_request_boot(void) crl |= 0x80; GPIOA_CRL = crl; SCB_VTOR = 0; +#endif }