2024-01-22 05:08 AM
Hi, I'm running into problems registering USB interfaces on STM32G0B1KBU6. The same code works fine on STM32F1*, STM32F7*, and STM32G4*.
Environment: latest STM32CubeIDE (v.1.13.2) @ Windows. Target: custom board with STM32G0B1KBU6, which uses the following peripherals: USB, CANbus, 9x PWM out lines and a digital GPIO in (the details are below). Flashing is done over SWD using either ST-Link v.2, or J-Link Base, directly from the CubeIDE.
For debugging, I've reduced the problem to a new and empty CubeIDE project for this chip, adding only the USB and one timer. No custom code: just what's generated by the IDE. No matter what USB device class is selected in *.ioc->Middleware and Software Packs -> USB_DEVICE -> Class For FS IP, the device fails to be recognized by the host (both Windows and Mac). The message provided by a Windows host is "Device Descriptor Request Failed". If I step over the init functions, the host reports this message exactly when the following stack flips the USBx->BCDR.USB_BCDR_DPPU bit:
HAL_PCD_Start() at stm32g0xx_hal_pcd.c:981 0x8001302
USBD_LL_Start() at usbd_conf.c:474 0x8005d86
USBD_Start() at usbd_core.c:378 0x80056cc
MX_USB_Device_Init() at usb_device.c:82 0x80058dc
main() at main.c:96 0x8000238
The USB stack never requests any of the device descriptor fields (doesn't hit the breakpoints there), although the valid descriptor is passed correctly by MX_USB_Device_Init() into USBD_Start().
On the hardware side:
Please let me know if I should provide the USB capture or any other info.
Hope this has a known solution. Thank you so much for looking into this!
2024-01-23 04:48 PM
I would try to get a USB example from the CubeMX repository running. Those tend to be more robust than the automatic CubeMX code generation. Here is one such example, may need to be tweaked slightly for your specific hardware.
Once that is working, diff the two codes to determine differences.