Merge commit '443ced62d4e47d73da13746a836369d8421b4fe8' into sam-update
# Conflicts: # libopencm3
This commit is contained in:
commit
81bb75bba6
7
Makefile
7
Makefile
@ -4,15 +4,18 @@ Q := @
|
||||
endif
|
||||
|
||||
PC_HOSTED =
|
||||
NO_LIBOPENCM3 =
|
||||
ifeq ($(PROBE_HOST), libftdi)
|
||||
PC_HOSTED = true
|
||||
NO_LIBOPENCM3 = true
|
||||
endif
|
||||
ifeq ($(PROBE_HOST), pc-stlinkv2)
|
||||
PC_HOSTED = true
|
||||
NO_LIBOPENCM3 = true
|
||||
endif
|
||||
|
||||
all:
|
||||
ifndef PC_HOSTED
|
||||
ifndef NO_LIBOPENCM3
|
||||
$(Q)if [ ! -f libopencm3/Makefile ]; then \
|
||||
echo "Initialising git submodules..." ;\
|
||||
git submodule init ;\
|
||||
@ -23,7 +26,7 @@ endif
|
||||
$(Q)$(MAKE) $(MFLAGS) -C src
|
||||
|
||||
clean:
|
||||
ifndef PC_HOSTED
|
||||
ifndef NO_LIBOPENCM3
|
||||
$(Q)$(MAKE) $(MFLAGS) -C libopencm3 $@
|
||||
endif
|
||||
$(Q)$(MAKE) $(MFLAGS) -C src $@
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 46e315bf2b3da94dbaec7671541e8ad2b2f87a75
|
||||
Subproject commit f86c46467d94c0160c2f58044675e42f1a8fdb7c
|
15
src/Makefile
15
src/Makefile
@ -8,12 +8,9 @@ MAKEFLAGS += --no-print-dir
|
||||
Q := @
|
||||
endif
|
||||
|
||||
OPT_FLAGS ?= -O2
|
||||
|
||||
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)
|
||||
LDFLAGS += $(OPT_FLAGS)
|
||||
|
||||
ifeq ($(ENABLE_DEBUG), 1)
|
||||
CFLAGS += -DENABLE_DEBUG -g3 -ggdb
|
||||
@ -60,6 +57,10 @@ SRC = \
|
||||
|
||||
include $(PLATFORM_DIR)/Makefile.inc
|
||||
|
||||
OPT_FLAGS ?= -O2
|
||||
CFLAGS += $(OPT_FLAGS)
|
||||
LDFLAGS += $(OPT_FLAGS)
|
||||
|
||||
ifndef TARGET
|
||||
TARGET=blackmagic
|
||||
endif
|
||||
@ -72,7 +73,7 @@ ifndef OWN_HL
|
||||
SRC += jtag_scan.c jtagtap.c swdptap.c
|
||||
endif
|
||||
|
||||
OBJ = $(SRC:.c=.o)
|
||||
OBJ = $(patsubst %.S,%.o,$(patsubst %.c,%.o,$(SRC)))
|
||||
|
||||
$(TARGET): include/version.h $(OBJ)
|
||||
@echo " LD $@"
|
||||
@ -82,6 +83,10 @@ $(TARGET): include/version.h $(OBJ)
|
||||
@echo " CC $<"
|
||||
$(Q)$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
%.o: %.S
|
||||
@echo " AS $<"
|
||||
$(Q)$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
%.bin: %
|
||||
@echo " OBJCOPY $@"
|
||||
$(Q)$(OBJCOPY) $(OBJCOPY_FLAGS) -O binary $^ $@
|
||||
|
@ -120,7 +120,7 @@ void gdb_putpacket(const char *packet, int size)
|
||||
}
|
||||
}
|
||||
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[1], 1);
|
||||
#ifdef DEBUG_GDBPACKET
|
||||
|
@ -21,7 +21,7 @@
|
||||
#ifndef __GDB_IF_H
|
||||
#define __GDB_IF_H
|
||||
|
||||
#if !defined(PC_HOSTED)
|
||||
#if !defined(NO_LIBOPENCM3)
|
||||
#include <libopencm3/usb/usbd.h>
|
||||
void gdb_usb_out_cb(usbd_device *dev, uint8_t ep);
|
||||
#endif
|
||||
|
@ -423,7 +423,7 @@ static void dfu_detach_complete(usbd_device *dev, struct usb_setup_data *req)
|
||||
#endif
|
||||
}
|
||||
|
||||
static int cdcacm_control_request(usbd_device *dev,
|
||||
static enum usbd_request_return_codes cdcacm_control_request(usbd_device *dev,
|
||||
struct usb_setup_data *req, uint8_t **buf, uint16_t *len,
|
||||
void (**complete)(usbd_device *dev, struct usb_setup_data *req))
|
||||
{
|
||||
@ -437,23 +437,23 @@ static int cdcacm_control_request(usbd_device *dev,
|
||||
cdcacm_set_modem_state(dev, req->wIndex, true, true);
|
||||
/* Ignore if not for GDB interface */
|
||||
if(req->wIndex != 0)
|
||||
return 1;
|
||||
return USBD_REQ_HANDLED;
|
||||
|
||||
cdcacm_gdb_dtr = req->wValue & 1;
|
||||
|
||||
return 1;
|
||||
return USBD_REQ_HANDLED;
|
||||
case USB_CDC_REQ_SET_LINE_CODING:
|
||||
if(*len < sizeof(struct usb_cdc_line_coding))
|
||||
return 0;
|
||||
return USBD_REQ_NOTSUPP;
|
||||
|
||||
switch(req->wIndex) {
|
||||
case 2:
|
||||
usbuart_set_line_coding((struct usb_cdc_line_coding*)*buf);
|
||||
return 1;
|
||||
return USBD_REQ_HANDLED;
|
||||
case 0:
|
||||
return 1; /* Ignore on GDB Port */
|
||||
return USBD_REQ_HANDLED; /* Ignore on GDB Port */
|
||||
default:
|
||||
return 0;
|
||||
return USBD_REQ_NOTSUPP;
|
||||
}
|
||||
case DFU_GETSTATUS:
|
||||
if(req->wIndex == DFU_IF_NO) {
|
||||
@ -465,17 +465,17 @@ static int cdcacm_control_request(usbd_device *dev,
|
||||
(*buf)[5] = 0; /* iString not used here */
|
||||
*len = 6;
|
||||
|
||||
return 1;
|
||||
return USBD_REQ_HANDLED;
|
||||
}
|
||||
return 0;
|
||||
return USBD_REQ_NOTSUPP;
|
||||
case DFU_DETACH:
|
||||
if(req->wIndex == DFU_IF_NO) {
|
||||
*complete = dfu_detach_complete;
|
||||
return 1;
|
||||
return USBD_REQ_HANDLED;
|
||||
}
|
||||
return 0;
|
||||
return USBD_REQ_NOTSUPP;
|
||||
}
|
||||
return 0;
|
||||
return USBD_REQ_NOTSUPP;
|
||||
}
|
||||
|
||||
int cdcacm_get_config(void)
|
||||
|
@ -62,7 +62,7 @@ void platform_init(void)
|
||||
scb_reset_core();
|
||||
}
|
||||
|
||||
rcc_clock_setup_hse_3v3(&rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_48MHZ]);
|
||||
rcc_clock_setup_pll(&rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_168MHZ]);
|
||||
|
||||
/* Enable peripherals */
|
||||
rcc_periph_clock_enable(RCC_OTGFS);
|
||||
|
@ -46,7 +46,7 @@ void platform_init(void)
|
||||
scb_reset_core();
|
||||
}
|
||||
|
||||
rcc_clock_setup_hse_3v3(&rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_48MHZ]);
|
||||
rcc_clock_setup_pll(&rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_168MHZ]);
|
||||
|
||||
/* Enable peripherals */
|
||||
rcc_peripheral_enable_clock(&RCC_AHB2ENR, RCC_AHB2ENR_OTGFSEN);
|
||||
|
@ -143,10 +143,8 @@ static const char *usb_strings[] = {
|
||||
//"@Internal Flash /0x00000000/1*0016Ka,15*0016Kg",
|
||||
};
|
||||
|
||||
static uint8_t usbdfu_getstatus(usbd_device *usbd_dev, uint32_t *bwPollTimeout)
|
||||
static uint8_t usbdfu_getstatus(uint32_t *bwPollTimeout)
|
||||
{
|
||||
(void)usbd_dev;
|
||||
|
||||
switch (usbdfu_state) {
|
||||
case STATE_DFU_DNLOAD_SYNC:
|
||||
usbdfu_state = STATE_DFU_DNBUSY;
|
||||
@ -225,9 +223,12 @@ static void usbdfu_getstatus_complete(usbd_device *usbd_dev, struct usb_setup_da
|
||||
}
|
||||
}
|
||||
|
||||
static int usbdfu_control_request(usbd_device *usbd_dev, struct usb_setup_data *req, uint8_t **buf,
|
||||
uint16_t *len, void (**complete)(usbd_device *usbd_dev, struct usb_setup_data *req))
|
||||
static enum usbd_request_return_codes usbdfu_control_request(usbd_device *dev,
|
||||
struct usb_setup_data *req, uint8_t **buf, uint16_t *len,
|
||||
void (**complete)(usbd_device *dev, struct usb_setup_data *req))
|
||||
{
|
||||
(void)dev;
|
||||
|
||||
if ((req->bmRequestType & 0x7F) != 0x21)
|
||||
return 0; /* Only accept class request. */
|
||||
|
||||
@ -258,7 +259,7 @@ static int usbdfu_control_request(usbd_device *usbd_dev, struct usb_setup_data *
|
||||
return 0;
|
||||
case DFU_GETSTATUS: {
|
||||
uint32_t bwPollTimeout = 0; /* 24-bit integer in DFU class spec */
|
||||
(*buf)[0] = usbdfu_getstatus(usbd_dev, &bwPollTimeout);
|
||||
(*buf)[0] = usbdfu_getstatus(&bwPollTimeout);
|
||||
(*buf)[1] = bwPollTimeout & 0xFF;
|
||||
(*buf)[2] = (bwPollTimeout >> 8) & 0xFF;
|
||||
(*buf)[3] = (bwPollTimeout >> 16) & 0xFF;
|
||||
|
@ -68,7 +68,7 @@ extern uint8_t running_status;
|
||||
gpio_set_output_config(SWDIO_PORT, GPIO_OTYPE_PP, GPIO_DRIVE_2MA, SWDIO_PIN); \
|
||||
}
|
||||
|
||||
extern usbd_driver lm4f_usb_driver;
|
||||
extern const usbd_driver lm4f_usb_driver;
|
||||
#define USB_DRIVER lm4f_usb_driver
|
||||
#define USB_IRQ NVIC_USB0_IRQ
|
||||
#define USB_ISR usb0_isr
|
||||
|
@ -1,5 +1,5 @@
|
||||
SYS = $(shell $(CC) -dumpmachine)
|
||||
CFLAGS += -DPC_HOSTED -DENABLE_DEBUG
|
||||
CFLAGS += -DPC_HOSTED -DNO_LIBOPENCM3 -DENABLE_DEBUG
|
||||
LDFLAGS += -lftdi1
|
||||
ifneq (, $(findstring mingw, $(SYS)))
|
||||
LDFLAGS += -lusb-1.0 -lws2_32
|
||||
|
@ -1,6 +1,6 @@
|
||||
TARGET=blackmagic_stlinkv2
|
||||
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
|
||||
LDFLAGS += -lusb-1.0
|
||||
ifneq (, $(findstring mingw, $(SYS)))
|
||||
|
@ -25,5 +25,5 @@ MEMORY
|
||||
}
|
||||
|
||||
/* Include the common ld script from libopenstm32. */
|
||||
INCLUDE libopencm3_stm32f1.ld
|
||||
INCLUDE cortex-m-generic.ld
|
||||
|
||||
|
@ -198,20 +198,20 @@ usbdfu_getstatus_complete(usbd_device *dev, struct usb_setup_data *req)
|
||||
}
|
||||
}
|
||||
|
||||
static int usbdfu_control_request(usbd_device *dev,
|
||||
static enum usbd_request_return_codes usbdfu_control_request(usbd_device *dev,
|
||||
struct usb_setup_data *req, uint8_t **buf, uint16_t *len,
|
||||
void (**complete)(usbd_device *dev, struct usb_setup_data *req))
|
||||
{
|
||||
(void)dev;
|
||||
|
||||
if((req->bmRequestType & 0x7F) != 0x21)
|
||||
return 0; /* Only accept class request */
|
||||
return USBD_REQ_NOTSUPP; /* Only accept class request */
|
||||
|
||||
switch(req->bRequest) {
|
||||
case DFU_DNLOAD:
|
||||
if((len == NULL) || (*len == 0)) {
|
||||
usbdfu_state = STATE_DFU_MANIFEST_SYNC;
|
||||
return 1;
|
||||
return USBD_REQ_HANDLED;
|
||||
} else {
|
||||
/* Copy download data for use on GET_STATUS */
|
||||
prog.blocknum = req->wValue;
|
||||
@ -222,22 +222,22 @@ static int usbdfu_control_request(usbd_device *dev,
|
||||
if ((addr < app_address) || (addr >= max_address)) {
|
||||
current_error = DFU_STATUS_ERR_TARGET;
|
||||
usbdfu_state = STATE_DFU_ERROR;
|
||||
return 1;
|
||||
return USBD_REQ_HANDLED;
|
||||
} else
|
||||
prog.addr = addr;
|
||||
}
|
||||
usbdfu_state = STATE_DFU_DNLOAD_SYNC;
|
||||
return 1;
|
||||
return USBD_REQ_HANDLED;
|
||||
}
|
||||
case DFU_CLRSTATUS:
|
||||
/* Clear error and return to dfuIDLE */
|
||||
if(usbdfu_state == STATE_DFU_ERROR)
|
||||
usbdfu_state = STATE_DFU_IDLE;
|
||||
return 1;
|
||||
return USBD_REQ_HANDLED;
|
||||
case DFU_ABORT:
|
||||
/* Abort returns to dfuIDLE state */
|
||||
usbdfu_state = STATE_DFU_IDLE;
|
||||
return 1;
|
||||
return USBD_REQ_HANDLED;
|
||||
case DFU_UPLOAD:
|
||||
if ((usbdfu_state == STATE_DFU_IDLE) ||
|
||||
(usbdfu_state == STATE_DFU_DNLOAD_IDLE) ||
|
||||
@ -250,10 +250,10 @@ static int usbdfu_control_request(usbd_device *dev,
|
||||
dfu_function.wTransferSize);
|
||||
memcpy(*buf, (void*)baseaddr, *len);
|
||||
}
|
||||
return 1;
|
||||
return USBD_REQ_HANDLED;
|
||||
} else {
|
||||
usbd_ep_stall_set(dev, 0, 1);
|
||||
return 0;
|
||||
return USBD_REQ_NOTSUPP;
|
||||
}
|
||||
case DFU_GETSTATUS: {
|
||||
uint32_t bwPollTimeout = 0; /* 24-bit integer in DFU class spec */
|
||||
@ -268,16 +268,16 @@ static int usbdfu_control_request(usbd_device *dev,
|
||||
|
||||
*complete = usbdfu_getstatus_complete;
|
||||
|
||||
return 1;
|
||||
return USBD_REQ_HANDLED;
|
||||
}
|
||||
case DFU_GETSTATE:
|
||||
/* Return state with no state transision */
|
||||
*buf[0] = usbdfu_state;
|
||||
*len = 1;
|
||||
return 1;
|
||||
return USBD_REQ_HANDLED;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return USBD_REQ_NOTSUPP;
|
||||
}
|
||||
|
||||
void dfu_init(const usbd_driver *driver, dfu_mode_t mode)
|
||||
|
@ -25,5 +25,5 @@ MEMORY
|
||||
}
|
||||
|
||||
/* Include the common ld script from libopenstm32. */
|
||||
INCLUDE libopencm3_stm32f4.ld
|
||||
INCLUDE cortex-m-generic.ld
|
||||
|
||||
|
@ -25,4 +25,4 @@ MEMORY
|
||||
}
|
||||
|
||||
/* Include the common ld script from libopenstm32. */
|
||||
INCLUDE libopencm3_stm32f1.ld
|
||||
INCLUDE cortex-m-generic.ld
|
||||
|
@ -25,4 +25,4 @@ MEMORY
|
||||
}
|
||||
|
||||
/* Include the common ld script from libopenstm32. */
|
||||
INCLUDE libopencm3_stm32f1.ld
|
||||
INCLUDE cortex-m-generic.ld
|
||||
|
@ -42,8 +42,6 @@ void traceswo_init(void)
|
||||
{
|
||||
TRACE_TIM_CLK_EN();
|
||||
|
||||
timer_reset(TRACE_TIM);
|
||||
|
||||
/* Refer to ST doc RM0008 - STM32F10xx Reference Manual.
|
||||
* Section 14.3.4 - 14.3.6 (General Purpose Timer - Input Capture)
|
||||
*
|
||||
|
@ -68,7 +68,6 @@ void usbuart_init(void)
|
||||
|
||||
/* Setup timer for running deferred FIFO processing */
|
||||
USBUSART_TIM_CLK_EN();
|
||||
timer_reset(USBUSART_TIM);
|
||||
timer_set_mode(USBUSART_TIM, TIM_CR1_CKD_CK_INT,
|
||||
TIM_CR1_CMS_EDGE, TIM_CR1_DIR_UP);
|
||||
timer_set_prescaler(USBUSART_TIM,
|
||||
|
@ -25,5 +25,5 @@ MEMORY
|
||||
}
|
||||
|
||||
/* Include the common ld script from libopenstm32. */
|
||||
INCLUDE libopencm3_lm4f.ld
|
||||
INCLUDE cortex-m-generic.ld
|
||||
|
||||
|
@ -611,7 +611,7 @@ bool efm32_probe(target *t)
|
||||
uint32_t ram_size = ram_kib * 0x400;
|
||||
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,
|
||||
device->name, part_number, flash_kib, device->description);
|
||||
|
||||
|
@ -364,7 +364,7 @@ static void samd_add_flash(target *t, uint32_t addr, size_t length)
|
||||
target_add_flash(t, f);
|
||||
}
|
||||
|
||||
char variant_string[40];
|
||||
char variant_string[60];
|
||||
bool samd_probe(target *t)
|
||||
{
|
||||
uint32_t cid = samd_read_cid(t);
|
||||
@ -390,15 +390,15 @@ bool samd_probe(target *t)
|
||||
|
||||
/* Part String */
|
||||
if (protected) {
|
||||
sprintf(variant_string,
|
||||
"Atmel SAMD%d%c%dA%s (rev %c) (PROT=1)",
|
||||
samd.series, samd.pin, samd.mem,
|
||||
samd.package, samd.revision);
|
||||
snprintf(variant_string, sizeof(variant_string),
|
||||
"Atmel SAMD%d%c%dA%s (rev %c) (PROT=1)",
|
||||
samd.series, samd.pin, samd.mem,
|
||||
samd.package, samd.revision);
|
||||
} else {
|
||||
sprintf(variant_string,
|
||||
"Atmel SAMD%d%c%dA%s (rev %c)",
|
||||
samd.series, samd.pin, samd.mem,
|
||||
samd.package, samd.revision);
|
||||
snprintf(variant_string, sizeof(variant_string),
|
||||
"Atmel SAMD%d%c%dA%s (rev %c)",
|
||||
samd.series, samd.pin, samd.mem,
|
||||
samd.package, samd.revision);
|
||||
}
|
||||
|
||||
/* Setup Target */
|
||||
|
Loading…
x
Reference in New Issue
Block a user