diff --git a/.gitignore b/.gitignore index a40d44d..945fd3d 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,4 @@ tags *.b#* blackmagic_upgrade *.exe - +.vscode diff --git a/src/Makefile b/src/Makefile index 396bfec..7213244 100644 --- a/src/Makefile +++ b/src/Makefile @@ -64,12 +64,12 @@ ifndef TARGET TARGET=blackmagic endif -ifndef SWD_HL -SRC += swdptap.c swdptap_generic.c +ifdef NO_OWN_LL +SRC += jtagtap_generic.c swdptap_generic.c endif -ifndef JTAG_HL -SRC += jtag_scan.c jtagtap.c jtagtap_generic.c +ifndef OWN_HL +SRC += jtag_scan.c jtagtap.c swdptap.c endif OBJ = $(SRC:.c=.o) diff --git a/src/include/gdb_if.h b/src/include/gdb_if.h index 3307454..d2ad243 100644 --- a/src/include/gdb_if.h +++ b/src/include/gdb_if.h @@ -21,7 +21,7 @@ #ifndef __GDB_IF_H #define __GDB_IF_H -#if !defined(LIBFTDI) +#if !defined(PC_HOSTED) #include void gdb_usb_out_cb(usbd_device *dev, uint8_t ep); #endif diff --git a/src/include/platform_support.h b/src/include/platform_support.h index f595ad1..d431393 100644 --- a/src/include/platform_support.h +++ b/src/include/platform_support.h @@ -24,7 +24,7 @@ # error "Include 'general.h' instead" #endif -#if defined(LIBFTDI) +#if defined(PC_HOSTED) void platform_init(int argc, char **argv); #else void platform_init(void); diff --git a/src/include/swdptap.h b/src/include/swdptap.h index c51a28c..cdb6969 100644 --- a/src/include/swdptap.h +++ b/src/include/swdptap.h @@ -27,7 +27,9 @@ int swdptap_init(void); bool swdptap_bit_in(void); void swdptap_bit_out(bool val); -/* High level functions, provided as weak in swdptap_generic.c */ +/* Low level functions, provided in swdptap_generic.c from the primitives + (indicate NO_OWN_LL in the Makefile.inc or libopencm specific in + platforms/common*/ uint32_t swdptap_seq_in(int ticks); bool swdptap_seq_in_parity(uint32_t *data, int ticks); void swdptap_seq_out(uint32_t MS, int ticks); diff --git a/src/main.c b/src/main.c index de11953..26e8ffd 100644 --- a/src/main.c +++ b/src/main.c @@ -33,7 +33,7 @@ int main(int argc, char **argv) { -#if defined(LIBFTDI) +#if defined(PC_HOSTED) platform_init(argc, argv); #else (void) argc; diff --git a/src/platforms/stm32/jtagtap.c b/src/platforms/common/jtagtap.c similarity index 100% rename from src/platforms/stm32/jtagtap.c rename to src/platforms/common/jtagtap.c diff --git a/src/platforms/libftdi/Makefile.inc b/src/platforms/libftdi/Makefile.inc index c22d101..06c07d7 100644 --- a/src/platforms/libftdi/Makefile.inc +++ b/src/platforms/libftdi/Makefile.inc @@ -1,5 +1,5 @@ SYS = $(shell $(CC) -dumpmachine) -CFLAGS += -DLIBFTDI -DENABLE_DEBUG +CFLAGS += -DPC_HOSTED -DENABLE_DEBUG LDFLAGS += -lftdi1 ifneq (, $(findstring mingw, $(SYS))) LDFLAGS += -lusb-1.0 -lws2_32 diff --git a/src/platforms/pc-stlinkv2/Makefile.inc b/src/platforms/pc-stlinkv2/Makefile.inc index 7fa2479..53ec16a 100644 --- a/src/platforms/pc-stlinkv2/Makefile.inc +++ b/src/platforms/pc-stlinkv2/Makefile.inc @@ -1,6 +1,6 @@ TARGET=blackmagic_stlinkv2 SYS = $(shell $(CC) -dumpmachine) -CFLAGS += -DLIBFTDI -DSTLINKV2 -DJTAG_HL -DENABLE_DEBUG +CFLAGS += -DPC_HOSTED -DSTLINKV2 -DJTAG_HL -DENABLE_DEBUG CFLAGS +=-I ./target LDFLAGS += -lusb-1.0 ifneq (, $(findstring mingw, $(SYS))) @@ -11,5 +11,4 @@ LDFLAGS += -lws2_32 endif VPATH += platforms/pc SRC += timing.c stlinkv2.c -SWD_HL = 1 -JTAG_HL = 1 +OWN_HL = 1 diff --git a/src/target/jtagtap_generic.c b/src/target/jtagtap_generic.c index 416bcb6..249c087 100644 --- a/src/target/jtagtap_generic.c +++ b/src/target/jtagtap_generic.c @@ -24,8 +24,7 @@ #include "general.h" #include "jtagtap.h" -void __attribute__((weak)) -jtagtap_tms_seq(uint32_t MS, int ticks) +void jtagtap_tms_seq(uint32_t MS, int ticks) { while(ticks--) { jtagtap_next(MS & 1, 1); @@ -33,8 +32,7 @@ jtagtap_tms_seq(uint32_t MS, int ticks) } } -void __attribute__((weak)) -jtagtap_tdi_tdo_seq(uint8_t *DO, const uint8_t final_tms, const uint8_t *DI, int ticks) +void jtagtap_tdi_tdo_seq(uint8_t *DO, const uint8_t final_tms, const uint8_t *DI, int ticks) { uint8_t index = 1; while(ticks--) { @@ -50,8 +48,7 @@ jtagtap_tdi_tdo_seq(uint8_t *DO, const uint8_t final_tms, const uint8_t *DI, int } } -void __attribute__((weak)) -jtagtap_tdi_seq(const uint8_t final_tms, const uint8_t *DI, int ticks) +void jtagtap_tdi_seq(const uint8_t final_tms, const uint8_t *DI, int ticks) { uint8_t index = 1; while(ticks--) { diff --git a/src/target/swdptap_generic.c b/src/target/swdptap_generic.c index 13ee02f..d170eb0 100644 --- a/src/target/swdptap_generic.c +++ b/src/target/swdptap_generic.c @@ -20,8 +20,7 @@ #include "general.h" #include "swdptap.h" -uint32_t __attribute__((weak)) -swdptap_seq_in(int ticks) +uint32_t swdptap_seq_in(int ticks) { uint32_t index = 1; uint32_t ret = 0; @@ -35,8 +34,7 @@ swdptap_seq_in(int ticks) return ret; } -bool __attribute__((weak)) -swdptap_seq_in_parity(uint32_t *ret, int ticks) +bool swdptap_seq_in_parity(uint32_t *ret, int ticks) { uint32_t index = 1; uint8_t parity = 0; @@ -55,8 +53,7 @@ swdptap_seq_in_parity(uint32_t *ret, int ticks) return parity; } -void __attribute__((weak)) -swdptap_seq_out(uint32_t MS, int ticks) +void swdptap_seq_out(uint32_t MS, int ticks) { while (ticks--) { swdptap_bit_out(MS & 1); @@ -64,8 +61,7 @@ swdptap_seq_out(uint32_t MS, int ticks) } } -void __attribute__((weak)) -swdptap_seq_out_parity(uint32_t MS, int ticks) +void swdptap_seq_out_parity(uint32_t MS, int ticks) { uint8_t parity = 0; diff --git a/src/target/target.c b/src/target/target.c index 48dc748..db396a3 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -314,7 +314,7 @@ void target_detach(target *t) { t->detach(t); t->attached = false; -#if defined(LIBFTDI) +#if defined(PC_HOSTED) # include "platform.h" platform_buffer_flush(); #endif