# Configure use to always be in the same path (udev rules?)

**URL:** <https://forums.balena.io/t/configure-use-to-always-be-in-the-same-path-udev-rules/188709>\
**Category:** Product support\
**Created:** [September 14, 2020, 8:49am UTC](https://forums.balena.io/t/configure-use-to-always-be-in-the-same-path-udev-rules/188709 "2020-09-14T08:49:17Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![query](https://avatars.discourse-cdn.com/v4/letter/q/3ab097/32.png) [@query](https://forums.balena.io/u/query)\
**Post date:** [September 14, 2020, 8:49am UTC](https://forums.balena.io/t/configure-use-to-always-be-in-the-same-path-udev-rules/188709/1 "2020-09-14T08:49:17Z")

</div>

I am having one issue with a USB device, where sometimes it is registered at **/dev/ttyUSB0** and sometimes it is at **/dev/ttyUSB1** , where can I find information to set a custom udev rules to make sure that this device always starts as USB0, for example.

Thank you

---

<div class="post-metadata">

**Author:** ![sradevski](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/sradevski/32/1609_2.png) [@sradevski](https://forums.balena.io/u/sradevski)\
**Post date:** [September 14, 2020, 9:00am UTC](https://forums.balena.io/t/configure-use-to-always-be-in-the-same-path-udev-rules/188709/4 "2020-09-14T09:00:18Z")

</div>

Hi Juan, there are some udev examples here: [https://github.com/tmigone/balena-udev-examples](https://github.com/tmigone/balena-udev-examples). There is [this forum thread](https://forums.balena.io/t/rename-network-interface/31822) about renaming a network interface using udev, but the principle is the same. Let us know if that helps, and feel free to post your findings here so others can benefit as well.

---

<div class="post-metadata">

**Author:** ![query](https://avatars.discourse-cdn.com/v4/letter/q/3ab097/32.png) [@query](https://forums.balena.io/u/query)\
**Post date:** [September 14, 2020, 11:37am UTC](https://forums.balena.io/t/configure-use-to-always-be-in-the-same-path-udev-rules/188709/6 "2020-09-14T11:37:35Z")

</div>

thanks @sradevski, for what I am looking here, both usb0 and usb1 comes from the same FTDI chip.

```auto
root@5517bbd:/dev# udevadm info /dev/ttyUSB0
P: /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/ttyUSB0/tty/ttyUSB0
N: ttyUSB0
L: 0
S: serial/by-path/platform-3f980000.usb-usb-0:1.3:1.0-port0
S: serial/by-id/usb-FTDI_Dual_RS232-HS-if00-port0
E: DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/ttyUSB0/tty/ttyUSB0
E: DEVNAME=/dev/ttyUSB0
E: MAJOR=188
E: MINOR=0
E: SUBSYSTEM=tty
E: USEC_INITIALIZED=11501625
E: ID_VENDOR=FTDI
E: ID_VENDOR_ENC=FTDI
E: ID_VENDOR_ID=0403
E: ID_MODEL=Dual_RS232-HS
E: ID_MODEL_ENC=Dual\x20RS232-HS
E: ID_MODEL_ID=6010
E: ID_REVISION=0700
E: ID_SERIAL=FTDI_Dual_RS232-HS
E: ID_TYPE=generic
E: ID_BUS=usb
E: ID_USB_INTERFACES=:ffffff:
E: ID_USB_INTERFACE_NUM=00
E: ID_USB_DRIVER=ftdi_sio
E: ID_PATH=platform-3f980000.usb-usb-0:1.3:1.0
E: ID_PATH_TAG=platform-3f980000_usb-usb-0_1_3_1_0
E: ID_MM_CANDIDATE=1
E: DEVLINKS=/dev/serial/by-path/platform-3f980000.usb-usb-0:1.3:1.0-port0 /dev/serial/by-id/usb-FTDI_Dual_RS232-HS-if00-port0
E: TAGS=:systemd:

root@5517bbd:/dev# udevadm info /dev/ttyUSB1
P: /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3/1-1.3:1.1/ttyUSB1/tty/ttyUSB1
N: ttyUSB1
L: 0
S: serial/by-id/usb-FTDI_Dual_RS232-HS-if01-port0
S: serial/by-path/platform-3f980000.usb-usb-0:1.3:1.1-port0
E: DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3/1-1.3:1.1/ttyUSB1/tty/ttyUSB1
E: DEVNAME=/dev/ttyUSB1
E: MAJOR=188
E: MINOR=1
E: SUBSYSTEM=tty
E: USEC_INITIALIZED=11503610
E: ID_VENDOR=FTDI
E: ID_VENDOR_ENC=FTDI
E: ID_VENDOR_ID=0403
E: ID_MODEL=Dual_RS232-HS
E: ID_MODEL_ENC=Dual\x20RS232-HS
E: ID_MODEL_ID=6010
E: ID_REVISION=0700
E: ID_SERIAL=FTDI_Dual_RS232-HS
E: ID_TYPE=generic
E: ID_BUS=usb
E: ID_USB_INTERFACES=:ffffff:
E: ID_USB_INTERFACE_NUM=01
E: ID_USB_DRIVER=ftdi_sio
E: ID_PATH=platform-3f980000.usb-usb-0:1.3:1.1
E: ID_PATH_TAG=platform-3f980000_usb-usb-0_1_3_1_1
E: ID_MM_CANDIDATE=1
E: DEVLINKS=/dev/serial/by-id/usb-FTDI_Dual_RS232-HS-if01-port0 /dev/serial/by-path/platform-3f980000.usb-usb-0:1.3:1.1-port0
E: TAGS=:systemd:

```

So the udev rules should be something like:  
`"os":{ "udevRules": { "10" : "ACTION==\"add\", SUBSYSTEM==\"tty\", ENV{MAJOR}==\"0188\", ENV{MINOR}==\"0\", NAME=\"USB0\"" } },` ?

Thanks

---

<div class="post-metadata">

**Author:** ![floion](https://avatars.discourse-cdn.com/v4/letter/f/45deac/32.png) [@floion](https://forums.balena.io/u/floion)\
**Post date:** [September 14, 2020, 9:14pm UTC](https://forums.balena.io/t/configure-use-to-always-be-in-the-same-path-udev-rules/188709/7 "2020-09-14T21:14:40Z")

</div>

Do you have connected multiple of these ftdi chips? If you would have something already connected that gets assigned the ttyUSB0 devname then if you next connect your usb serial adapter it will naturally be assigned ttyUSB1.  
So please share more about your usecase

---

<div class="post-metadata">

**Author:** ![query](https://avatars.discourse-cdn.com/v4/letter/q/3ab097/32.png) [@query](https://forums.balena.io/u/query)\
**Post date:** [September 14, 2020, 9:27pm UTC](https://forums.balena.io/t/configure-use-to-always-be-in-the-same-path-udev-rules/188709/8 "2020-09-14T21:27:28Z")

</div>

So right now there is only one things connected to the ftdi chip.  
But one thing that I noticed, sometimes if I turn the usb device (it’s a modbusrtu device) and then I turn on the raspberry pi, it assigns the ttyUSB1 to it. Which then I would have to change in the code to connect to.

---

<div class="post-metadata">

**Author:** ![floion](https://avatars.discourse-cdn.com/v4/letter/f/45deac/32.png) [@floion](https://forums.balena.io/u/floion)\
**Post date:** [September 14, 2020, 10:49pm UTC](https://forums.balena.io/t/configure-use-to-always-be-in-the-same-path-udev-rules/188709/9 "2020-09-14T22:49:33Z")

</div>

Can you share the `dmesg` from your rpi when you ttySUB1 gets assigned please?

---

<div class="post-metadata">

**Author:** ![query](https://avatars.discourse-cdn.com/v4/letter/q/3ab097/32.png) [@query](https://forums.balena.io/u/query)\
**Post date:** [September 15, 2020, 1:42pm UTC](https://forums.balena.io/t/configure-use-to-always-be-in-the-same-path-udev-rules/188709/11 "2020-09-15T13:42:09Z")

</div>

> [@floion](#):
>
> `dmesg`

Here you have when it’s connected to usb0 and usb1

[https://hastebin.com/nabajowusu](https://hastebin.com/nabajowusu)

Thank you

---

<div class="post-metadata">

**Author:** ![ab77](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/ab77/32/2870_2.png) [@ab77](https://forums.balena.io/u/ab77)\
**Post date:** [September 15, 2020, 11:50pm UTC](https://forums.balena.io/t/configure-use-to-always-be-in-the-same-path-udev-rules/188709/12 "2020-09-15T23:50:18Z")

</div>

Unable to test due to not having the hardware on hand, but something like this maybe?

```auto
SUBSYSTEM=="tty", ENV{ID_VENDOR_ID}=="0403", ENV{ID_MODEL_ID}=="6010", ENV{ID_SERIAL}=="FTDI_Dual_RS232-HS", ENV{ID_USB_INTERFACE_NUM}=="00", SYMLINK+="serial/ttyUSB_port0"

SUBSYSTEM=="tty", ENV{ID_VENDOR_ID}=="0403", ENV{ID_MODEL_ID}=="6010", ENV{ID_SERIAL}=="FTDI_Dual_RS232-HS", ENV{ID_USB_INTERFACE_NUM}=="01", SYMLINK+="serial/ttyUSB_port1"

```

Source: [https://gist.github.com/laanwj/fb8774b5ca9cd1517df2cd09f0fd0b61](https://gist.github.com/laanwj/fb8774b5ca9cd1517df2cd09f0fd0b61)

---

<div class="post-metadata">

**Author:** ![query](https://avatars.discourse-cdn.com/v4/letter/q/3ab097/32.png) [@query](https://forums.balena.io/u/query)\
**Post date:** [September 16, 2020, 10:11am UTC](https://forums.balena.io/t/configure-use-to-always-be-in-the-same-path-udev-rules/188709/14 "2020-09-16T10:11:34Z")

</div>

I will give it a try, thank you very much!

---

<div class="post-metadata">

**Author:** ![query](https://avatars.discourse-cdn.com/v4/letter/q/3ab097/32.png) [@query](https://forums.balena.io/u/query)\
**Post date:** [September 16, 2020, 1:57pm UTC](https://forums.balena.io/t/configure-use-to-always-be-in-the-same-path-udev-rules/188709/16 "2020-09-16T13:57:29Z")

</div>

No dice.  
What’s the best way to know which usb is being configured, or how would you advice to proceed with the investigation to fix this?

Thank you

---

<div class="post-metadata">

**Author:** ![query](https://avatars.discourse-cdn.com/v4/letter/q/3ab097/32.png) [@query](https://forums.balena.io/u/query)\
**Post date:** [September 16, 2020, 1:59pm UTC](https://forums.balena.io/t/configure-use-to-always-be-in-the-same-path-udev-rules/188709/17 "2020-09-16T13:59:48Z")

</div>

Also I see that sometimes the GSM Modem is being connected to USB0, what if I force the GSM to be on USB1 instead?

---

<div class="post-metadata">

**Author:** ![floion](https://avatars.discourse-cdn.com/v4/letter/f/45deac/32.png) [@floion](https://forums.balena.io/u/floion)\
**Post date:** [September 16, 2020, 7:56pm UTC](https://forums.balena.io/t/configure-use-to-always-be-in-the-same-path-udev-rules/188709/20 "2020-09-16T19:56:32Z")

</div>

Hi, if you can share the link to your device and enable support access, we can have a look and test a few things on your device. We’d also need permission to reboot the machine possibly

---

<div class="post-metadata">

**Author:** ![saintaardvark](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/saintaardvark/32/3390_2.png) [@saintaardvark](https://forums.balena.io/u/saintaardvark)\
**Post date:** [September 17, 2020, 12:49am UTC](https://forums.balena.io/t/configure-use-to-always-be-in-the-same-path-udev-rules/188709/21 "2020-09-17T00:49:24Z")

</div>

Hi there – taking another look at your boot messages ([https://hastebin.com/nabajowusu](https://hastebin.com/nabajowusu)), it looks like the USB Serial and the GSM modem are indeed getting enumerated differently each time as you suggested. In the first message, the serial ports were assigned to usb0 and usb2, and the GSM got usb1, usb3, usb4 and usb5. In the second, the GSM got usb0, usb1, usb2 and usb3, while the serial ports got usb4 and usb5.

Can you try adding udev rules for both devices and let us know how it goes? That may sort out the problem.

Thanks,  
Hugh

---

<div class="post-metadata">

**Author:** ![query](https://avatars.discourse-cdn.com/v4/letter/q/3ab097/32.png) [@query](https://forums.balena.io/u/query)\
**Post date:** [September 17, 2020, 8:17am UTC](https://forums.balena.io/t/configure-use-to-always-be-in-the-same-path-udev-rules/188709/23 "2020-09-17T08:17:18Z")

</div>

> [@saintaardvark](#):
>
> it looks like the USB Serial and the GSM mode

of course, here is the device (i’m just pushing the update and gonna leave like that for a bit). Thank you

> **[balena dashboard](https://dashboard.balena-cloud.com/devices/fcda6541989d61c44ceb604ada1758de/summary)**
>
> Sign in to monitor and manage your device fleet from the balena dashboard.

---

<div class="post-metadata">

**Author:** ![query](https://avatars.discourse-cdn.com/v4/letter/q/3ab097/32.png) [@query](https://forums.balena.io/u/query)\
**Post date:** [September 17, 2020, 8:18am UTC](https://forums.balena.io/t/configure-use-to-always-be-in-the-same-path-udev-rules/188709/24 "2020-09-17T08:18:02Z")

</div>

Will do, could you help me build the udev rules? 😅

---

<div class="post-metadata">

**Author:** ![anujdeshpande](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/anujdeshpande/32/3155_2.png) [@anujdeshpande](https://forums.balena.io/u/anujdeshpande)\
**Post date:** [September 17, 2020, 8:21am UTC](https://forums.balena.io/t/configure-use-to-always-be-in-the-same-path-udev-rules/188709/26 "2020-09-17T08:21:58Z")

</div>

Hi

One of my colleagues has created a handy repo with example containers and a blog to go along with that. See

- [https://github.com/tmigone/balena-udev-examples](https://github.com/tmigone/balena-udev-examples)
- [https://medium.com/@tomasmigone/hot-plugging-usb-devices-in-balenaos-5dca4b05ca7e](https://medium.com/@tomasmigone/hot-plugging-usb-devices-in-balenaos-5dca4b05ca7e)

This should help you configure the udev rules correctly for your devices

---

<div class="post-metadata">

**Author:** ![query](https://avatars.discourse-cdn.com/v4/letter/q/3ab097/32.png) [@query](https://forums.balena.io/u/query)\
**Post date:** [September 17, 2020, 4:29pm UTC](https://forums.balena.io/t/configure-use-to-always-be-in-the-same-path-udev-rules/188709/28 "2020-09-17T16:29:06Z")

</div>

```auto
udevadm info /dev/ttyUSB0
P: /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.0/ttyUSB0/tty/ttyUSB0
N: ttyUSB0
L: 0
S: serial/by-path/platform-3f980000.usb-usb-0:1.4:1.0-port0
S: serial/by-id/usb-Android_Android-if00-port0
E: DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.0/ttyUSB0/tty/ttyUSB0
E: DEVNAME=/dev/ttyUSB0
E: MAJOR=188
E: MINOR=0
E: SUBSYSTEM=tty
E: USEC_INITIALIZED=2585713782
E: ID_VENDOR=Android
E: ID_VENDOR_ENC=Android
E: ID_VENDOR_ID=2c7c
E: ID_MODEL=Android
E: ID_MODEL_ENC=Android
E: ID_MODEL_ID=0125
E: ID_REVISION=0318
E: ID_SERIAL=Android_Android
E: ID_TYPE=generic
E: ID_BUS=usb
E: ID_USB_INTERFACES=:ffffff:ff0000:
E: ID_USB_INTERFACE_NUM=00
E: ID_USB_DRIVER=option
E: ID_USB_CLASS_FROM_DATABASE=Miscellaneous Device
E: ID_USB_PROTOCOL_FROM_DATABASE=Interface Association
E: ID_VENDOR_FROM_DATABASE=Quectel Wireless Solutions Co., Ltd.
E: ID_MODEL_FROM_DATABASE=EC25 LTE modem
E: ID_PATH=platform-3f980000.usb-usb-0:1.4:1.0
E: ID_PATH_TAG=platform-3f980000_usb-usb-0_1_4_1_0
E: DEVLINKS=/dev/serial/by-path/platform-3f980000.usb-usb-0:1.4:1.0-port0 /dev/serial/by-id/usb-Android_Android-if00-port0

```

Then for the other device whicih should be usb0

```auto
P: /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/ttyUSB1/tty/ttyUSB1
N: ttyUSB1
L: 0
S: serial/by-path/platform-3f980000.usb-usb-0:1.3:1.0-port0
S: serial/by-id/usb-FTDI_Dual_RS232-HS-if00-port0
E: DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/ttyUSB1/tty/ttyUSB1
E: DEVNAME=/dev/ttyUSB1
E: MAJOR=188
E: MINOR=1
E: SUBSYSTEM=tty
E: USEC_INITIALIZED=2585562550
E: ID_VENDOR=FTDI
E: ID_VENDOR_ENC=FTDI
E: ID_VENDOR_ID=0403
E: ID_MODEL=Dual_RS232-HS
E: ID_MODEL_ENC=Dual\x20RS232-HS
E: ID_MODEL_ID=6010
E: ID_REVISION=0700
E: ID_SERIAL=FTDI_Dual_RS232-HS
E: ID_TYPE=generic
E: ID_BUS=usb
E: ID_USB_INTERFACES=:ffffff:
E: ID_USB_INTERFACE_NUM=00
E: ID_USB_DRIVER=ftdi_sio
E: ID_VENDOR_FROM_DATABASE=Future Technology Devices International, Ltd
E: ID_MODEL_FROM_DATABASE=FT2232C/D/H Dual UART/FIFO IC
E: ID_PATH=platform-3f980000.usb-usb-0:1.3:1.0
E: ID_PATH_TAG=platform-3f980000_usb-usb-0_1_3_1_0
E: DEVLINKS=/dev/serial/by-path/platform-3f980000.usb-usb-0:1.3:1.0-port0 /dev/serial/by-id/usb-FTDI_Dual_RS232-HS-if00-port0

```

The udev rules that I tried are:

```auto
SUBSYSTEM=="tty", ENV{ID_VENDOR}=="FTDI", ENV{ID_SERIAL}=="FTDI_Dual_RS232-HS", SYMLINK+="ttyUSB0"
SUBSYSTEM=="tty", ENV{ID_VENDOR_FROM_DATABASE}=="Quectel Wireless Solutions Co., Ltd.", ENV{ID_MODEL_FROM_DATABASE}=="EC25 LTE modem", SYMLINK+="ttyUSB1"

```

Btut when the system boots, it still doesn’t get recognized.

---

<div class="post-metadata">

**Author:** ![zvin](https://avatars.discourse-cdn.com/v4/letter/z/a5b964/32.png) [@zvin](https://forums.balena.io/u/zvin)\
**Post date:** [September 17, 2020, 4:53pm UTC](https://forums.balena.io/t/configure-use-to-always-be-in-the-same-path-udev-rules/188709/29 "2020-09-17T16:53:50Z")

</div>

Hello,  
Have you tried using `/dev/serial/by-id/usb-Android_Android-if00-port0` and `/dev/serial/by-id/usb-FTDI_Dual_RS232-HS-if00-port0` instead of `/dev/ttyUSB0` and `/dev/ttyUSB1`.  
That would solve your issue without adding new udev rules.

---

<div class="post-metadata">

**Author:** ![query](https://avatars.discourse-cdn.com/v4/letter/q/3ab097/32.png) [@query](https://forums.balena.io/u/query)\
**Post date:** [September 17, 2020, 5:51pm UTC](https://forums.balena.io/t/configure-use-to-always-be-in-the-same-path-udev-rules/188709/31 "2020-09-17T17:51:25Z")

</div>

Hey there, this actually solves the problem!  
I will test it further during tomorrow and next week!  
Thank you a bunch 🙂

---

<div class="post-metadata">

**Author:** ![tmigone](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/tmigone/32/2814_2.png) [@tmigone](https://forums.balena.io/u/tmigone)\
**Post date:** [September 17, 2020, 7:27pm UTC](https://forums.balena.io/t/configure-use-to-always-be-in-the-same-path-udev-rules/188709/32 "2020-09-17T19:27:14Z")

</div>

Glad to know it worked, let us know how your testing goes!

[Next page](https://forums.balena.io/t/configure-use-to-always-be-in-the-same-path-udev-rules/188709.md?page=2)
