2025-04-30 2:19 AM - edited 2025-04-30 2:42 AM
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.
I have examinated USB File descriptors using USB Device Tree Viewer and noticed that:
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:
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?
2025-04-30 2:35 AM
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?
2025-04-30 2:44 AM
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.
2025-04-30 6:58 AM - edited 2025-04-30 6:59 AM
> 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.
2025-04-30 8:12 AM
I use UsbTreeView to read device tree.
Here is what I find with the USB-C Key I cannot read in my bootloader.
This one is a USB-C Key I can read.
2025-04-30 8:30 AM
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.
2025-05-02 4:50 AM - edited 2025-05-02 6:18 AM
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?
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-05-05 12:31 AM
Thank you for your messages.
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.
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.
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:
* When I use the other USB-C Flash Drive with the scsi interface I have a hardfault because pClass[0] is undefined:
2025-05-05 2:27 AM
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.
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-05-05 2:50 AM
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 ?