1

How do you clear any memory Linux has of a USB device?

When I plug in several USB devices, I notice that Linux seems to "remember" them and remount them to the same locations in /dev.

For example, I have a few Arduinos that, when connected, appear as /dev/ttyACM0, /dev/ttyACM1 and /dev/ttyACM2. If I disconnect them all and then reconnect the second, it re-appears as /dev/ttyACM1 instead of /dev/ttyACM0, even though it's now the only device connected.

How do I clear whatever mechanism is remembering that the second device mounts as /dev/ttyACM1? The only way I've found to clear this is to reboot, but that's too disruptive to my system. I've tried restarting udev, but that had no effect.

I'm attempting to debug a problem where, after an Arduino is re-connected to the USB host, its serial connection sporadically hangs and drops off. After a fresh reboot, the Arduino's serial connection works perfectly, so my theory is there's some bug in my computer's USB driver that's remembering some aspect of the old connection, and it's trying to re-use this for the new connection, causing it to fail.

1

You might unload & reload the usb-serial driver module: it's either cdc-acm or ftdi-sio.

Once you've unplugged all the Arduinos, run:

sudo modprobe -r cdc-acm
sudo modprobe -r ftdi-sio

The kernel will automatically reload them (whichever is appropriate for your Arduino model) when you plug the Arduino(s) back in, but unloading the driver should remove its "memory" of which device is which.

0

It depends on your system (which you told us nothing about).

Often persistent device assignments are handled by udev rules, and stored in /etc/udev/rules.d, usually in files that have persistent in the name. Have a look what you find there on your system.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.