USB-dongle modem keeps changing from cuaU0 to cuaU1 and bck

Ian Lepore ian at freebsd.org
Tue Sep 1 15:04:52 UTC 2020


On Tue, 2020-09-01 at 16:23 +0200, Willem Jan Withagen wrote:
> On 1-9-2020 16:10, Hans Petter Selasky wrote:
> > On 2020-09-01 15:54, Willem Jan Withagen wrote:
> > > Could it be because the dongle itself crashes?
> > 
> > Yes, if they reboot or there are disturbances on the USB cables, then 
> > a new index number may be assigned during re-enumeration.
> 
> There is no hub or something in between, and it is directly connected.
> So I'm guessing that the modem resets/reboots.
> 
> Let's see if devd can help.
> 
> It does not happen very often, but now already twice on a day that it 
> should have worked.
> 8-(
> 
> --WjW
> 

A typical scenario when this problem happens is:
 
 - cuaU0 is opened by an app.
 - Something Happens(tm) to make the device disconnect from the bus,
   but cuaU0 is still open by the app so the devfs node remains.
 - The transient problems clears, the bus is re-enumerated, but since
   cuaU0 is still in use by the app, cuaU1 gets assigned.
 - Eventually the app tries to read from cuaU0 and gets an error
   return from the read and closes the device, freeing cuaU0 in devfs.

If you use devd rules to assign a particular alias based on the
device's serial number or bus:hub:port tuples, the same underlying
problem is going to be there:  the app may still have the old device
open and hasn't yet noticed that it has disappeared.  If the way the
alias is assigned is to create a symlink, and that's done using ln -fs
then it may work out.  But there may be some need to have the devd rule
signal or kill/restart your app that's doing the monitoring.

-- Ian



More information about the freebsd-usb mailing list