Permalink
Browse files

Merge pull request #125 from bvernoux/master

Cleanup and Fix code for HydraBus
  • Loading branch information...
gsmcmullin committed Apr 18, 2016
2 parents 0e8cbd4 + 2e3778e commit e010cd763def53df30b6013676899d2ead4ab794
@@ -16,23 +16,16 @@ LDFLAGS = -lopencm3_stm32f4 -Wl,--defsym,_stack=0x20006000 \
VPATH += platforms/stm32
SRC += cdcacm.c \
- platform.c \
traceswo.c \
usbuart.c \
serialno.c \
timing.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
@@ -19,7 +19,8 @@ Connections
How to Build
============
```
-cd blackmagic/src
+cd blackmagic
+make clean
make PROBE_HOST=hydrabus
```
@@ -3,7 +3,7 @@
*
* Copyright (C) 2015 Black Sphere Technologies Ltd.
* Written by Gareth McMullin <gareth@blacksphere.co.nz>
- * Copyright (C) 2015 Benjamin Vernoux <bvernoux@gmail.com>
+ * Copyright (C) 2016 Benjamin Vernoux <bvernoux@gmail.com>
*
* 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 <setjmp.h>
-#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
@@ -18,16 +18,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <string.h>
+#include "general.h"
+#include "usbdfu.h"
+
#include <libopencm3/cm3/systick.h>
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/gpio.h>
#include <libopencm3/cm3/scb.h>
-#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();
}

0 comments on commit e010cd7

Please sign in to comment.