Two interfaces with the same identity

Hi

Run into a issue when I added a second usb interface to Hassio RPI. The following interface that is connected is used to read the HAN meter port, and now I wanted to add a second USB to serial interface to control my systemair trough Modbus. The issue is that the new interface has the same identity as the already existing one.

/dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller-if00-port0

So when plugging in the new interface it does not show under hardware. Remove the already existing one, and the new one shows with the same name.

Is there any way to fix this, rename the existing interface or the new one?

Cheers!

No suggestions? :smiley:

Nop. These names are hardcoded in the hardware, just like mac-addresses.

Was afraid of that :slightly_smiling_face: then the power meter has to go, to free up a slot for systemair control. Thanks for your answer!

Read through this post at the Rhasspy forum and you MAY be able to assign different device names. Just a little bit of Linux device rules magic.

1 Like

@FredTheFrog I stumbled across this thread, as I was experiencing this problem with two arduino boards bought from Aliexpress.

This was the situation I was facing: I use an Atmega256 with Rflink and a Arduino nano with some sensors connected to the GPIOs. It is known that on restart the OS randomly assigns dev/ttyUSB0 and /dev/ttyUSB1 for two connected serial devices. Usually the solution is to use the ‘by-id’-path, to be certain the right device is addressed. However this time I got two devices which are both: /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0. So in this situation this can’t be used a the serial location and the dev/ttyUSB# seems the only option to use.

However, as said, this gives a problem when restarting the system, whether it keeps working.

In the thread @FredTheFrog was linking to, this link is provided to this wiki article: PersistentUSBDevices - Domoticz

There is a section: Alternative filtering via Devpath which describes the situation of two (arduino clone) devices for which the manufacturer didn’t add proper serial numbers

Alternative filtering via Devpath

When there is a situation with two or more devices with the same vendor ID and productID and there is no serial number, then you can use the options below to add some other way of filtering. In this case we’ll use the dev path, which is the IDs the devices have gotten in the USB hierarchy. The downside of using the devpath is that the devices will always have to stay plugged into the same physical port.

Like above, find the idVendor and idProduct codes by typing lsusb -v. Next, find the devices place in USB hierarchy. You can see this hierarchy by typing:

lsusb -t

This gives an example output of:

Bus 01.Port 1: Dev 1, Class=root_hub, Driver=dwc_otg/1p, 480M
|__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/5p, 480M
|__ Port 1: Dev 3, If 0, Class=Vendor Specific Class, Driver=smsc95xx, 480M
|__ Port 2: Dev 4, If 0, Class=Vendor Specific Class, Driver=ch341, 12M
|__ Port 5: Dev 6, If 0, Class=Vendor Specific Class, Driver=ch341, 12M

The devpath is the port hierachy. So in this specific example, using two cheap Chinese Arduino clones without proper serial numbers on a Raspberry Pi 3, we might add this to the USB Serial Rules file:

SUBSYSTEM==“tty”, ATTRS{idVendor}==“1a86”, ATTRS{idProduct}==“7523”, ATTRS{devpath}==“1.2”, SYMLINK+=“ttyUSB-arduino1”
SUBSYSTEM==“tty”, ATTRS{idVendor}==“1a86”, ATTRS{idProduct}==“7523”, ATTRS{devpath}==“1.5”, SYMLINK+=“ttyUSB-arduino2”

The lsusb -t method mentioned in the wiki article, doesn’t give the wanted information on Home Assistant OS via ssh. But the dmesg output gave among other:

[ 3.912936] usb 1-1.5: new full-speed USB device number 7 using dwc_otg
[ 4.020896] usb 1-1.5: New USB device found, idVendor=1a86, idProduct=7523, bcdDevice= 2.64
[ 4.024756] usb 1-1.5: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[ 4.026492] usb 1-1.5: Product: USB Serial

[ 3.488965] usb 1-1.3: new full-speed USB device number 5 using dwc_otg
[ 3.584302] usb 1-1.3: New USB device found, idVendor=1a86, idProduct=7523, bcdDevice= 2.64
[ 3.591153] usb 1-1.3: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[ 3.593843] usb 1-1.3: Product: USB Serial

There were my Arduino devices.

I am using a Rasperry Pi with an SSD connected via USB as hardware for running Home Assistant OS. By default my laptop, MacOS, isn’t able to read out the filesystem of linux partitions. Therefore I chose to run Raspberry Pi OS on a seperate SD card and after bootup I plugged in my SSD with Home Assistant OS.

As method of connection to the Raspberry Pi OS I used a remote connection via realVNC. Inputted the SSD again, via USB, after bootup and then I was able to add the file
99-usb-serial.rules via terminal within Raspberry Pi OS as a root user (sudo).

The folder /etc/udev/rules.d/ where the 99-usb-serial.rules should be placed is on thehassio-overlay partition.

I changed the 1.2 to 1.3 from the example of the wiki article as in my case this corresponded to the USB port my arduino was in, usb 1-1.3:.

SUBSYSTEM=="tty", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", ATTRS{devpath}=="1.3", SYMLINK+="ttyUSB-arduino1"
SUBSYSTEM=="tty", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", ATTRS{devpath}=="1.5", SYMLINK+="ttyUSB-arduino2"

Chmod 644 on 99-usb-serial.rules might be necessary. It works for me, didn’t check if it was vital.

Then shutdown and removed the SD card of the Pi. Then connected the USB devices again. With the arduino’s in the same ports as they were when the usb1.3 and 1.5 were determined.

Now I am able to refer to the unique addresses of the both arduinos

Alternative method

EDIT: I recently did a a clean install of my system. I am using HAOS. This time I chose the route to do it via terminal, as below.

First I activated the access via terminal with SSH to the host. Note: this is different from the SSH access to the core, which is possible with the SSH addons available in the addon store.
To do this I followed the steps described here: Debugging the Home Assistant Operating System | Home Assistant Developer Docs (create a FAT formatted USB with name CONFIG and add authorized_keys file and restart the host with this)

I changed the port used by the terminal addon in the settings to 22 (not sure if this is necessary, but reckon 22222 is used by the system SSH accesss.)

After this I connected via terminal with root account, with:

ssh [email protected] -p 22222

This will lead to welcome message:


Welcome to Home Assistant OS.

Use `ha` to access the Home Assistant CLI.
#

Note there is a # and not a >. The latter is shown when SSH access is to the core, not the host.

Then I executed, to create a .rules file:

touch etc/etc/udev/rules.d/99-usb-serial.rules

and then opened it with vi editor with the command:

vi /etc/udev/rules.d/99-usb-serial.rules

This showed the vi editor for the file. Hit i (insert) to start editing.

In the file I pasted the two lines:

SUBSYSTEM=="tty", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", ATTRS{devpath}=="1.3", SYMLINK+="ttyUSB-arduino1"
SUBSYSTEM=="tty", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", ATTRS{devpath}=="1.5", SYMLINK+="ttyUSB-arduino2"

When done editing in vi, hit :wq (save and quit).

After that I checked if the contents came trough in the right manner with:

cat /etc/udev/rules.d/99-usb-serial.rules which displays the contents of the file.

Then I changed the permissions with command chmod 644 /etc/udev/rules.d/99-usb-serial.rules

Reboot the host with command reboot

after waiting to startup, login via ssh again with ssh [email protected] -p 22222

hit ls /dev

The assigned symlink names (ttyUSB-arduino1 and ttyUSB-arduino2 or self chosen) should be in the list now.

2 Likes