Cdc_ehter drive bug, no usb0 card registered

The board use Quectel EC200U 4G modem, use ECM mode, and use the latest OpenWrt master branch, compiled and burned to the board.

When initially booting, output register 'cdc_ether' at usb-1e1c0000.xhci-1, CDC Ethernet Device. I can see that there is a NIC for usb0.

[   35.167751] mtk_soc_eth 1e100000.ethernet wan: PHY [mdio-bus:00] driver [MediaTek MT7530 PHY] (irq=POLL)
[   35.177301] mtk_soc_eth 1e100000.ethernet wan: configuring for phy/rgmii-rxid link mode
[   50.688074] usb 1-1: new high-speed USB device number 2 using xhci-mtk
[   51.031457] usb 1-1: USB disconnect, device number 2
[   57.338085] usb 1-1: new high-speed USB device number 3 using xhci-mtk
[   57.518463] usb 1-1: config 1 has an invalid interface number: 6 but max is 5
[   57.525585] usb 1-1: config 1 has no interface number 5
[   57.538805] cdc_ether 1-1:1.0 usb0: register 'cdc_ether' at usb-1e1c0000.xhci-1, CDC Ethernet Device, ae:0c:29:a3:9b:6d
[   57.551879] option 1-1:1.2: GSM modem (1-port) converter detected
[   57.558719] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB0
[   57.567433] option 1-1:1.3: GSM modem (1-port) converter detected
[   57.574263] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB1
[   57.582548] option 1-1:1.4: GSM modem (1-port) converter detected
[   57.589335] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB2
[   57.598360] option 1-1:1.6: GSM modem (1-port) converter detected
[   57.605213] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB3
[   83.600746] IPv6: ADDRCONF(NETDEV_CHANGE): usb0: link becomes ready

Then use the GPIO to power down the EC200U 4G modem, the system outputs unregister 'cdc_ether' usb-1e1c0000.xhci-1, CDC Ethernet Device, the usb0 NIC is disappeared, this is normal behavior:

[  146.541628] usb 1-1: USB disconnect, device number 3
[  146.546814] cdc_ether 1-1:1.0 usb0: unregister 'cdc_ether' usb-1e1c0000.xhci-1, CDC Ethernet Device
[  146.690578] option1 ttyUSB0: GSM modem (1-port) converter now disconnected from ttyUSB0
[  146.699270] option 1-1:1.2: device disconnected
[  146.704901] option1 ttyUSB1: GSM modem (1-port) converter now disconnected from ttyUSB1
[  146.713377] option 1-1:1.3: device disconnected
[  146.718966] option1 ttyUSB2: GSM modem (1-port) converter now disconnected from ttyUSB2
[  146.727378] option 1-1:1.4: device disconnected
[  146.733039] option1 ttyUSB3: GSM modem (1-port) converter now disconnected from ttyUSB3
[  146.741473] option 1-1:1.6: device disconnected

Next, the Quectel EC200U 4G modem was re-powered with GPIO, and the system output was missing the register 'cdc_ether' at usb-1e1c0000.xhci-1, CDC Ethernet Device., and I never saw the usb0 card again:

[  159.530388] usb 1-1: new high-speed USB device number 4 using xhci-mtk
[  159.877144] usb 1-1: USB disconnect, device number 4
[  166.192167] usb 1-1: new high-speed USB device number 5 using xhci-mtk
[  166.373377] usb 1-1: config 1 has an invalid interface number: 6 but max is 5
[  166.380505] usb 1-1: config 1 has no interface number 5
[  166.391840] option 1-1:1.0: GSM modem (1-port) converter detected
[  166.400652] option 1-1:1.1: GSM modem (1-port) converter detected
[  166.409970] option 1-1:1.2: GSM modem (1-port) converter detected
[  166.417211] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB2
[  166.425830] option 1-1:1.3: GSM modem (1-port) converter detected
[  166.432768] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB3
[  166.443708] option 1-1:1.4: GSM modem (1-port) converter detected
[  166.451145] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB4
[  166.460658] option 1-1:1.6: GSM modem (1-port) converter detected
[  166.468511] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB5

This should be a bug in the cdc_ehter driver, how should I fix it?

The option driver steals the ECM interfaces (0 and1). This is most likely caused by a misconfiguration of the option driver. It won't do this by default.

The reason it happens after disconnect but not before is just a race. If you load it first then it will win against the cdc_ether driver

1 Like

The application writes PID/VID to /sys/bus/usb-serial/drivers/option1/new_id and kernel options.c has some duplicates, so after removing them, it works fine.

Thank you

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.