From 2e3778e77235188c224917f7ae6a881eec5dd813 Mon Sep 17 00:00:00 2001 From: bvernoux Date: Mon, 18 Apr 2016 00:48:06 +0200 Subject: [PATCH] Cleanup and Fix code for HydraBus --- src/platforms/hydrabus/Makefile.inc | 9 +------ src/platforms/hydrabus/Readme.md | 3 ++- src/platforms/hydrabus/platform.h | 38 ++++++++++++----------------- src/platforms/hydrabus/usbdfu.c | 10 +++----- 4 files changed, 22 insertions(+), 38 deletions(-) diff --git a/src/platforms/hydrabus/Makefile.inc b/src/platforms/hydrabus/Makefile.inc index 50fd4fd..e7c6907 100644 --- a/src/platforms/hydrabus/Makefile.inc +++ b/src/platforms/hydrabus/Makefile.inc @@ -16,7 +16,6 @@ LDFLAGS = -lopencm3_stm32f4 -Wl,--defsym,_stack=0x20006000 \ VPATH += platforms/stm32 SRC += cdcacm.c \ - platform.c \ traceswo.c \ usbuart.c \ serialno.c \ @@ -24,15 +23,9 @@ SRC += cdcacm.c \ all: blackmagic.bin blackmagic.hex blackmagic.dfu -blackmagic.bin: blackmagic - $(OBJCOPY) -O binary $^ $@ - -blackmagic.hex: blackmagic.bin - $(OBJCOPY) -O ihex blackmagic $@ - blackmagic.dfu: blackmagic.hex @echo Creating $@ @python ../scripts/dfu-convert.py -i $< $@ host_clean: - -rm blackmagic.bin blackmagic.hex blackmagic.dfu + -$(Q)$(RM) blackmagic.bin blackmagic.hex blackmagic.dfu diff --git a/src/platforms/hydrabus/Readme.md b/src/platforms/hydrabus/Readme.md index 47366bb..1eb824b 100644 --- a/src/platforms/hydrabus/Readme.md +++ b/src/platforms/hydrabus/Readme.md @@ -19,7 +19,8 @@ Connections How to Build ============ ``` -cd blackmagic/src +cd blackmagic +make clean make PROBE_HOST=hydrabus ``` diff --git a/src/platforms/hydrabus/platform.h b/src/platforms/hydrabus/platform.h index 6a36a54..eb7a298 100644 --- a/src/platforms/hydrabus/platform.h +++ b/src/platforms/hydrabus/platform.h @@ -3,7 +3,7 @@ * * Copyright (C) 2015 Black Sphere Technologies Ltd. * Written by Gareth McMullin - * Copyright (C) 2015 Benjamin Vernoux + * Copyright (C) 2016 Benjamin Vernoux * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,18 +25,15 @@ #ifndef __PLATFORM_H #define __PLATFORM_H -#include "gdb_packet.h" #include "gpio.h" -#include "morse.h" #include "timing.h" +#include "version.h" #include -#define INLINE_GPIO -#define CDCACM_PACKET_SIZE 64 #define PLATFORM_HAS_TRACESWO -#define BOARD_IDENT "Black Magic Probe (HydraBus), (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")" -#define BOARD_IDENT_DFU "Black Magic (Upgrade) for HydraBus, (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")" +#define BOARD_IDENT "Black Magic Probe (HydraBus), (Firmware " FIRMWARE_VERSION ")" +#define BOARD_IDENT_DFU "Black Magic (Upgrade) for HydraBus, (Firmware " FIRMWARE_VERSION ")" #define DFU_IDENT "Black Magic Firmware Upgrade (HydraBus)" #define DFU_IFACE_STRING "@Internal Flash /0x08000000/1*016Ka,3*016Kg,1*064Kg,7*128Kg" @@ -59,26 +56,25 @@ /* Hardware definitions... */ #define JTAG_PORT GPIOC +#define TDI_PORT JTAG_PORT #define TMS_PORT JTAG_PORT #define TCK_PORT JTAG_PORT #define TDO_PORT JTAG_PORT -#define TDI_PORT JTAG_PORT +#define TDI_PIN GPIO3 #define TMS_PIN GPIO0 #define TCK_PIN GPIO1 #define TDO_PIN GPIO2 -#define TDI_PIN GPIO3 #define SWDIO_PORT JTAG_PORT #define SWCLK_PORT JTAG_PORT #define SWDIO_PIN TMS_PIN #define SWCLK_PIN TCK_PIN -#define SRST_PORT GPIOC -#define SRST_PIN GPIO4 - #define TRST_PORT GPIOC #define TRST_PIN GPIO5 +#define SRST_PORT GPIOC +#define SRST_PIN GPIO4 #define LED_PORT GPIOA #define LED_PORT_UART GPIOA @@ -141,22 +137,17 @@ #define DEBUG(...) -extern jmp_buf fatal_error_jmpbuf; +#define gpio_set_val(port, pin, val) do { \ + if(val) \ + gpio_set((port), (pin)); \ + else \ + gpio_clear((port), (pin)); \ +} while(0) #define SET_RUN_STATE(state) {running_status = (state);} #define SET_IDLE_STATE(state) {gpio_set_val(LED_PORT, LED_IDLE_RUN, state);} #define SET_ERROR_STATE(state) {gpio_set_val(LED_PORT, LED_ERROR, state);} -#define PLATFORM_SET_FATAL_ERROR_RECOVERY() {setjmp(fatal_error_jmpbuf);} -#define PLATFORM_FATAL_ERROR(error) { \ - if(running_status) gdb_putpacketz("X1D"); \ - else gdb_putpacketz("EFF"); \ - running_status = 0; \ - target_list_free(); \ - morse("TARGET LOST.", 1); \ - longjmp(fatal_error_jmpbuf, (error)); \ -} - static inline int platform_hwversion(void) { return 0; @@ -166,6 +157,7 @@ static inline int platform_hwversion(void) #define sscanf siscanf #define sprintf siprintf #define vasprintf vasiprintf +#define snprintf sniprintf #endif diff --git a/src/platforms/hydrabus/usbdfu.c b/src/platforms/hydrabus/usbdfu.c index fc9bccd..b43b59d 100644 --- a/src/platforms/hydrabus/usbdfu.c +++ b/src/platforms/hydrabus/usbdfu.c @@ -18,16 +18,14 @@ * along with this program. If not, see . */ -#include +#include "general.h" +#include "usbdfu.h" + #include #include #include #include -#include "usbdfu.h" - -extern void dfu_protect_enable(void); - void dfu_detach(void) { /* USB device must detach, we just reset... */ @@ -65,7 +63,7 @@ int main(void) gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO9 | GPIO10 | GPIO11 | GPIO12); gpio_set_af(GPIOA, GPIO_AF10, GPIO9 | GPIO10| GPIO11 | GPIO12); - dfu_init(&stm32f107_usb_driver, DFU_MODE); + dfu_init(&stm32f107_usb_driver); dfu_main(); }