tsaitgaist has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/simtrace2/+/15176


Change subject: USB: place version string in interface
......................................................................

USB: place version string in interface

previously the version string was in the iConfiguration field of a
dedicated USB configuration.
this configuration had no interface, but the USB specification
requires at least one interface.
an interface has been added to this configuration.
the version string is now in the iInterface field, and the
iConfiguration field contains "firmware version".
the USB specification does not require an end-point, and none are
present.

Change-Id: I99361e313979711f4f45ad424a52faa3ddd7c558
---
M firmware/libcommon/source/usb.c
1 file changed, 39 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/76/15176/1

diff --git a/firmware/libcommon/source/usb.c b/firmware/libcommon/source/usb.c
index 9d3072f..e75646e 100644
--- a/firmware/libcommon/source/usb.c
+++ b/firmware/libcommon/source/usb.c
@@ -62,6 +62,7 @@
        CARDEM_USIM4_INTF_STR,
        // runtime strings
        SERIAL_STR,
+       VERSION_CONF_STR,
        VERSION_STR,
        // count
        STRING_DESC_CNT
@@ -69,7 +70,7 @@

 /** array of static (from usb_strings) and runtime (serial, version) USB 
strings
  */
-static const unsigned char *usb_strings_extended[ARRAY_SIZE(usb_strings) + 2];
+static const unsigned char *usb_strings_extended[ARRAY_SIZE(usb_strings) + 3];

 /* USB string for the serial (using 128-bit device ID) */
 static unsigned char usb_string_serial[] = {
@@ -110,6 +111,26 @@
 };

 /* USB string for the version */
+static const unsigned char usb_string_version_conf[] = {
+       USBStringDescriptor_LENGTH(16),
+       USBGenericDescriptor_STRING,
+       USBStringDescriptor_UNICODE('f'),
+       USBStringDescriptor_UNICODE('i'),
+       USBStringDescriptor_UNICODE('r'),
+       USBStringDescriptor_UNICODE('m'),
+       USBStringDescriptor_UNICODE('w'),
+       USBStringDescriptor_UNICODE('a'),
+       USBStringDescriptor_UNICODE('r'),
+       USBStringDescriptor_UNICODE('e'),
+       USBStringDescriptor_UNICODE(' '),
+       USBStringDescriptor_UNICODE('v'),
+       USBStringDescriptor_UNICODE('e'),
+       USBStringDescriptor_UNICODE('r'),
+       USBStringDescriptor_UNICODE('s'),
+       USBStringDescriptor_UNICODE('i'),
+       USBStringDescriptor_UNICODE('o'),
+       USBStringDescriptor_UNICODE('n'),
+};
 static const char git_version[] = GIT_VERSION;
 static unsigned char usb_string_version[2 + ARRAY_SIZE(git_version) * 2 - 2];

@@ -582,21 +603,34 @@
 typedef struct _SIMTraceDriverConfigurationDescriptorVersion {
        /** Standard configuration descriptor. */
        USBConfigurationDescriptor configuration;
+       USBInterfaceDescriptor version;
 } __attribute__ ((packed)) SIMTraceDriverConfigurationDescriptorVersion;

 static const SIMTraceDriverConfigurationDescriptorVersion
                                configurationDescriptorVersion = {
-       /* Standard configuration descriptor */
+       /* Standard configuration descriptor for the interface descriptor*/
        .configuration = {
                .bLength                = sizeof(USBConfigurationDescriptor),
                .bDescriptorType        = USBGenericDescriptor_CONFIGURATION,
                .wTotalLength           = 
sizeof(SIMTraceDriverConfigurationDescriptorVersion),
-               .bNumInterfaces         = 0,
+               .bNumInterfaces         = 1,
                .bConfigurationValue    = CFG_NUM_VERSION,
-               .iConfiguration         = VERSION_STR,
+               .iConfiguration         = VERSION_CONF_STR,
                .bmAttributes           = USBD_BMATTRIBUTES,
                .bMaxPower              = USBConfigurationDescriptor_POWER(100),
        },
+       /* Interface standard descriptor just holding the version information */
+       .version = {
+               .bLength = sizeof(USBInterfaceDescriptor),
+               .bDescriptorType        = USBGenericDescriptor_INTERFACE,
+               .bInterfaceNumber       = 0,
+               .bAlternateSetting      = 0,
+               .bNumEndpoints          = 0,
+               .bInterfaceClass        = USB_CLASS_PROPRIETARY,
+               .bInterfaceSubClass     = 0xff,
+               .bInterfaceProtocol     = 0,
+               .iInterface             = VERSION_STR,
+       },
 };

 const USBConfigurationDescriptor *configurationDescriptorsArr[] = {
@@ -693,6 +727,7 @@
                usb_strings_extended[i] = usb_strings[i];
        }
        usb_strings_extended[SERIAL_STR] = usb_string_serial;
+       usb_strings_extended[VERSION_CONF_STR] = usb_string_version_conf;
        usb_strings_extended[VERSION_STR] = usb_string_version;

        // Initialize standard USB driver

--
To view, visit https://gerrit.osmocom.org/c/simtrace2/+/15176
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: I99361e313979711f4f45ad424a52faa3ddd7c558
Gerrit-Change-Number: 15176
Gerrit-PatchSet: 1
Gerrit-Owner: tsaitgaist <kre...@sysmocom.de>
Gerrit-MessageType: newchange

Reply via email to