Skip to main content
Visitor II
April 30, 2025
Question

USB-C Key detection

  • April 30, 2025
  • 7 replies
  • 849 views

Hello,

 

I am working on a Bootloader that reads USB-Key using USB_Host middleware to retrieve files before performing some operations but I have some issues detecting some USB keys.

  • USB 2.0 Keys are all detected
  • USB 3.2 Keys are not well detected

I have examinated USB File descriptors using USB Device Tree Viewer and noticed that:

  • Demanded Current <=500 mA : Detected
  • Demanded Current > 500 mA : Not Detected

Even though, I have measured Ibus and it's never over 120 mA so I assume it's not that.

If I use a USB-C to USB-A adapter to force to use USB 2.0 fallback, it doesn't work either.

 

Then I noticed that in the Device Tree that:

  • Enumerator: SCSI => Not Detected
  • Enumerator: USBSTOR => Detected

 

When I use Debugger, I can see a hard fault coming from USBH_Process :

 
case HOST_CHECK_CLASS:
if (phost->ClassNumber == 0U)
{
USBH_UsrLog("No Class has been registered.");
}
else
{
phost->pActiveClass = NULL;

for (idx = 0U; idx < USBH_MAX_NUM_SUPPORTED_CLASS; idx++)
{
if (phost->pClass[idx]->ClassCode == phost->device.CfgDesc.Itf_Desc[0].bInterfaceClass)
{
phost->pActiveClass = phost->pClass[idx];
break;
}
}

The phost->pClass[idx]->ClassCode is unknown for SCSI USB 3.2 Keys.

When I use USB 2.0 Key, it's ok ClassCode is known.

 

Any idea how to solve this issue?

    This topic has been closed for replies.

    7 replies

    Super User
    April 30, 2025

    Welcome to the forum.

    Please see How to write your question to maximize your chances to find a solution; in particular How to insert source code.

    What MCU are you using, and what hardware?

    SKham.2Author
    Visitor II
    April 30, 2025

    MCU is stm32h750 and I am working on a proprietary Touch Screen.

    I assume Hardware is not an issue though as I can detect USB 2.0 Keys and some USB 3.2 Keys.

    Super User
    April 30, 2025

    > Then I noticed that in the Device Tree that  Enumerator: SCSI => Not Detected

    In which Device Tree?  If you mean Windows device manager, then USBSTOR is the most common interface of USB drives. UASP is less common. These are not associated with USB 2.x or 3.x interfaces or connector types.

     

     

     

    SKham.2Author
    Visitor II
    April 30, 2025

    I use UsbTreeView to read device tree.

    Here is what I find with the USB-C Key I cannot read in my bootloader.

    usb_not_detected.png

     

    This one is a USB-C Key I can read.

    usb_detected.png

     

    Super User
    April 30, 2025

    Ok so the problematic device has UASPstor protocol (its driver properly is uaspstor.sys). The ST library supports only MSC class. The interface protocol for legacy MSC is 0x50 (bulk-only),  protocol for UASP is 0x62 and it has 4th interrupt endpoint. Also the UASP device requires almost 900 ma, check that your board can provide it. 

    Consider the USBX library for your project.

    Technical Moderator
    May 2, 2025

    Hi @SKham.2 

    The demanded current 896 mA, might exceed typical power supply. Does your board provide it in some way? Would you share USB schematics? I think It's more about the implementation rather than a limitation.
    Also, would you attach USB protocol trace?

    SKham.2Author
    Visitor II
    May 5, 2025

    Thank you for your messages.

    @Pavel A. 

    I didn't know that ST Library support only MSC class USB flash drive, it surprise me a bit because there is: usbh_msc_scsi.c

     

    Even if it is written that the key could demand a maximum current of about 900 mA, it doesn't exceed 200 mA when I access file on it from my computer as I measured with a USB multimeter.

    20250505_084303.jpg

     

    Unfortunately I cannot share the schematic of our USB implementation but we have high-side mosfet switch connected on VBUS that gives 500 mA max for IBUS.

     

    @FBL 

    I don't have a USB protocol trace, how can I make it? Any tool/software I could use?

     

    Here are screenshots of what I can see with the debugger.

    * When I run the debugger with the MSC USB Flash Drive, USB_Host recognize the key properly:

    Screenshot 2025-05-05 091838.pngScreenshot 2025-05-05 092617.png

     

    * When I use the other USB-C Flash Drive with the scsi interface I have a hardfault because pClass[0] is undefined:

    Screenshot 2025-05-05 091957.pngScreenshot 2025-05-05 092039.png

     

    Technical Moderator
    May 5, 2025

    Hi @SKham.2 

    You can use some software tools for example Wireshark + USBPcap to capture USB traffic using the USBPcap plugin. This will help ensure that all descriptors are being correctly parsed by your USB host.  Also, having hardware USB analyzers could be more suited for low-level hardware debugging. 

    SKham.2Author
    Visitor II
    May 5, 2025

    But to use Wireshark and analyze the communication between the USB Flash drive and the MCU, I would need some kind of hardware sniffer in between right ?