STM32H747 and USB DISK - how to make it work?
Discovery board: STM32H747I-DISCO.
OTG connected to P1 (HS).
First of all, there are two modes:
- EXTERNAL Phy
- Internal FS
EXTERNAL Phy is faster, Internal FS is slower. What does "external" mean?
Will it just work or not?
First I tried "Internal FS". Just doesn't work. Initialization with MX_USB_HOST_Init() passes, the f_mount() fails on reading first bytes from the disk. At the same time LD5 (overcurrent) is on, LD7 (VBUS) is off.
Then I tried "External Phy". Initialization passes. The same LED states, LD5 on, LD7 off.
Also I notice a weird thing: many pins that are NOT USED by USB_OTG_HS in the GPIO section were reset. I had to set them up manually. Including LCD_BL and LCD_RESET. My TIM3 CH1 output was also changed without a reason.
I lost all day for testing next to each and every option. I can't make the USB DISK work, what's worse, on one try I got LD7 on and LD5 off, but I can't get back to that state anymore.
To make it clear, I tested the OTG and USB disk on my Android phone and it works.
EDIT: After I fixed all that STM32CubeIDE has broken in GPIO configuration, now the device starts, both LD7 and LD5 are on, USB doesn't work.
ANOTHER UPDATE:
I fixed the VBUS problem. The next problem is when I try to make first read from the USB disk I get error, it's triggered at this exact point:
if ((phost->device.is_connected == 0U) ||
(phost->gState != HOST_CLASS) ||
(MSC_Handle->unit[lun].state != MSC_IDLE))
{
return USBH_FAIL;
}The phost->gState is HOST_DEV_WAIT_FOR_ATTACHMENT. Now why is that? The USB disk is already connected when the function is called. It's connected before the device is powered on.
I added HAL_Delay(1000) before calling f_open(), it still fails, but with state HOST_ENUMERATION.
