Skip to content

Commit 195de97

Browse files
committed
use only one endpoint pair for MSC except on SAMD21
1 parent 95a5a57 commit 195de97

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

ports/atmel-samd/mpconfigport.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ ifeq ($(CHIP_FAMILY),samd21)
1919
# frequencyio not yet verified as working on SAMD21.
2020
CIRCUITPY_FREQUENCYIO = 0
2121
CIRCUITPY_TOUCHIO_USE_NATIVE = 1
22+
23+
# SAMD21 needs separate endpoint pairs for MSC BULK IN and BULK OUT, otherwise it's erratic.
24+
USB_MSC_NUM_ENDPOINT_PAIRS = 2
2225
endif
2326

2427
# Put samd51-only choices here.

supervisor/supervisor.mk

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ ifndef USB_HID_DEVICES
8989
USB_HID_DEVICES = "KEYBOARD,MOUSE,CONSUMER,GAMEPAD"
9090
endif
9191

92+
# SAMD21 needs separate endpoint pairs for MSC BULK IN and BULK OUT, otherwise it's erratic.
93+
ifndef USB_MSC_NUM_ENDPOINT_PAIRS
94+
USB_MSC_NUM_ENDPOINT_PAIRS = 1
95+
endif
96+
9297
SUPERVISOR_O = $(addprefix $(BUILD)/, $(SRC_SUPERVISOR:.c=.o)) $(BUILD)/autogen_display_resources.o
9398

9499
$(BUILD)/supervisor/shared/translate.o: $(HEADER_BUILD)/qstrdefs.generated.h
@@ -106,8 +111,9 @@ autogen_usb_descriptor.intermediate: ../../tools/gen_usb_descriptor.py Makefile
106111
--vid $(USB_VID)\
107112
--pid $(USB_PID)\
108113
--serial_number_length $(USB_SERIAL_NUMBER_LENGTH)\
109-
--devices $(USB_DEVICES) \
110-
--hid_devices $(USB_HID_DEVICES) \
114+
--devices $(USB_DEVICES)\
115+
--hid_devices $(USB_HID_DEVICES)\
116+
--msc_num_endpoint_pairs $(USB_MSC_NUM_ENDPOINT_PAIRS)\
111117
--output_c_file $(BUILD)/autogen_usb_descriptor.c\
112118
--output_h_file $(BUILD)/genhdr/autogen_usb_descriptor.h
113119

tools/gen_usb_descriptor.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
help='devices to include in descriptor (AUDIO includes MIDI support)')
3333
parser.add_argument('--hid_devices', type=lambda l: tuple(l.split(',')), default=DEFAULT_HID_DEVICES,
3434
help='HID devices to include in HID report descriptor')
35+
parser.add_argument('--msc_num_endpoint_pairs', type=int, default=1,
36+
help='Use 1 or 2 endpoint pairs for MSC (1 bidirectional, or 1 input + 1 output (required by SAMD21))')
3537
parser.add_argument('--output_c_file', type=argparse.FileType('w'), required=True)
3638
parser.add_argument('--output_h_file', type=argparse.FileType('w'), required=True)
3739

@@ -45,6 +47,9 @@
4547
if unknown_hid_devices:
4648
raise ValueError("Unknown HID devices(s)", unknown_hid_devices)
4749

50+
if args.msc_num_endpoint_pairs not in (1, 2):
51+
raise ValueError("--msc_num_endpoint_pairs must be 1 or 2")
52+
4853

4954
class StringIndex:
5055
"""Assign a monotonically increasing index to each unique string. Start with 0."""
@@ -153,7 +158,9 @@ def strings_in_order(cls):
153158
bInterval=0),
154159
standard.EndpointDescriptor(
155160
description="MSC out",
156-
bEndpointAddress=0x1 | standard.EndpointDescriptor.DIRECTION_OUT,
161+
# SAMD21 needs to use a separate pair of endpoints for MSC.
162+
bEndpointAddress=((0x1 if args.msc_num_endpoint_pairs == 2 else 0x0) |
163+
standard.EndpointDescriptor.DIRECTION_OUT),
157164
bmAttributes=standard.EndpointDescriptor.TYPE_BULK,
158165
bInterval=0)
159166
]

0 commit comments

Comments
 (0)