Skip to content

Commit 64e0958

Browse files
committed
wip: descriptor building
1 parent 6b18a51 commit 64e0958

File tree

20 files changed

+241
-154
lines changed

20 files changed

+241
-154
lines changed

ports/atmel-samd/common-hal/microcontroller/Processor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) {
346346

347347
for (int i=0; i<4; i++) {
348348
for (int k=0; k<4; k++) {
349-
raw_id[4 * i + k] = (*(id_addresses[i]) >> k * 8) & 0xff;
349+
raw_id[4 * i + (3 -k)] = (*(id_addresses[i]) >> k * 8) & 0xff;
350350
}
351351
}
352352
}

ports/atmel-samd/mpconfigport.mk

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ endif
2020

2121
INTERNAL_LIBM = 1
2222

23-
USB_SERIAL_NUMBER_LENGTH = 32
24-
2523
# Number of USB endpoint pairs.
2624
USB_NUM_EP = 8
2725

ports/cxd56/mpconfigport.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
USB_SERIAL_NUMBER_LENGTH = 10
21
USB_HIGHSPEED = 1
32
USB_RENUMBER_ENDPOINTS = 0
43
USB_CDC_EP_NUM_NOTIFICATION = 3

ports/esp32s2/mpconfigport.mk

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz
66
# Internal math library is substantially smaller than toolchain one
77
INTERNAL_LIBM = 1
88

9-
# Chip supplied serial number, in bytes
10-
USB_SERIAL_NUMBER_LENGTH = 12
11-
129
# Longints can be implemented as mpz, as longlong, or not
1310
LONGINT_IMPL = MPZ
1411

ports/litex/mpconfigport.mk

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ INTERNAL_LIBM = 1
99
# Number of USB endpoint pairs.
1010
USB_NUM_EP = 16
1111

12-
# Chip supplied serial number, in bytes
13-
USB_SERIAL_NUMBER_LENGTH = 30
14-
1512
# Longints can be implemented as mpz, as longlong, or not
1613
LONGINT_IMPL = MPZ
1714

ports/mimxrt10xx/mpconfigport.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ endif
1414

1515
INTERNAL_LIBM = 1
1616

17-
USB_SERIAL_NUMBER_LENGTH = 32
1817
USB_HIGHSPEED = 1
1918

2019
# Number of USB endpoint pairs.

ports/nrf/mpconfigport.mk

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz
99

1010
INTERNAL_LIBM = 1
1111

12-
USB_SERIAL_NUMBER_LENGTH = 16
13-
1412
# Number of USB endpoint pairs.
1513
USB_NUM_EP = 8
1614

ports/raspberrypi/mpconfigport.mk

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ CIRCUITPY_AUDIOMIXER ?= 0
4747

4848
INTERNAL_LIBM = 1
4949

50-
USB_SERIAL_NUMBER_LENGTH = 16
51-
5250
# Number of USB endpoint pairs.
5351
USB_NUM_EP = 8
5452

ports/stm/mpconfigport.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
MPY_TOOL_LONGINT_IMPL ?= -mlongint-impl=mpz
22
LONGINT_IMPL ?= MPZ
33
INTERNAL_LIBM ?= 1
4-
USB_SERIAL_NUMBER_LENGTH ?= 24
54

65
ifeq ($(MCU_VARIANT),$(filter $(MCU_VARIANT),STM32F405xx STM32F407xx))
76
CIRCUITPY_CANIO = 1

shared-module/storage/__init__.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static const uint8_t storage_usb_msc_descriptor_template[] = {
5858
// MSC Endpoint IN Descriptor
5959
0x07, // 9 bLength
6060
0x05, // 10 bDescriptorType (Endpoint)
61-
0xFF, // 11 bEndpointAddress (IN/D2H) [SET AT RUNTIME: 0x8 | number]
61+
0xFF, // 11 bEndpointAddress (IN/D2H) [SET AT RUNTIME: 0x80 | number]
6262
#define MSC_IN_ENDPOINT_INDEX 11
6363
0x02, // 12 bmAttributes (Bulk)
6464
0x40, 0x00, // 13,14 wMaxPacketSize 64
@@ -81,12 +81,21 @@ size_t storage_usb_descriptor_length(void) {
8181
return sizeof(usb_msc_descriptor);
8282
}
8383

84-
size_t storage_usb_add_descriptor(uint8_t *descriptor_buf, uint8_t interface_number, uint8_t in_endpoint, uint8_t out_endpoint, uint8_t interface_string) {
84+
static const char[] storage_interface_name = USB_INTERFACE_NAME " Mass Storage";
85+
86+
size_t storage_usb_add_descriptor(uint8_t *descriptor_buf, uint8_t *current_interface, uint8_t *current_endpoint, uint8_t* current_interface_string) {
8587
memcpy(descriptor_buf, storage_usb_msc_descriptor_template, sizeof(storage_usb_msc_descriptor_template));
86-
descriptor_buf[MSC_INTERFACE_INDEX] = interface_number;
87-
descriptor_buf[MSC_INTERFACE_STRING_INDEX] = interface_string;
88-
descriptor_buf[MSC_IN_ENDPOINT_INDEX] = in_endpoint_address;
89-
descriptor_buf[MSC_OUT_ENDPOINT_INDEX] = 0x80 | out_endpoint_address;
88+
descriptor_buf[MSC_INTERFACE_INDEX] = *current_interface;
89+
(*current_interface)++;
90+
91+
descriptor_buf[MSC_IN_ENDPOINT_INDEX] = USB_MSC_EP_NUM_IN ? USB_MSC_EP_NUM_IN : *current_endpoint;
92+
descriptor_buf[MSC_OUT_ENDPOINT_INDEX] = 0x80 | (USB_MSC_EP_NUM_OUT ? USB_MSC_EP_NUM_OUT : *current_endpoint);
93+
(*current_endpoint)++:
94+
95+
usb_add_interface_string(*current_interface_string,);
96+
descriptor_buf[MSC_INTERFACE_STRING_INDEX] = *current_interface_string;
97+
(*current_interface_string)++;
98+
9099
return sizeof(storage_usb_msc_descriptor_template);
91100
}
92101

0 commit comments

Comments
 (0)