summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2020-07-23 01:39:15 +0700
committerhathach <[email protected]>2020-07-23 01:39:15 +0700
commit0407cfe16c7b9736da2ff36c69232e7c3f470864 (patch)
treef081ff213fcc5763534bf2633bab2b4ec511624f
parent7d2fc124452d6ec2d5d45bdacc4fc8b38d03d0d0 (diff)
fix samd21 race condition with setup packet
reproduced with Adafruit_TinyUSB_ArduinoCore port commit 11d669b4d2a40eb2fc5e51b2a9707a6de9d42363 and SAMD BSP 1.6.1
-rw-r--r--examples/make.mk54
-rw-r--r--hw/bsp/feather_m0_express/board.mk10
-rw-r--r--hw/bsp/feather_m4_express/board.mk10
-rw-r--r--hw/bsp/itsybitsy_m0/board.mk10
-rw-r--r--hw/bsp/itsybitsy_m4/board.mk10
-rw-r--r--hw/bsp/metro_m0_express/board.mk10
-rw-r--r--hw/bsp/metro_m4_express/board.mk10
-rw-r--r--src/portable/microchip/samd/dcd_samd.c2
8 files changed, 76 insertions, 40 deletions
diff --git a/examples/make.mk b/examples/make.mk
index 2ea50753b..b7917987e 100644
--- a/examples/make.mk
+++ b/examples/make.mk
@@ -46,31 +46,32 @@ SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/hw/bsp/$(BOARD)/*.c))
# Compiler Flags
CFLAGS += \
- -fdata-sections \
- -ffunction-sections \
- -fsingle-precision-constant \
- -fno-strict-aliasing \
- -Wdouble-promotion \
- -Wstrict-prototypes \
- -Wall \
- -Wextra \
- -Werror \
- -Wfatal-errors \
- -Werror-implicit-function-declaration \
- -Wfloat-equal \
- -Wundef \
- -Wshadow \
- -Wwrite-strings \
- -Wsign-compare \
- -Wmissing-format-attribute \
- -Wunreachable-code \
- -Wcast-align
-
+ -ggdb \
+ -fdata-sections \
+ -ffunction-sections \
+ -fsingle-precision-constant \
+ -fno-strict-aliasing \
+ -Wdouble-promotion \
+ -Wstrict-prototypes \
+ -Wall \
+ -Wextra \
+ -Werror \
+ -Wfatal-errors \
+ -Werror-implicit-function-declaration \
+ -Wfloat-equal \
+ -Wundef \
+ -Wshadow \
+ -Wwrite-strings \
+ -Wsign-compare \
+ -Wmissing-format-attribute \
+ -Wunreachable-code \
+ -Wcast-align
+
# Debugging/Optimization
ifeq ($(DEBUG), 1)
- CFLAGS += -Og -ggdb
+ CFLAGS += -Og
else
- CFLAGS += -Os
+ CFLAGS += -Os
endif
# Log level is mapped to TUSB DEBUG option
@@ -80,14 +81,11 @@ endif
# Logger: default is uart, can be set to rtt or swo
ifeq ($(LOGGER),rtt)
- RTT_SRC = lib/SEGGER_RTT
-
- CFLAGS += -DLOGGER_RTT -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
+ RTT_SRC = lib/SEGGER_RTT
+ CFLAGS += -DLOGGER_RTT -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
INC += $(TOP)/$(RTT_SRC)/RTT
SRC_C += $(RTT_SRC)/RTT/SEGGER_RTT_printf.c
SRC_C += $(RTT_SRC)/RTT/SEGGER_RTT.c
-
else ifeq ($(LOGGER),swo)
- CFLAGS += -DLOGGER_SWO
-
+ CFLAGS += -DLOGGER_SWO
endif
diff --git a/hw/bsp/feather_m0_express/board.mk b/hw/bsp/feather_m0_express/board.mk
index d762c4eca..7b6891e03 100644
--- a/hw/bsp/feather_m0_express/board.mk
+++ b/hw/bsp/feather_m0_express/board.mk
@@ -41,5 +41,11 @@ FREERTOS_PORT = ARM_CM0
JLINK_DEVICE = ATSAMD21G18
JLINK_IF = swd
-# flash using jlink
-flash: flash-jlink
+# flash using bossac at least version 1.8
+# can be found in arduino15/packages/arduino/tools/bossac/
+# Add it to your PATH or change BOSSAC variable to match your installation
+BOSSAC = bossac
+
+flash: $(BUILD)/$(BOARD)-firmware.bin
+ @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
+ $(BOSSAC) --port=$(SERIAL) -U -i --offset=0x2000 -e -w $^ -R
diff --git a/hw/bsp/feather_m4_express/board.mk b/hw/bsp/feather_m4_express/board.mk
index 49c2d7f2f..34c98597c 100644
--- a/hw/bsp/feather_m4_express/board.mk
+++ b/hw/bsp/feather_m4_express/board.mk
@@ -44,5 +44,11 @@ FREERTOS_PORT = ARM_CM4F
JLINK_DEVICE = ATSAMD51J19
JLINK_IF = swd
-# flash using jlink
-flash: flash-jlink
+# flash using bossac at least version 1.8
+# can be found in arduino15/packages/arduino/tools/bossac/
+# Add it to your PATH or change BOSSAC variable to match your installation
+BOSSAC = bossac
+
+flash: $(BUILD)/$(BOARD)-firmware.bin
+ @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
+ $(BOSSAC) --port=$(SERIAL) -U -i --offset=0x4000 -e -w $^ -R
diff --git a/hw/bsp/itsybitsy_m0/board.mk b/hw/bsp/itsybitsy_m0/board.mk
index d762c4eca..7b6891e03 100644
--- a/hw/bsp/itsybitsy_m0/board.mk
+++ b/hw/bsp/itsybitsy_m0/board.mk
@@ -41,5 +41,11 @@ FREERTOS_PORT = ARM_CM0
JLINK_DEVICE = ATSAMD21G18
JLINK_IF = swd
-# flash using jlink
-flash: flash-jlink
+# flash using bossac at least version 1.8
+# can be found in arduino15/packages/arduino/tools/bossac/
+# Add it to your PATH or change BOSSAC variable to match your installation
+BOSSAC = bossac
+
+flash: $(BUILD)/$(BOARD)-firmware.bin
+ @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
+ $(BOSSAC) --port=$(SERIAL) -U -i --offset=0x2000 -e -w $^ -R
diff --git a/hw/bsp/itsybitsy_m4/board.mk b/hw/bsp/itsybitsy_m4/board.mk
index 49c2d7f2f..34c98597c 100644
--- a/hw/bsp/itsybitsy_m4/board.mk
+++ b/hw/bsp/itsybitsy_m4/board.mk
@@ -44,5 +44,11 @@ FREERTOS_PORT = ARM_CM4F
JLINK_DEVICE = ATSAMD51J19
JLINK_IF = swd
-# flash using jlink
-flash: flash-jlink
+# flash using bossac at least version 1.8
+# can be found in arduino15/packages/arduino/tools/bossac/
+# Add it to your PATH or change BOSSAC variable to match your installation
+BOSSAC = bossac
+
+flash: $(BUILD)/$(BOARD)-firmware.bin
+ @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
+ $(BOSSAC) --port=$(SERIAL) -U -i --offset=0x4000 -e -w $^ -R
diff --git a/hw/bsp/metro_m0_express/board.mk b/hw/bsp/metro_m0_express/board.mk
index d762c4eca..7b6891e03 100644
--- a/hw/bsp/metro_m0_express/board.mk
+++ b/hw/bsp/metro_m0_express/board.mk
@@ -41,5 +41,11 @@ FREERTOS_PORT = ARM_CM0
JLINK_DEVICE = ATSAMD21G18
JLINK_IF = swd
-# flash using jlink
-flash: flash-jlink
+# flash using bossac at least version 1.8
+# can be found in arduino15/packages/arduino/tools/bossac/
+# Add it to your PATH or change BOSSAC variable to match your installation
+BOSSAC = bossac
+
+flash: $(BUILD)/$(BOARD)-firmware.bin
+ @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
+ $(BOSSAC) --port=$(SERIAL) -U -i --offset=0x2000 -e -w $^ -R
diff --git a/hw/bsp/metro_m4_express/board.mk b/hw/bsp/metro_m4_express/board.mk
index 49c2d7f2f..34c98597c 100644
--- a/hw/bsp/metro_m4_express/board.mk
+++ b/hw/bsp/metro_m4_express/board.mk
@@ -44,5 +44,11 @@ FREERTOS_PORT = ARM_CM4F
JLINK_DEVICE = ATSAMD51J19
JLINK_IF = swd
-# flash using jlink
-flash: flash-jlink
+# flash using bossac at least version 1.8
+# can be found in arduino15/packages/arduino/tools/bossac/
+# Add it to your PATH or change BOSSAC variable to match your installation
+BOSSAC = bossac
+
+flash: $(BUILD)/$(BOARD)-firmware.bin
+ @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
+ $(BOSSAC) --port=$(SERIAL) -U -i --offset=0x4000 -e -w $^ -R
diff --git a/src/portable/microchip/samd/dcd_samd.c b/src/portable/microchip/samd/dcd_samd.c
index 45bff2511..d0cc8560a 100644
--- a/src/portable/microchip/samd/dcd_samd.c
+++ b/src/portable/microchip/samd/dcd_samd.c
@@ -43,6 +43,8 @@ static inline void prepare_setup(void)
{
// Only make sure the EP0 OUT buffer is ready
sram_registers[0][0].ADDR.reg = (uint32_t) _setup_packet;
+ sram_registers[0][0].PCKSIZE.bit.MULTI_PACKET_SIZE = sizeof(_setup_packet);
+ sram_registers[0][0].PCKSIZE.bit.BYTE_COUNT = 0;
}
// Setup the control endpoint 0.