Open ALTracer opened 1 year ago
Also see discussion in #8906 and https://github.com/libopencm3/libopencm3-examples/issues/178. Summoning @raiden00pl for good measure because of involvement in RNDIS, COMPOSITE and stm32h7. Maybe even @davids5 (thanks for allowing disabling GPIO_OTG_ID!)
Wireshark:
with NuttX firmware, host gets -EPROTO and 0-length USB URB in response to GET DESCRIPTOR Request DEVICE to 1.0.0 0-address destination. Request-response time is 0.3ms-1.0ms. Then hosts sends RESET to USBHUB (this is AMD Ryzen 3200G B450M desktop and USB2.0 front panel port, no issues with Full Speed devices) and repeats DESCRIPTOR Request. 0-length responses. I'll need to look at physical level later, something's wrong. NuttX throws a lot of USBDEV_REGDEBUG traces I enabled, into 0x50000000-0x50001000 region. Without them (synchronous 1-byte FIFO USART at 115200 is /dev/console aka arm bit-bucket, so might slow down) nothing much changes.
with STM32 DfuSe BootROM, host gets URB status success and 18-length data, also a DFU Mode descriptor. Then assigns an address (39 today) and repeats descriptor request-response to this address, all the usual handshake stuff. First request-response time is 2.7ms.
@ALTracer Have a look at the reference manual and see of the IP block uses on the stm32411 look line the one on the F466/F469
[See comment in #if defined(CONFIG_STM32_STM32F446) || defined(CONFIG_STM32_STM32F469) /* In the case of the STM32F446 or STM32F469 the meaning of the bit
@davids5 Maybe you didn't read my #8906 ?
Moving half of comment from PR to this issue:
I see something funny in otgfsdev driver code: https://github.com/apache/nuttx/blob/d3f659b85427401c334aea8f2c633516222f7982/arch/arm/src/stm32/stm32_otgfsdev.c#L5361-L5369 F446, F469 and MP15x have a newer DWC2 and only VBDEN bit in ther GCCFG register. F411 has a slightly older revision and is controllable by all the bits: VBUSASEN. VBUSBSEN, NOVBUSSENS.
STM32F411CE Reference Manual contains a OTG Device mode programming sequence, where they tell to write the VBUSBSEN bit to enable Vbus B-mode sensing logic, if VBus pad is muxed. Or they tell to write the NOVBUSSENS bit if VBus pad is not connected.
NuttX driver code writes BOTH VBUSASEN, VBUSBSEN unconditionally, and there is no git history for these two lines since basically 2015. Sure, some might say after NOVBUSSENS this is largely irrelevant, but 1) it contradicts the RM; (not really, it's just not stated) 2) there are multiple threads/GH-issues in libopencm3 which consider this subject/problem of non-working OTG device on F411 and friends.
Summary
I can't get USB OTG to work in device mode on WeAct BlackPill STM32F411CEU6 rev 3.1 in CDC/ACM, MSC and COMPOSITE configurations.
Impact
Possibly all stm32f4-based boards and dwc2 IP users without VBUS_SENSE pad routed.
Description
As I was bringing up some more configs for stm32f411-minimum, I stumbled upon non-working USBDEV. USBHOST won't work because I didn't bridge VBUS with onboard 5V pin yet, and I don't need USBHOST on this board.
I see several issues in stm32_otgfsdev driver code:
+# ifdef CONFIG_USBDEV_VBUSSENSING
endif
ifdef CONFIG_STM32_OTGFS_SOFOUTPUT
I input sercon, msconn, conn and disconn. The latter triggered an assert because my Gentoo Host cannot enumerate this device.
Wireshark usbmon0 traces later. STM32 DfuSe USB BootROM works.