Preamble: It seems that this question is being poorly received by some users and I'm not sure why. If you believe this question merits a downvote, please also consider posting a comment explaining why so that I know how to fix it. I need a solution to my problem and am more than willing to edit my question if need be.
I'm trying to use a TP-Link UE200
USB-to-Ethernet Adapter with Debian Buster (the latest stable release at the time of this writting). Under normal operation, this adapter presents itself as a USB CD-ROM drive when first plugged in and relies on its driver to switch it to Ethernet mode.
The adapter works fine when I plug it into my system when it's already running: linux detects the adaptor properly and automatically switches the device to the correct mode. However my system fails to automatically switch the correct mode when the adapter is plugged in during system boot-up.
Furthermore, when in its CD-ROM state, I'm unable to find a way to force the device to present itself as an Ethernet adapter without mechanically unplugging and replugging the device. This system is meant to run and reboot without human intervention, so having to manually intervene each time is undesirable.
My question is as follows: How can I get my adapter - that was plugged in when the system booted up - to present itself as an Ethernet adapter without having to physically unplug it?
Side notes:
I would like to add that I have a similar setup running on a raspberry pi 4 + Ubuntu 19.10. The Ethernet adapter gets correctly recognized even when the system boots up with it plugged in. I've only experienced this issue on Debian Buster/x86_64 so far.
As far as USB is concerned, the adapter behaves as two separate USB devices. Each of the device's two modes has its own USB Product ID (namely 0601 when operating as a CD-ROM drive and 0602 when operating as an Ethernet adapter).
Things I've tried so far:
Unbinding and rebinding the device via
/sys/bus/usb/drivers/usb/{unbind,bind}
: the adapter just presents itself as0601
again, and the kernel registers it as a CD-ROM device again. I think the device needs to be powered off completely before it will reinitialize itself properly.Manually unbinding the
usb-storage
driver from the device and binding thecdc_ether
driver via/sys/bus/usb/drivers/usb-storage/unbind
and/sys/bus/usb/drivers/cdc_ether/bind
(after loading the module manually): Unsuprisingly this doesn't work since the device presents itself to the kernel as a usb mass-storage device.Using
usb_modeswitch
to manually force the device to present itself as 0602: The device simply ignores the messages or refuses to work. Ejecting the device-K
and resetting it-R
don't seem to have any effect.Disconnecting the device via
/sys/bus/usb/devices/XXX/remove
:Works perfectly, but no way to get linux to "unremove" the device without physically reinserting the deviceUpon further investigation, it probably doesn't since linux doesn't cut power to the device.Including the
cdc_ether
module in my initramfs, and preloading the module via the kernel command line parametermodules_load
in a vain hope that this issue is caused by lack kernel modules during early boot: Linux still usedusb-storage
regardless.