Problem with USB OTG in host mode, no HOST_USER_CLASS_ACTIVE.
I configured USB_OTG_FS on STM32H745I-DISCO board using STM32CubeIDE.
Here are my settings:




My `MX_USB_HOST_Init()` function is called in `DefaultTask`.
It completes without errors.
`USBH_UserProcess()` is called whenever a USB disk is inserted to the port, with `HOST_USER_CONNECTION`.
Then, in only one of like 10 different pendrives - I get `HOST_USER_CLASS_ACTIVE` state, then everything works, I can use any format on the USB disk. Via FatFs library. I tested it with FAT32 and ExFAT. Both seem to work perfectly without any issues.
But I just can't buy another pendrive that works with that. 10 other pendrives don't work. I get `HOST_USER_CONNECTION` and that's it. Nothing. The device is not detected as mass storage device. What's especially infuriating, that it happens also with exactly the same looking pendrives. They have the same capacity, same speed, even the same look, branding and all. TBH: I have 3 pendrives that work with H745. 2 of them were bought together, in one batch, the other one is a random one found in a drawer. 7 others are various bunch. Some of them are bought to be the same model as the working ones - unfortunately despite looking exactly the same, they don't work. Some of them are just similar "16GB / USB2.0". They are all recognized both by Windows and Linux. They are all formatted identically, as only one MBR partition, FAT32. Partition tools report even the same sector sizes and all partition description fields. The working USB can be formatted as FAT32, ExFAT, not formatted at all, deleted partition table - no matter what, it is detected as mass storage device. The others just don't work at all. USB host detects when they are inserted, but the MSC class initialization fails.
What's weird, I could swear a year ago I had it working with various pendrives. Then I upgraded the firmware a couple of times, but I haven't noticed anything breaking because I was using always the same pendrive for tests. Now when I try 10 different ones, only 3 / 10 work.
So I just created a new project on STM32H747I-DISCO. I configured the board to use external USB chip. My first test with a random pendrive - everything works. I get `HOST_USER_CLASS_ACTIVE` - so I try if it would work with different pendrives. And SURPRISE: it doesn't. I couldn't even make it work with the same as before. It turned out it was a fluke or something, because now on H747 USB doesn't work at all. I get `HOST_USER_CONNECTION` and the host hangs. After resetting the device it detects insertion, but no `CLASS_ACTIVE`.
What's wrong with this USB host? How should I proceed with trying to fix it? My guess is there is a bug in USB Host firmware / middleware released by ST for H745 (and probably for H747 too). I'm not sure, but I think I had it working once, but now, when I create new, empty projects - it's just it. Nothing on H747. On H745 I can work with just 1 type of pendrive, all others don't work.
I'm looking for an advice on how to debug that problem. I don't see any code parts of the USB host even run. What should I check first? How to even start debugging this? On "supported" USB stick a lot is happening. The data is transferred between MCU and USB, a lot of driver functions called. The problem is - it all happens as the host detects the device is connected. But this doesn't happen. Some sticks just seem like disconnect in the same moment they are connected. Others seem dead - like completely nothing happens. But they of course work with PC and phone.

