MX_USB_DEVICE_Init() causes program to stall, possibly due to low-quality USB power supply
Hello,
We observe issues with a set of stm32F407ZETx.
The application stalls / hangs somewhere while calling MX_USB_DEVICE_Init(). We are using the USB in CDC class. The board is powered via a USB cable, and the issue is not observed when using a good-quality USB power block, but it is observed if we e.g. put a dongle in between (https://us.transcend-info.com/product/card-reader-accessory/hub2). The production site (in a different country) is also observing these issues, I'll ask if they use a hub as well.
The application seems to hang, but I could not pinpoint where exactly, since the program counter register suddenly becomes 0x0!!! That seems to happen on a random place during MX_USB_DEVICE_Init(). Sometimes, the application recovers automatically (on the production site, they say that the startup time usually takes 2 minutes instead of 3 seconds), but on our reproduction setup, the application never recovers automatically.
Surprisingly, the application DOES recover if we touch the groundplane with e.g. a pin from a multimeter. We have had strange observations when e.g. plugging in the programmer, but eventually we could pin it down to 'touching' the groundplane.
This is all very puzzling, but I still assume that there is a common root cause for the observations. So as a summary, I'd like to know:
- How can the program counter suddenly become 0x0?
- How can the program automatically resume after touching the ground plane?
- How can this be caused by the function MX_USB_DEVICE_Init()?
- We did not connect USB_OTG_FS_ID and USB_OTG_FS_VBUS pin on the MCU.
- How can it be caused by a low-quality USB supply? Our first analysis shows that the convertor to 3.3V seems quite stable, and the USB_DEVICE_Init() is far from the first function to be called (so the voltage should be quite stable).
- If we disable the USB initialization, we clearly don't have the logging functionality but apart from that the application works all fine.
- I've seen other threads about program counters becoming 0x0 but that was caused by missing entries in the interrupt table, as far as I could see.
- I'm using cubeide 1.3.0 and cubemx 5.6.1. I have not yet tried to upstep to newer versions for this project.
