Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit 8d01dfb

Browse files
committed
Add Binary Object Store (BOS) descriptor support.
1 parent 3360abe commit 8d01dfb

4 files changed

Lines changed: 36 additions & 2 deletions

File tree

examples/boot-uf2-dfu/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ TARGET = boot-uf2-dfu
22
LIBRARIES = fx2 fx2usb fx2dfu fx2usbmassstor fx2uf2 fx2isrs
33
MODEL = medium
44

5-
CODE_SIZE ?= 0x3c00
6-
XRAM_SIZE ?= 0x0400
5+
CODE_SIZE ?= 0x3d00
6+
XRAM_SIZE ?= 0x0300
77

88
LIBFX2 = ../../firmware/library
99
include $(LIBFX2)/fx2rules.mk

firmware/library/include/fx2usb.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ struct usb_descriptor_set {
160160
usb_configuration_set_c *configs;
161161
uint8_t string_count;
162162
usb_ascii_string_c *strings;
163+
uint8_t capability_count;
164+
usb_desc_generic_c *capabilities;
163165
};
164166

165167
typedef __code const struct usb_descriptor_set

firmware/library/include/usb.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ enum usb_descriptor {
5454
USB_DESC_DEVICE_QUALIFIER = 6,
5555
USB_DESC_OTHER_SPEED_CONFIGURATION = 7,
5656
USB_DESC_INTERFACE_POWER = 8,
57+
USB_DESC_BINARY_OBJECT_STORE = 15,
58+
USB_DESC_DEVICE_CAPABILITY = 16,
59+
};
60+
61+
enum usb_device_capability {
62+
USB_DEV_CAP_PLATFORM = 5,
5763
};
5864

5965
enum usb_feature {
@@ -232,4 +238,14 @@ struct usb_desc_string {
232238
typedef __code const struct usb_desc_string
233239
usb_desc_string_c;
234240

241+
struct usb_desc_binary_object_store {
242+
uint8_t bLength;
243+
uint8_t bDescriptorType;
244+
uint16_t wTotalLength;
245+
uint8_t bNumDeviceCaps;
246+
};
247+
248+
typedef __code const struct usb_desc_binary_object_store
249+
usb_binary_object_store_c;
250+
235251
#endif

firmware/library/usb.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,22 @@ void usb_serve_descriptor(usb_descriptor_set_c *set,
213213
*buf++ = 0;
214214
scratch[0] += 2;
215215
}
216+
} else if(type == USB_DESC_BINARY_OBJECT_STORE && index == 0) {
217+
__xdata struct usb_desc_binary_object_store *bos_desc =
218+
(__xdata struct usb_desc_binary_object_store *)buf;
219+
bos_desc->bLength = sizeof(struct usb_desc_binary_object_store);
220+
bos_desc->bDescriptorType = USB_DESC_BINARY_OBJECT_STORE;
221+
// bos_desc->wTotalLength filled in later
222+
bos_desc->bNumDeviceCaps = set->capability_count;
223+
buf += bos_desc->bLength;
224+
__code const struct usb_desc_generic *dev_cap_desc = set->capabilities;
225+
for(uint8_t i = 0; i < set->capability_count; i++) {
226+
APPEND(dev_cap_desc);
227+
dev_cap_desc++;
228+
}
229+
bos_desc->wTotalLength = (uint16_t)(buf - scratch);
230+
SETUP_EP0_IN_DATA(scratch, bos_desc->wTotalLength);
231+
return;
216232
} else {
217233
STALL_EP0();
218234
return;

0 commit comments

Comments
 (0)