Merge pull request #499 from smunaut/minor_enhancements

Minor enhancements
This commit is contained in:
UweBonnes 2019-08-13 19:58:26 +02:00 committed by GitHub
commit c9c8b089f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 29 additions and 21 deletions

View File

@ -4,15 +4,18 @@ Q := @
endif endif
PC_HOSTED = PC_HOSTED =
NO_LIBOPENCM3 =
ifeq ($(PROBE_HOST), libftdi) ifeq ($(PROBE_HOST), libftdi)
PC_HOSTED = true PC_HOSTED = true
NO_LIBOPENCM3 = true
endif endif
ifeq ($(PROBE_HOST), pc-stlinkv2) ifeq ($(PROBE_HOST), pc-stlinkv2)
PC_HOSTED = true PC_HOSTED = true
NO_LIBOPENCM3 = true
endif endif
all: all:
ifndef PC_HOSTED ifndef NO_LIBOPENCM3
$(Q)if [ ! -f libopencm3/Makefile ]; then \ $(Q)if [ ! -f libopencm3/Makefile ]; then \
echo "Initialising git submodules..." ;\ echo "Initialising git submodules..." ;\
git submodule init ;\ git submodule init ;\
@ -23,7 +26,7 @@ endif
$(Q)$(MAKE) $(MFLAGS) -C src $(Q)$(MAKE) $(MFLAGS) -C src
clean: clean:
ifndef PC_HOSTED ifndef NO_LIBOPENCM3
$(Q)$(MAKE) $(MFLAGS) -C libopencm3 $@ $(Q)$(MAKE) $(MFLAGS) -C libopencm3 $@
endif endif
$(Q)$(MAKE) $(MFLAGS) -C src $@ $(Q)$(MAKE) $(MFLAGS) -C src $@

View File

@ -8,12 +8,9 @@ MAKEFLAGS += --no-print-dir
Q := @ Q := @
endif endif
OPT_FLAGS ?= -O2
CFLAGS += -Wall -Wextra -Werror -Wno-char-subscripts -Wno-cast-function-type \ CFLAGS += -Wall -Wextra -Werror -Wno-char-subscripts -Wno-cast-function-type \
$(OPT_FLAGS) -std=gnu99 -g3 -MD \ -std=gnu99 -g3 -MD \
-I. -Iinclude -Iplatforms/common -I$(PLATFORM_DIR) -I. -Iinclude -Iplatforms/common -I$(PLATFORM_DIR)
LDFLAGS += $(OPT_FLAGS)
ifeq ($(ENABLE_DEBUG), 1) ifeq ($(ENABLE_DEBUG), 1)
CFLAGS += -DENABLE_DEBUG CFLAGS += -DENABLE_DEBUG
@ -60,6 +57,10 @@ SRC = \
include $(PLATFORM_DIR)/Makefile.inc include $(PLATFORM_DIR)/Makefile.inc
OPT_FLAGS ?= -O2
CFLAGS += $(OPT_FLAGS)
LDFLAGS += $(OPT_FLAGS)
ifndef TARGET ifndef TARGET
TARGET=blackmagic TARGET=blackmagic
endif endif
@ -72,7 +73,7 @@ ifndef OWN_HL
SRC += jtag_scan.c jtagtap.c swdptap.c SRC += jtag_scan.c jtagtap.c swdptap.c
endif endif
OBJ = $(SRC:.c=.o) OBJ = $(patsubst %.S,%.o,$(patsubst %.c,%.o,$(SRC)))
$(TARGET): include/version.h $(OBJ) $(TARGET): include/version.h $(OBJ)
@echo " LD $@" @echo " LD $@"
@ -82,6 +83,10 @@ $(TARGET): include/version.h $(OBJ)
@echo " CC $<" @echo " CC $<"
$(Q)$(CC) $(CFLAGS) -c $< -o $@ $(Q)$(CC) $(CFLAGS) -c $< -o $@
%.o: %.S
@echo " AS $<"
$(Q)$(CC) $(CFLAGS) -c $< -o $@
%.bin: % %.bin: %
@echo " OBJCOPY $@" @echo " OBJCOPY $@"
$(Q)$(OBJCOPY) -O binary $^ $@ $(Q)$(OBJCOPY) -O binary $^ $@

View File

@ -120,7 +120,7 @@ void gdb_putpacket(const char *packet, int size)
} }
} }
gdb_if_putchar('#', 0); gdb_if_putchar('#', 0);
sprintf(xmit_csum, "%02X", csum); snprintf(xmit_csum, sizeof(xmit_csum), "%02X", csum);
gdb_if_putchar(xmit_csum[0], 0); gdb_if_putchar(xmit_csum[0], 0);
gdb_if_putchar(xmit_csum[1], 1); gdb_if_putchar(xmit_csum[1], 1);
#ifdef DEBUG_GDBPACKET #ifdef DEBUG_GDBPACKET

View File

@ -21,7 +21,7 @@
#ifndef __GDB_IF_H #ifndef __GDB_IF_H
#define __GDB_IF_H #define __GDB_IF_H
#if !defined(PC_HOSTED) #if !defined(NO_LIBOPENCM3)
#include <libopencm3/usb/usbd.h> #include <libopencm3/usb/usbd.h>
void gdb_usb_out_cb(usbd_device *dev, uint8_t ep); void gdb_usb_out_cb(usbd_device *dev, uint8_t ep);
#endif #endif

View File

@ -1,5 +1,5 @@
SYS = $(shell $(CC) -dumpmachine) SYS = $(shell $(CC) -dumpmachine)
CFLAGS += -DPC_HOSTED -DENABLE_DEBUG CFLAGS += -DPC_HOSTED -DNO_LIBOPENCM3 -DENABLE_DEBUG
LDFLAGS += -lftdi1 LDFLAGS += -lftdi1
ifneq (, $(findstring mingw, $(SYS))) ifneq (, $(findstring mingw, $(SYS)))
LDFLAGS += -lusb-1.0 -lws2_32 LDFLAGS += -lusb-1.0 -lws2_32

View File

@ -1,6 +1,6 @@
TARGET=blackmagic_stlinkv2 TARGET=blackmagic_stlinkv2
SYS = $(shell $(CC) -dumpmachine) SYS = $(shell $(CC) -dumpmachine)
CFLAGS += -DPC_HOSTED -DSTLINKV2 -DJTAG_HL -DENABLE_DEBUG CFLAGS += -DPC_HOSTED -DNO_LIBOPENCM3 -DSTLINKV2 -DJTAG_HL -DENABLE_DEBUG
CFLAGS +=-I ./target CFLAGS +=-I ./target
LDFLAGS += -lusb-1.0 LDFLAGS += -lusb-1.0
ifneq (, $(findstring mingw, $(SYS))) ifneq (, $(findstring mingw, $(SYS)))

View File

@ -611,7 +611,7 @@ bool efm32_probe(target *t)
uint32_t ram_size = ram_kib * 0x400; uint32_t ram_size = ram_kib * 0x400;
uint32_t flash_page_size = device->flash_page_size; uint32_t flash_page_size = device->flash_page_size;
sprintf(variant_string, "%c\b%c\b%s %d F%d %s", snprintf(variant_string, sizeof(variant_string), "%c\b%c\b%s %d F%d %s",
di_version + 48, (uint8_t)device_index + 32, di_version + 48, (uint8_t)device_index + 32,
device->name, part_number, flash_kib, device->description); device->name, part_number, flash_kib, device->description);

View File

@ -364,7 +364,7 @@ static void samd_add_flash(target *t, uint32_t addr, size_t length)
target_add_flash(t, f); target_add_flash(t, f);
} }
char variant_string[40]; char variant_string[60];
bool samd_probe(target *t) bool samd_probe(target *t)
{ {
uint32_t cid = samd_read_cid(t); uint32_t cid = samd_read_cid(t);
@ -390,15 +390,15 @@ bool samd_probe(target *t)
/* Part String */ /* Part String */
if (protected) { if (protected) {
sprintf(variant_string, snprintf(variant_string, sizeof(variant_string),
"Atmel SAMD%d%c%dA%s (rev %c) (PROT=1)", "Atmel SAMD%d%c%dA%s (rev %c) (PROT=1)",
samd.series, samd.pin, samd.mem, samd.series, samd.pin, samd.mem,
samd.package, samd.revision); samd.package, samd.revision);
} else { } else {
sprintf(variant_string, snprintf(variant_string, sizeof(variant_string),
"Atmel SAMD%d%c%dA%s (rev %c)", "Atmel SAMD%d%c%dA%s (rev %c)",
samd.series, samd.pin, samd.mem, samd.series, samd.pin, samd.mem,
samd.package, samd.revision); samd.package, samd.revision);
} }
/* Setup Target */ /* Setup Target */