diff options
| author | Kevin Banks <kevin@firia.com> | 2021-01-25 20:37:58 -0600 |
|---|---|---|
| committer | Kevin Banks <kevin@firia.com> | 2021-01-25 20:37:58 -0600 |
| commit | fbfb7b68cce3fbcccc423c1013c0c3cabe6a89d0 (patch) | |
| tree | 4b2dfe8eebef84fc24d1a9225aa5c4fa2b874488 /tools | |
| parent | 9ce33a5771cd6061e81aeaf2b1c4361490c36b08 (diff) | |
Most of the code we need has been pulled in from the tinyusb webusb_serial demo. Still LOTS to do regarding descriptors.
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/gen_usb_descriptor.py | 53 |
1 files changed, 48 insertions, 5 deletions
diff --git a/tools/gen_usb_descriptor.py b/tools/gen_usb_descriptor.py index 0f936597f..86de86d1a 100644 --- a/tools/gen_usb_descriptor.py +++ b/tools/gen_usb_descriptor.py @@ -484,6 +484,7 @@ h_file = args.output_h_file c_file.write("""\ #include <stdint.h> +#include "tusb.h" #include "py/objtuple.h" #include "shared-bindings/usb_hid/Device.h" #include "{H_FILE_NAME}" @@ -628,11 +629,13 @@ extern const uint8_t hid_report_descriptor[{hid_report_descriptor_length}]; msc_vendor=args.manufacturer[:8], msc_product=args.product[:16])) -if 'VENDOR' in args.devices: - h_file.write("""\ -extern const tusb_desc_webusb_url_t desc_webusb_url; - -""") +# 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; +# +#""") h_file.write("""\ #endif // MICROPY_INCLUDED_AUTOGEN_USB_DESCRIPTOR_H @@ -719,4 +722,44 @@ const tusb_desc_webusb_url_t desc_webusb_url = .bScheme = 1, // 0: http, 1: https, 255: "" .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. + +#define MS_OS_20_DESC_LEN 0xB2 + +uint8_t const desc_ms_os_20[] = +{{ + // Set header: length, type, windows version, total length + U16_TO_U8S_LE(0x000A), U16_TO_U8S_LE(MS_OS_20_SET_HEADER_DESCRIPTOR), U32_TO_U8S_LE(0x06030000), U16_TO_U8S_LE(MS_OS_20_DESC_LEN), + + // Configuration subset header: length, type, configuration index, reserved, configuration total length + U16_TO_U8S_LE(0x0008), U16_TO_U8S_LE(MS_OS_20_SUBSET_HEADER_CONFIGURATION), 0, 0, U16_TO_U8S_LE(MS_OS_20_DESC_LEN-0x0A), + + // Function Subset header: length, type, first interface, reserved, subset length + U16_TO_U8S_LE(0x0008), U16_TO_U8S_LE(MS_OS_20_SUBSET_HEADER_FUNCTION), ITF_NUM_VENDOR, 0, U16_TO_U8S_LE(MS_OS_20_DESC_LEN-0x0A-0x08), + + // MS OS 2.0 Compatible ID descriptor: length, type, compatible ID, sub compatible ID + U16_TO_U8S_LE(0x0014), U16_TO_U8S_LE(MS_OS_20_FEATURE_COMPATBLE_ID), 'W', 'I', 'N', 'U', 'S', 'B', 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // sub-compatible + + // MS OS 2.0 Registry property descriptor: length, type + U16_TO_U8S_LE(MS_OS_20_DESC_LEN-0x0A-0x08-0x08-0x14), U16_TO_U8S_LE(MS_OS_20_FEATURE_REG_PROPERTY), + U16_TO_U8S_LE(0x0007), U16_TO_U8S_LE(0x002A), // wPropertyDataType, wPropertyNameLength and PropertyName "DeviceInterfaceGUIDs\0" in UTF-16 + 'D', 0x00, 'e', 0x00, 'v', 0x00, 'i', 0x00, 'c', 0x00, 'e', 0x00, 'I', 0x00, 'n', 0x00, 't', 0x00, 'e', 0x00, + 'r', 0x00, 'f', 0x00, 'a', 0x00, 'c', 0x00, 'e', 0x00, 'G', 0x00, 'U', 0x00, 'I', 0x00, 'D', 0x00, 's', 0x00, 0x00, 0x00, + U16_TO_U8S_LE(0x0050), // wPropertyDataLength + //bPropertyData: “{{975F44D9-0D08-43FD-8B3E-127CA8AFFF9D}}”. + '{{', 0x00, '9', 0x00, '7', 0x00, '5', 0x00, 'F', 0x00, '4', 0x00, '4', 0x00, 'D', 0x00, '9', 0x00, '-', 0x00, + '0', 0x00, 'D', 0x00, '0', 0x00, '8', 0x00, '-', 0x00, '4', 0x00, '3', 0x00, 'F', 0x00, 'D', 0x00, '-', 0x00, + '8', 0x00, 'B', 0x00, '3', 0x00, 'E', 0x00, '-', 0x00, '1', 0x00, '2', 0x00, '7', 0x00, 'C', 0x00, 'A', 0x00, + '8', 0x00, 'A', 0x00, 'F', 0x00, 'F', 0x00, 'F', 0x00, '9', 0x00, 'D', 0x00, '}}', 0x00, 0x00, 0x00, 0x00, 0x00 +}}; + +TU_VERIFY_STATIC(sizeof(desc_ms_os_20) == MS_OS_20_DESC_LEN, "Incorrect size"); + +// End of section about desc_ms_os_20 + """.format(webusb_url=args.webusb_url)) |
