summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Banks <kevin@firia.com>2021-01-26 20:43:19 -0600
committerKevin Banks <kevin@firia.com>2021-01-26 20:43:19 -0600
commit1b031508e14a3cdfa2ba9c5cf158126d3f002cba (patch)
tree167879fa90b7f2a93a3083238b172e9d57bac92b
parentb152c658e2538f2e2cb6c760c4b4dab6bb6cf357 (diff)
BOS and MS_OS_2.0 descriptors have been added. Still more descriptor work TODO.
-rw-r--r--supervisor/shared/usb/usb.c7
-rw-r--r--tools/gen_usb_descriptor.py74
2 files changed, 62 insertions, 19 deletions
diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c
index 9b0cba8da..5db90d2fa 100644
--- a/supervisor/shared/usb/usb.c
+++ b/supervisor/shared/usb/usb.c
@@ -43,13 +43,6 @@
// The WebUSB support being conditionally added to this file is based on the
// tinyusb demo examples/device/webusb_serial.
-enum
-{
- VENDOR_REQUEST_WEBUSB = 1,
- VENDOR_REQUEST_MICROSOFT = 2
-};
-
-extern uint8_t const desc_ms_os_20[];
extern const tusb_desc_webusb_url_t desc_webusb_url;
static bool web_serial_connected = false;
diff --git a/tools/gen_usb_descriptor.py b/tools/gen_usb_descriptor.py
index 86de86d1a..210ca1923 100644
--- a/tools/gen_usb_descriptor.py
+++ b/tools/gen_usb_descriptor.py
@@ -629,13 +629,21 @@ extern const uint8_t hid_report_descriptor[{hid_report_descriptor_length}];
msc_vendor=args.manufacturer[:8],
msc_product=args.product[:16]))
-# Currently getting compile-time errors in files like tusb_fifo.c
-# if we try do define this here (TODO figure this out!)
-#if 'VENDOR' in args.devices:
-# h_file.write("""\
-#extern const tusb_desc_webusb_url_t desc_webusb_url;
-#
-#""")
+if 'VENDOR' in args.devices:
+ h_file.write("""\
+enum
+{
+ VENDOR_REQUEST_WEBUSB = 1,
+ VENDOR_REQUEST_MICROSOFT = 2
+};
+
+extern uint8_t const desc_ms_os_20[];
+
+// Currently getting compile-time errors in files like tusb_fifo.c
+// if we try do define this here (TODO figure this out!)
+//extern const tusb_desc_webusb_url_t desc_webusb_url;
+
+""")
h_file.write("""\
#endif // MICROPY_INCLUDED_AUTOGEN_USB_DESCRIPTOR_H
@@ -711,7 +719,7 @@ c_file.write("""\
""")
if 'VENDOR' in args.devices:
- # Mimic what the tinyusb webusb demo does
+ # Mimic what the tinyusb webusb demo does in it's main.c file
c_file.write("""
#define URL "{webusb_url}"
@@ -723,13 +731,55 @@ const tusb_desc_webusb_url_t desc_webusb_url =
.url = URL
}};
-// This next hardcoded descriptor was pulled from the usb_descriptor.c file of the
-// tinyusb webusb_serial demo. TODO - this is probably something else to integrate
-// into the adafruit_usb_descriptors project, especially with this next #define..
-#define ITF_NUM_VENDOR 6 // SWAG for now.
+// These next two hardcoded descriptor were pulled from the usb_descriptor.c file
+// of the tinyusb webusb_serial demo. TODO - this is probably something else to
+// integrate into the adafruit_usb_descriptors project, especially with this next
+// #define..
+
+// SWAG for now. Will have to be manually corrected until generated by gen_usb_descriptor.py
+#define ITF_NUM_VENDOR 6i
+
+//--------------------------------------------------------------------+
+// BOS Descriptor
+//--------------------------------------------------------------------+
+
+/* Microsoft OS 2.0 registry property descriptor
+Per MS requirements https://msdn.microsoft.com/en-us/library/windows/hardware/hh450799(v=vs.85).aspx
+device should create DeviceInterfaceGUIDs. It can be done by driver and
+in case of real PnP solution device should expose MS "Microsoft OS 2.0
+registry property descriptor". Such descriptor can insert any record
+into Windows registry per device/configuration/interface. In our case it
+will insert "DeviceInterfaceGUIDs" multistring property.
+
+GUID is freshly generated and should be OK to use.
+
+https://developers.google.com/web/fundamentals/native-hardware/build-for-webusb/
+(Section Microsoft OS compatibility descriptors)
+*/
+
+#define BOS_TOTAL_LEN (TUD_BOS_DESC_LEN + TUD_BOS_WEBUSB_DESC_LEN + TUD_BOS_MICROSOFT_OS_DESC_LEN)
#define MS_OS_20_DESC_LEN 0xB2
+// BOS Descriptor is required for webUSB
+uint8_t const desc_bos[] =
+{{
+ // total length, number of device caps
+ TUD_BOS_DESCRIPTOR(BOS_TOTAL_LEN, 2),
+
+ // Vendor Code, iLandingPage
+ TUD_BOS_WEBUSB_DESCRIPTOR(VENDOR_REQUEST_WEBUSB, 1),
+
+ // Microsoft OS 2.0 descriptor
+ TUD_BOS_MS_OS_20_DESCRIPTOR(MS_OS_20_DESC_LEN, VENDOR_REQUEST_MICROSOFT)
+}};
+
+uint8_t const * tud_descriptor_bos_cb(void)
+{{
+ return desc_bos;
+}}
+
+
uint8_t const desc_ms_os_20[] =
{{
// Set header: length, type, windows version, total length