Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WCID support #137

Open
gamelaster opened this issue Jan 16, 2024 · 2 comments
Open

WCID support #137

gamelaster opened this issue Jan 16, 2024 · 2 comments

Comments

@gamelaster
Copy link

Hello, I would like to ask, what is the best way of implementing WCID (thus auto installing WinUSB driver) in USBX?
Currently, we have been able to get it working, but we needed to modify USBX source to workaround ascii to unicode conversion of strings, but we would like to avoid modifying usbx, so having proper way of doing this would be much better. Thanks!

@xiaocq2001
Copy link
Contributor

xiaocq2001 commented Jan 17, 2024

Currently USBX accepts ascii string and extend it to unicode string (padding zero on each ascii byte) defined by USB spec.
The WCID have a vendor ID and a padding byte after the unicode string (referencing https://github.com/pbatard/libwdi/wiki/WCID-Devices#user-content-Microsoft_OS_String_Descriptor),
so it's worthy to try the string framework like this:

UCHAR string_framework[] = { 

    /* Manufacturer string descriptor : Index 1 */
        0x09, 0x04, 0x01, 0x0c, 
        0x45, 0x78, 0x70, 0x72,0x65, 0x73, 0x20, 0x4c, 
        0x6f, 0x67, 0x69, 0x63,

    /* Product string descriptor : Index 2 */
        0x09, 0x04, 0x02, 0x0c, 
        0x44, 0x61, 0x74, 0x61, 0x50, 0x75, 0x6d, 0x70, 
        0x44, 0x65, 0x6d, 0x6f,  

    /* Serial Number string descriptor : Index 3 */
        0x09, 0x04, 0x03, 0x04, 
        0x30, 0x30, 0x30, 0x31,

    /* WCID MS OS String Descriptor.  */
        0x09, 0x04, 0xEE,
        0x08, /* 8 bytes to extend (including vendor code byte) */
        'M', 'S', 'F', 'T', '1', '0', '0', '0',
        <VendorCode> /* Put your vendor code here */

    };

For general support for any kind of vendor string format, I would say that should be some new feature for USBX, to let string framework accept totally customized descriptor format.

Note windows could ask lang id 0000 for string, define UX_DEVICE_ENABLE_GET_STRING_WITH_ZERO_LANGUAGE_ID to accept it.

@majsi
Copy link

majsi commented Jan 18, 2024

Thank you for your comment. If I modify the code from your answer like this:

UCHAR string_framework[] = { 
    /* Manufacturer string descriptor : Index 1 */
        0x09, 0x04, 0x01, 0x0c, 
        0x45, 0x78, 0x70, 0x72,0x65, 0x73, 0x20, 0x4c, 
        0x6f, 0x67, 0x69, 0x63,

    /* Product string descriptor : Index 2 */
        0x09, 0x04, 0x02, 0x0c, 
        0x44, 0x61, 0x74, 0x61, 0x50, 0x75, 0x6d, 0x70, 
        0x44, 0x65, 0x6d, 0x6f,  

    /* Serial Number string descriptor : Index 3 */
        0x09, 0x04, 0x03, 0x04, 
        0x30, 0x30, 0x30, 0x31,

    /* WCID MS OS String Descriptor.  */
        0x00, 0x00, 0xEE,
        0x08, /* 8 bytes to extend (including vendor code byte) */
        'M', 'S', 'F', 'T', '1', '0', '0',
        <VendorCode> /* Put your vendor code here */

    };

then MS Windows correctly reads the 0xEE string descriptor. Software such as USB Device Tree Viewer and Thesycon USB Descriptor Dumper do not display this descriptor because they read 0xEE with a language ID other than 0x0000.

The macro you mentioned,
UX_DEVICE_ENABLE_GET_STRING_WITH_ZERO_LANGUAGE_ID,
I couldn't find in the firmware package I am using, available at STM32CubeH5 v1.1.0. When I compared the codes with eclipse-usbx, I noticed the following section is missing:

#ifdef UX_DEVICE_ENABLE_GET_STRING_WITH_ZERO_LANGUAGE_ID

            /* Check if the language ID is zero.  */
            if (request_index == 0)
            {

                /* Get the first language ID in the language ID framework.  */
                request_index =  _ux_utility_short_get(_ux_system_slave -> ux_system_slave_language_id_framework);
            }
#endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants