cancel
Showing results for 
Search instead for 
Did you mean: 

stm32g0b1 usb host (MSC) flash drive not working

GrassHopper
Associate II

I have a STM32G0B1VET on a test board and tried to use its USB host function to connect a flash drive. It just stuck at the function of "USBH_MSC_SCSI_Inquiry" in file "usbh_msc_scsi.c". It can't pass  the state of below:

case BOT_CMD_WAIT:

   error = USBH_MSC_BOT_Process(phost, lun);

where the error returns "USBH_BUSY".

  1. I have tried to increase the stack and heap to 0x2000. And I tried several different flash drives (500MB to 16GB). The same thing happened.
  2. I have measured the 48Mhz signal which is good.
  3. I have tried putting 30 Ohm resistors on the DP and DM line.
  4. I have tried using GPIO pin to control the 5V line for flash drive.
  5. I have tried using 3.3V for flash drive.

Does anybody have an idea what's wrong? Any successful case? Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
HKrnr
Associate

Hi, a solution that worked in my case has been found on a similar topic. It appears the issue occurs on the row 561 of usb_ctrlreq.c, which you can replace with the following :

ep_descriptor->wMaxPacketSize |= MIN((uint16_t)(LE16(buf + 4) & 0x7FFU), (uint16_t)USBH_MAX_DATA_BUFFER);

As a new member I cannot share links, so the original topic is : FatFs_USBDisk example with USB_FS does not work. When an USB Stick is connected the USBH_MSC_Process never gets further then MSC_READ_INQUIRY. Any hints? , created by MMenz.1 on the 6th of July 2022, 2:36 AM

View solution in original post

8 REPLIES 8
GrassHopper
Associate II

I'm using the latest STM32cubeide, 1.10.1 with STM32Cube FW_G0 V1.6.0.

Further debugging shows the code stops at "USBH_MSC_BOT_Process" function in "usbh_msc_bot.c". It stops at the

 case BOT_DATA_IN_WAIT:

   URB_Status = USBH_LL_GetURBState(phost, MSC_Handle->InPipe);

It returns "USBH_URB_ERROR" for URB_status and won't go into

   if (URB_Status == USBH_URB_DONE)

Please help.

GLASS
Senior

Hi, we have the same problem with STM32F769BIT6 since we upgraded USB Host V3.4.0 to USB Host V3.4.1.

We are sure that the guilty is USB Host library.

STM32F7 HAL V1.17.0 or 1.16.2 and CUBE MX 6.6.1 (or 6.5.0) generated code are not the source of this problem. (they are OK with USB Host V3.4.0 and all fail with USB Host V3.4.1).

Seem's that the USB Host V3.4.1. was not correctly tested by ST...

@Amel NASRI​ Hi, seem's that same error rising on stm32g0 and stm32f7 since upgraded to USB Host library v3.4.1.that is delivered with latest respective HAL.

Pl​ease can somebody from ST can give a look please?

HKrnr
Associate

Hi, a solution that worked in my case has been found on a similar topic. It appears the issue occurs on the row 561 of usb_ctrlreq.c, which you can replace with the following :

ep_descriptor->wMaxPacketSize |= MIN((uint16_t)(LE16(buf + 4) & 0x7FFU), (uint16_t)USBH_MAX_DATA_BUFFER);

As a new member I cannot share links, so the original topic is : FatFs_USBDisk example with USB_FS does not work. When an USB Stick is connected the USBH_MSC_Process never gets further then MSC_READ_INQUIRY. Any hints? , created by MMenz.1 on the 6th of July 2022, 2:36 AM

You guys are awesome! This is a solution for me! Thanks a lot.

Amel NASRI
ST Employee

Hello,

Please note that the reported issue was already fixed in stm32_mw_usb_host v3.5.0.

-Amel

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.

Hello, i had a similar problem that was successfully fixed with stm32_mw_usb_host  v3.5.0, but I cannot find the upgrade in STM32CubeMX -> manage embedded sw packages -> SMT32G0.

The last USBhost updated packages that I see is v1.6.1 (USB Host Lib to use V3.4.1); it would be nice to include it in the libraries, so that if I need future project generating codes, could be done.

Thanks!

Hello,

I have seen same issue when working with NUCLEO-H755ZI (unable to detect flash drive when using micro-usb OTG cable)

Even when I updated code as suggested (stm32_mw_usb_host v3.5.0) some how USB flash drive is not detected

Mainly, usbh_ctlreq.c file was the only one updated since the other are pretty much the same

Any hints?