ricardgb commented on issue #15880:
URL: https://github.com/apache/nuttx/issues/15880#issuecomment-4915349759
I hit this same symptom (CDC-ECM netdev up on the NuttX side, but the device
never appears on the host) on an RP2040 (raspberrypi-pico) with a standalone
`CONFIG_NET_CDCECM` build, and root-caused it. The bug is still present on
current master.
**Root cause:** USB device controller drivers invoke `CLASS_DISCONNECT()` on
every USB bus reset — and a bus reset is the first step of normal host
enumeration. The other class drivers (`cdcacm`, `usbmsc`, `rndis`) all
re-assert `DEV_CONNECT()` at the end of their `disconnect()` handlers ("perform
the soft connect function so that we can be re-enumerated"), so on controllers
that soft-disconnect around reset the pull-up glitch is microseconds long and
invisible to the host. `cdcecm_disconnect()`, however, is a no-op
(`uinfo("\n")` only) — so the first bus reset of enumeration leaves the device
soft-disconnected permanently. On RP2040, `rp2040_usbintr_busreset()`
explicitly drops the pull-up, so a standalone CDC-ECM device never enumerates
at all. `stm32_otgfsdev.c` also calls `CLASS_DISCONNECT()` from its
`stm32_usbreset()`, which likely explains the STM32F4Discovery report here. (In
composite mode `composite.c` re-connects in its own disconnect handler, so
composite configura
tions may involve additional factors — the standalone case is what I
validated.)
**Fix (one line, mirroring cdcacm):** re-assert the soft connect in
`cdcecm_disconnect()`:
```c
static void cdcecm_disconnect(FAR struct usbdevclass_driver_s *driver,
FAR struct usbdev_s *dev)
{
uinfo("\n");
#ifndef CONFIG_CDCECM_COMPOSITE
DEV_CONNECT(dev);
#endif
}
```
**Validation:** on raspberrypi-pico (RP2040, NuttX 12.13.0 + this fix), the
host now enumerates the device via `cdc_ether` and ping across the link runs at
0% loss (~0.5 ms RTT).
Note that `cdcncm.c` has the identical defect (a single `DEV_CONNECT` in
bind, no re-connect in `disconnect()`), so NCM presumably fails the same way in
standalone mode and would take the same one-line fix.
Happy to submit a PR for both.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]