Re: New device wiring option

From: John-Mark Gurney <jmg_at_funkthat.com>
Date: Mon, 17 May 2021 10:56:01 -0700
Daniel O'Connor via freebsd-arch wrote this message on Fri, Apr 16, 2021 at 21:05 +0930:
> > On 15 Apr 2021, at 14:47, Poul-Henning Kamp <phk_at_phk.freebsd.dk> wrote:
> > 
> > --------
> > Bjoern A. Zeeb writes:
> > 
> >> Probably USB as well?  Having 10 serial consoles on USB Hubs and unplugging
> >> one ???early??? one it is easy to end up re-numbering the entire chain after a
> >> reboot.  Not sure if this really fits into your problem/implementation domain.
> > 
> > My solution to that specific problem is the following entry in /etc/devd:
> > 
> > 	attach 500 {
> > 		match "device-name"     "uftdi[0-9]*";
> > 		match "vendor"          "0x0403";
> > 		match "product"         "(0x6001|0x6015)";
> > 		action "ln -fs /dev/cua$ttyname /dev/cua_$sernum";
> > 	};
> > 	
> > 	notify 500 {
> > 		match "system"          "USB";
> > 		match "subsystem"       "DEVICE";
> > 		match "type"            "DETACH";
> > 		match "vendor"          "0x0403";
> > 		match "product"         "(0x6001|0x6015)";
> > 		action "rm -f /dev/cua_$sernum";
> > 	};
> 
> I wrote a more general version of this, although when I did testing the serial number was not available so I had to store it for deletion later.

Yeah, and I did a slight improvement here:
https://reviews.freebsd.org/D21886#554613

https://www.funkthat.com/~jmg/FreeBSD/usbserialsn

Which supports devices that don't have serial numbers by addressing them
via a path of hub port numbers which does not change...

One issue is that it isn't atomic, so there's always a slight race
between devd running and removing the link, and a new device appearing
at the old one's name.

-- 
  John-Mark Gurney				Voice: +1 415 225 5579

     "All that I will do, has been done, All that I have, has not."
Received on Mon May 17 2021 - 17:56:01 UTC

Original text of this message