Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[console] udevprefix.conf not generated after plug-on usb console switch #5943

Closed
Blueve opened this issue Nov 17, 2020 · 23 comments · Fixed by #6039
Closed

[console] udevprefix.conf not generated after plug-on usb console switch #5943

Blueve opened this issue Nov 17, 2020 · 23 comments · Fixed by #6039
Labels

Comments

@Blueve
Copy link
Contributor

Blueve commented Nov 17, 2020

Description

Console switch uses udev rule to mapping usb tty devices to fixed tty device. More detial can be found in this HLD: https://github.com/Azure/SONiC/blob/master/doc/udev-terminalserver/udev%20rules%20for%20Terminal%20Server.md

According to our design in this PR: #5571
A udevprefix.conf file will be put on platform's plugin folder after the usb console switch plugged on, but it not.

I run the script by myself and it works:

admin@sonic:~$ ls /usr/share/sonic/device/x86_64-cel_e1031-r0/plugins/
eeprom.py  eeprom.pyc  pcie.yaml  psuutil.py  sfputil.py

admin@sonic:~$ sudo bash /usr/local/bin/udev_prefix.sh C0-

admin@sonic:~$ ls /usr/share/sonic/device/x86_64-cel_e1031-r0/plugins/
eeprom.py  eeprom.pyc  pcie.yaml  psuutil.py  sfputil.py  udevprefix.conf

Seems like the udev rule not trigger the script correctly?

All above testing are based on master branch's build 492.

Steps to reproduce the issue:

  1. Install image 492
  2. Check /usr/share/sonic/device/x86_64-cel_e1031-r0/plugins/

Describe the results you received:
No udevprefix.conf found

Describe the results you expected:
There is a udevprefix.conf file and the content in it is C0-

Additional information you deem important (e.g. issue happens only occasionally):

**Output of `show version`:**
admin@sonic:~$ show version

SONiC Software Version: SONiC.master.492-e526d889
Distribution: Debian 10.6
Kernel: 4.19.0-9-2-amd64
Build commit: e526d889
Build date: Mon Nov 16 09:08:19 UTC 2020
Built by: johnar@jenkins-worker-8

Platform: x86_64-cel_e1031-r0
HwSKU: Celestica-E1031-T48S4
ASIC: broadcom
Serial Number: R0882B2F160615GD000006
Uptime: 09:11:37 up 48 min,  1 user,  load average: 1.97, 2.48, 2.69

Docker images:
REPOSITORY                    TAG                   IMAGE ID            SIZE
docker-snmp                   latest                b3fbbdf0a732        458MB
docker-snmp                   master.492-e526d889   b3fbbdf0a732        458MB
docker-teamd                  latest                8e784367cc04        454MB
docker-teamd                  master.492-e526d889   8e784367cc04        454MB
docker-sonic-mgmt-framework   latest                efda89429ce3        578MB
docker-sonic-mgmt-framework   master.492-e526d889   efda89429ce3        578MB
docker-router-advertiser      latest                1c08552c349b        421MB
docker-router-advertiser      master.492-e526d889   1c08552c349b        421MB
docker-platform-monitor       latest                6ad8c0548036        534MB
docker-platform-monitor       master.492-e526d889   6ad8c0548036        534MB
docker-lldp                   latest                8f6d86eaaa25        485MB
docker-lldp                   master.492-e526d889   8f6d86eaaa25        485MB
docker-dhcp-relay             latest                876d49713757        428MB
docker-dhcp-relay             master.492-e526d889   876d49713757        428MB
docker-database               latest                3d944ee29d03        421MB
docker-database               master.492-e526d889   3d944ee29d03        421MB
docker-orchagent              latest                4a1f908f059e        468MB
docker-orchagent              master.492-e526d889   4a1f908f059e        468MB
docker-nat                    latest                5d7c8386030e        457MB
docker-nat                    master.492-e526d889   5d7c8386030e        457MB
docker-sonic-telemetry        latest                be95535a4a93        491MB
docker-sonic-telemetry        master.492-e526d889   be95535a4a93        491MB
docker-fpm-frr                latest                f017be17f608        471MB
docker-fpm-frr                master.492-e526d889   f017be17f608        471MB
docker-sflow                  latest                e32a4db2937e        455MB
docker-sflow                  master.492-e526d889   e32a4db2937e        455MB
docker-syncd-brcm             latest                7aacd07f4385        536MB
docker-syncd-brcm             master.492-e526d889   7aacd07f4385        536MB
**Attach debug file `sudo generate_dump`:**

```
(paste your output here)
```
@Blueve
Copy link
Contributor Author

Blueve commented Nov 17, 2020

@sandycelestica could you take a look on this issue?

@sandycelestica
Copy link
Contributor

sandycelestica commented Nov 17, 2020 via email

@Blueve
Copy link
Contributor Author

Blueve commented Nov 17, 2020

This file depends on your udev rules design. Here is an example about how to generate this file. e.g: ACTION=="add" ,KERNEL=="ttyUSB*",SUBSYSTEM=="tty",KERNELS=="1-1.1",ATTRS{idProducc t}=="2517",ATTRS{idVendor}=="0424",RUN+="/bin/bash -c '/usr/local/bin/udev_prefii x.sh C0-'",GOTO="C0 Add" When the device is plugged in, "udev_prefix.sh" would be called .And in udev_prefix.sh it would generate the udevprefix.conf. Here is an example of udev_prefix.sh #!/bin/bashPREV_REBOOT_CAUSE="/host/reboot-cause/"DEVICE="/usr/share/sonic/device"PLATFORM=$(/usr/local/bin/sonic-cfggen -H -v DEVICE_METADATA.localhost.platform)FILES=$DEVICE/$PLATFORM/pluginsFILENAME="udevprefix.conf"if [ "$1" = "clear" ]then if [ -e $FILES/$FILENAME ]; then rm $FILES/$FILENAME fielse if [ -e $FILES/$FILENAME ]; then : > $FILES/$FILENAME echo -n "$1" > $FILES/$FILENAME else touch $FILES/$FILENMAE echo -n "$1" > $FILES/$FILENAME fifi

On Tue, Nov 17, 2020 at 2:20 PM Blueve @.***> wrote: @sandycelestica https://github.com/sandycelestica could you take a look on this issue? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#5943 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALLLGDSWE5TGY4LTXJLOTEDSQIIZRANCNFSM4TYEDRNQ .
-- Thanks and Regards. Sandy Li Software Design Engineering Specialist,GDS SSL Mobile: +86 <+86%20136%201189%204667>18073112486 Email: sandyli@celestica.com gshao@celestica.com www.celestica.com Think Bigger, Reach Further

Hi Sandy, we are using the rule you provided(https://github.com/sandycelestica/sonic-buildimage/blob/master/platform/broadcom/sonic-platform-modules-cel/haliburton/script/50-ttyUSB-C0.rules), seems like the script were not executed when plugged in. But the following SYMLINK added successfully. This issue can be repro on my testbed, is possible to test it on your side?

@sandycelestica
Copy link
Contributor

I tested this before I upload the code. If needed I could set up the environment to reproduce this issue.
Could you please share with me the test log? Including "ls /dev/*", "lsusb" ,"lsusb -t"

@Blueve
Copy link
Contributor Author

Blueve commented Nov 18, 2020

I tested this before I upload the code. If needed I could set up the environment to reproduce this issue.
Could you please share with me the test log? Including "ls /dev/*", "lsusb" ,"lsusb -t"

Yeah. Seems like both LN11 and LN12(https://github.com/sandycelestica/sonic-buildimage/blob/master/platform/broadcom/sonic-platform-modules-cel/haliburton/script/50-ttyUSB-C0.rules#L11,L12) in the rule are not working as expect, but others works fine.

Could you please try below steps on your side?

  1. Unplug the usb connection between E1031 and console switch
admin@sonic:~$ ls /dev/*
/dev/autofs           /dev/linux-bcm-bde     /dev/loop7               /dev/random    /dev/stdout  /dev/tty18  /dev/tty29  /dev/tty4   /dev/tty50  /dev/tty61   /dev/urandom  /dev/vcsa4        /dev/vhost-net
/dev/btrfs-control    /dev/linux-bcm-knet    /dev/loop-control        /dev/rfkill    /dev/tty     /dev/tty19  /dev/tty3   /dev/tty40  /dev/tty51  /dev/tty62   /dev/vcs      /dev/vcsa5        /dev/vhost-vsock
/dev/console          /dev/linux-kernel-bde  /dev/mem                 /dev/rtc       /dev/tty0    /dev/tty2   /dev/tty30  /dev/tty41  /dev/tty52  /dev/tty63   /dev/vcs1     /dev/vcsa6        /dev/watchdog
/dev/core             /dev/linux-knet-cb     /dev/memory_bandwidth    /dev/rtc0      /dev/tty1    /dev/tty20  /dev/tty31  /dev/tty42  /dev/tty53  /dev/tty7    /dev/vcs2     /dev/vcsu         /dev/watchdog0
/dev/cpu_dma_latency  /dev/log               /dev/network_latency     /dev/sda       /dev/tty10   /dev/tty21  /dev/tty32  /dev/tty43  /dev/tty54  /dev/tty8    /dev/vcs3     /dev/vcsu1        /dev/zero
/dev/cuse             /dev/loop0             /dev/network_throughput  /dev/sda1      /dev/tty11   /dev/tty22  /dev/tty33  /dev/tty44  /dev/tty55  /dev/tty9    /dev/vcs4     /dev/vcsu2
/dev/full             /dev/loop1             /dev/null                /dev/sda2      /dev/tty12   /dev/tty23  /dev/tty34  /dev/tty45  /dev/tty56  /dev/ttyS0   /dev/vcs5     /dev/vcsu3
/dev/fuse             /dev/loop2             /dev/port                /dev/sda3      /dev/tty13   /dev/tty24  /dev/tty35  /dev/tty46  /dev/tty57  /dev/ttyS1   /dev/vcs6     /dev/vcsu4
/dev/hpet             /dev/loop3             /dev/ppp                 /dev/sg0       /dev/tty14   /dev/tty25  /dev/tty36  /dev/tty47  /dev/tty58  /dev/ttyS2   /dev/vcsa     /dev/vcsu5
/dev/initctl          /dev/loop4             /dev/psaux               /dev/snapshot  /dev/tty15   /dev/tty26  /dev/tty37  /dev/tty48  /dev/tty59  /dev/ttyS3   /dev/vcsa1    /dev/vcsu6
/dev/kmsg             /dev/loop5             /dev/ptmx                /dev/stderr    /dev/tty16   /dev/tty27  /dev/tty38  /dev/tty49  /dev/tty6   /dev/uhid    /dev/vcsa2    /dev/vga_arbiter
/dev/kvm              /dev/loop6             /dev/ptp0                /dev/stdin     /dev/tty17   /dev/tty28  /dev/tty39  /dev/tty5   /dev/tty60  /dev/uinput  /dev/vcsa3    /dev/vhci

/dev/block:
7:0  7:1  7:2  7:3  7:4  7:5  7:6  7:7  8:0  8:1  8:2  8:3

/dev/bsg:
0:0:0:0

/dev/bus:
usb

/dev/char:
10:1    10:231  10:59  10:63  13:63  1:5    189:1  248:0  4:1   4:13  4:17  4:20  4:24  4:28  4:31  4:35  4:39  4:42  4:46  4:5   4:53  4:57  4:60  4:64  4:7  5:1  7:128  7:132  7:3  7:64  7:68
10:130  10:232  10:60  1:1    13:64  1:7    1:9    249:0  4:10  4:14  4:18  4:21  4:25  4:29  4:32  4:36  4:4   4:43  4:47  4:50  4:54  4:58  4:61  4:65  4:8  5:2  7:129  7:133  7:4  7:65  7:69
10:184  10:235  10:61  1:11   13:65  1:8    21:0   252:0  4:11  4:15  4:19  4:22  4:26  4:3   4:33  4:37  4:40  4:44  4:48  4:51  4:55  4:59  4:62  4:66  4:9  7:0  7:130  7:134  7:5  7:66  7:70
10:228  10:237  10:62  1:3    1:4    189:0  247:0  4:0    4:12  4:16  4:2   4:23  4:27  4:30  4:34  4:38  4:41  4:45  4:49  4:52  4:56  4:6   4:63  4:67  5:0  7:1  7:131  7:2    7:6  7:67

/dev/cpu:
microcode

/dev/disk:
by-id  by-label  by-partlabel  by-partuuid  by-path  by-uuid

/dev/fd:
0  1  2  3

/dev/hugepages:

/dev/input:
by-path  event0  event1  mice

/dev/mapper:
control

/dev/mqueue:

/dev/net:
tun

/dev/pts:
0  ptmx

/dev/shm:

/dev/snd:
seq  timer

/dev/vfio:
vfio
admin@sonic:~$ lsusb
Bus 001 Device 002: ID 8087:07db Intel Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
admin@sonic:~$ lsusb -t
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/8p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M

Ensure there are no udevprefix.rule file exists in plugins folder at this moment.

admin@sonic:~$ ls /usr/share/sonic/device/x86_64-cel_e1031-r0/plugins/
eeprom.py  eeprom.pyc  pcie.yaml  psuutil.py  sfputil.py
  1. Plug in the console switch and wait for 1 minute
admin@sonic:~$ ls /dev/*
/dev/autofs         /dev/C0-27  /dev/C0-46             /dev/linux-knet-cb       /dev/random    /dev/tty15  /dev/tty34  /dev/tty53    /dev/ttyUSB10  /dev/ttyUSB3   /dev/ttyUSB6  /dev/vcsu
/dev/btrfs-control  /dev/C0-28  /dev/C0-47             /dev/log                 /dev/rfkill    /dev/tty16  /dev/tty35  /dev/tty54    /dev/ttyUSB11  /dev/ttyUSB30  /dev/ttyUSB7  /dev/vcsu1
/dev/C0-1           /dev/C0-29  /dev/C0-48             /dev/loop0               /dev/rtc       /dev/tty17  /dev/tty36  /dev/tty55    /dev/ttyUSB12  /dev/ttyUSB31  /dev/ttyUSB8  /dev/vcsu2
/dev/C0-10          /dev/C0-3   /dev/C0-5              /dev/loop1               /dev/rtc0      /dev/tty18  /dev/tty37  /dev/tty56    /dev/ttyUSB13  /dev/ttyUSB32  /dev/ttyUSB9  /dev/vcsu3
/dev/C0-11          /dev/C0-30  /dev/C0-6              /dev/loop2               /dev/sda       /dev/tty19  /dev/tty38  /dev/tty57    /dev/ttyUSB14  /dev/ttyUSB33  /dev/uhid     /dev/vcsu4
/dev/C0-12          /dev/C0-31  /dev/C0-7              /dev/loop3               /dev/sda1      /dev/tty2   /dev/tty39  /dev/tty58    /dev/ttyUSB15  /dev/ttyUSB34  /dev/uinput   /dev/vcsu5
/dev/C0-13          /dev/C0-32  /dev/C0-8              /dev/loop4               /dev/sda2      /dev/tty20  /dev/tty4   /dev/tty59    /dev/ttyUSB16  /dev/ttyUSB35  /dev/urandom  /dev/vcsu6
/dev/C0-14          /dev/C0-33  /dev/C0-9              /dev/loop5               /dev/sda3      /dev/tty21  /dev/tty40  /dev/tty6     /dev/ttyUSB17  /dev/ttyUSB36  /dev/vcs      /dev/vga_arbiter
/dev/C0-15          /dev/C0-34  /dev/console           /dev/loop6               /dev/sg0       /dev/tty22  /dev/tty41  /dev/tty60    /dev/ttyUSB18  /dev/ttyUSB37  /dev/vcs1     /dev/vhci
/dev/C0-16          /dev/C0-35  /dev/core              /dev/loop7               /dev/snapshot  /dev/tty23  /dev/tty42  /dev/tty61    /dev/ttyUSB19  /dev/ttyUSB38  /dev/vcs2     /dev/vhost-net
/dev/C0-17          /dev/C0-36  /dev/cpu_dma_latency   /dev/loop-control        /dev/stderr    /dev/tty24  /dev/tty43  /dev/tty62    /dev/ttyUSB2   /dev/ttyUSB39  /dev/vcs3     /dev/vhost-vsock
/dev/C0-18          /dev/C0-37  /dev/cuse              /dev/mem                 /dev/stdin     /dev/tty25  /dev/tty44  /dev/tty63    /dev/ttyUSB20  /dev/ttyUSB4   /dev/vcs4     /dev/watchdog
/dev/C0-19          /dev/C0-38  /dev/full              /dev/memory_bandwidth    /dev/stdout    /dev/tty26  /dev/tty45  /dev/tty7     /dev/ttyUSB21  /dev/ttyUSB40  /dev/vcs5     /dev/watchdog0
/dev/C0-2           /dev/C0-39  /dev/fuse              /dev/network_latency     /dev/tty       /dev/tty27  /dev/tty46  /dev/tty8     /dev/ttyUSB22  /dev/ttyUSB41  /dev/vcs6     /dev/zero
/dev/C0-20          /dev/C0-4   /dev/hpet              /dev/network_throughput  /dev/tty0      /dev/tty28  /dev/tty47  /dev/tty9     /dev/ttyUSB23  /dev/ttyUSB42  /dev/vcsa
/dev/C0-21          /dev/C0-40  /dev/initctl           /dev/null                /dev/tty1      /dev/tty29  /dev/tty48  /dev/ttyS0    /dev/ttyUSB24  /dev/ttyUSB43  /dev/vcsa1
/dev/C0-22          /dev/C0-41  /dev/kmsg              /dev/port                /dev/tty10     /dev/tty3   /dev/tty49  /dev/ttyS1    /dev/ttyUSB25  /dev/ttyUSB44  /dev/vcsa2
/dev/C0-23          /dev/C0-42  /dev/kvm               /dev/ppp                 /dev/tty11     /dev/tty30  /dev/tty5   /dev/ttyS2    /dev/ttyUSB26  /dev/ttyUSB45  /dev/vcsa3
/dev/C0-24          /dev/C0-43  /dev/linux-bcm-bde     /dev/psaux               /dev/tty12     /dev/tty31  /dev/tty50  /dev/ttyS3    /dev/ttyUSB27  /dev/ttyUSB46  /dev/vcsa4
/dev/C0-25          /dev/C0-44  /dev/linux-bcm-knet    /dev/ptmx                /dev/tty13     /dev/tty32  /dev/tty51  /dev/ttyUSB0  /dev/ttyUSB28  /dev/ttyUSB47  /dev/vcsa5
/dev/C0-26          /dev/C0-45  /dev/linux-kernel-bde  /dev/ptp0                /dev/tty14     /dev/tty33  /dev/tty52  /dev/ttyUSB1  /dev/ttyUSB29  /dev/ttyUSB5   /dev/vcsa6

/dev/block:
7:0  7:1  7:2  7:3  7:4  7:5  7:6  7:7  8:0  8:1  8:2  8:3

/dev/bsg:
0:0:0:0

/dev/bus:
usb

/dev/char:
10:1    10:237  1:11   1:7     188:13  188:2   188:26  188:32  188:39  188:45  188:9   189:20  189:27  249:0  4:13  4:2   4:26  4:32  4:39  4:45  4:51  4:58  4:64  5:0    7:130  7:4   7:68
10:130  10:59   1:3    1:8     188:14  188:20  188:27  188:33  188:4   188:46  189:0   189:21  189:28  252:0  4:14  4:20  4:27  4:33  4:4   4:46  4:52  4:59  4:65  5:1    7:131  7:5   7:69
10:184  10:60   13:63  188:0   188:15  188:21  188:28  188:34  188:40  188:47  189:1   189:22  189:29  4:0    4:15  4:21  4:28  4:34  4:40  4:47  4:53  4:6   4:66  5:2    7:132  7:6   7:70
10:228  10:61   13:64  188:1   188:16  188:22  188:29  188:35  188:41  188:5   189:16  189:23  1:9     4:1    4:16  4:22  4:29  4:35  4:41  4:48  4:54  4:60  4:67  7:0    7:133  7:64
10:231  10:62   13:65  188:10  188:17  188:23  188:3   188:36  188:42  188:6   189:17  189:24  21:0    4:10   4:17  4:23  4:3   4:36  4:42  4:49  4:55  4:61  4:7   7:1    7:134  7:65
10:232  10:63   1:4    188:11  188:18  188:24  188:30  188:37  188:43  188:7   189:18  189:25  247:0   4:11   4:18  4:24  4:30  4:37  4:43  4:5   4:56  4:62  4:8   7:128  7:2    7:66
10:235  1:1     1:5    188:12  188:19  188:25  188:31  188:38  188:44  188:8   189:19  189:26  248:0   4:12   4:19  4:25  4:31  4:38  4:44  4:50  4:57  4:63  4:9   7:129  7:3    7:67

/dev/cpu:
microcode

/dev/disk:
by-id  by-label  by-partlabel  by-partuuid  by-path  by-uuid

/dev/fd:
0  1  2  3

/dev/hugepages:

/dev/input:
by-path  event0  event1  mice

/dev/mapper:
control

/dev/mqueue:

/dev/net:
tun

/dev/pts:
0  ptmx

/dev/serial:
by-id  by-path

/dev/shm:

/dev/snd:
seq  timer

/dev/vfio:
vfio
admin@sonic:~$ lsusb
Bus 001 Device 030: ID 10c4:ea71 Cygnal Integrated Products, Inc. 
Bus 001 Device 029: ID 10c4:ea71 Cygnal Integrated Products, Inc. 
Bus 001 Device 028: ID 10c4:ea71 Cygnal Integrated Products, Inc. 
Bus 001 Device 027: ID 10c4:ea71 Cygnal Integrated Products, Inc. 
Bus 001 Device 026: ID 10c4:ea71 Cygnal Integrated Products, Inc. 
Bus 001 Device 025: ID 10c4:ea71 Cygnal Integrated Products, Inc. 
Bus 001 Device 024: ID 0424:2517 Standard Microsystems Corp. Hub
Bus 001 Device 023: ID 10c4:ea71 Cygnal Integrated Products, Inc. 
Bus 001 Device 022: ID 10c4:ea71 Cygnal Integrated Products, Inc. 
Bus 001 Device 021: ID 10c4:ea71 Cygnal Integrated Products, Inc. 
Bus 001 Device 020: ID 10c4:ea71 Cygnal Integrated Products, Inc. 
Bus 001 Device 019: ID 10c4:ea71 Cygnal Integrated Products, Inc. 
Bus 001 Device 018: ID 10c4:ea71 Cygnal Integrated Products, Inc. 
Bus 001 Device 017: ID 0424:2517 Standard Microsystems Corp. Hub
Bus 001 Device 002: ID 8087:07db Intel Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
admin@sonic:~$ lsusb -t
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/8p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 1: Dev 17, If 0, Class=Hub, Driver=hub/7p, 480M
            |__ Port 1: Dev 18, If 0, Class=Vendor Specific Class, Driver=cp210x, 12M
            |__ Port 1: Dev 18, If 3, Class=Vendor Specific Class, Driver=cp210x, 12M
            |__ Port 1: Dev 18, If 1, Class=Vendor Specific Class, Driver=cp210x, 12M
            |__ Port 1: Dev 18, If 2, Class=Vendor Specific Class, Driver=cp210x, 12M
            |__ Port 2: Dev 19, If 2, Class=Vendor Specific Class, Driver=cp210x, 12M
            |__ Port 2: Dev 19, If 0, Class=Vendor Specific Class, Driver=cp210x, 12M
            |__ Port 2: Dev 19, If 3, Class=Vendor Specific Class, Driver=cp210x, 12M
            |__ Port 2: Dev 19, If 1, Class=Vendor Specific Class, Driver=cp210x, 12M
            |__ Port 3: Dev 20, If 2, Class=Vendor Specific Class, Driver=cp210x, 12M
            |__ Port 3: Dev 20, If 0, Class=Vendor Specific Class, Driver=cp210x, 12M
            |__ Port 3: Dev 20, If 3, Class=Vendor Specific Class, Driver=cp210x, 12M
            |__ Port 3: Dev 20, If 1, Class=Vendor Specific Class, Driver=cp210x, 12M
            |__ Port 4: Dev 21, If 3, Class=Vendor Specific Class, Driver=cp210x, 12M
            |__ Port 4: Dev 21, If 1, Class=Vendor Specific Class, Driver=cp210x, 12M
            |__ Port 4: Dev 21, If 2, Class=Vendor Specific Class, Driver=cp210x, 12M
            |__ Port 4: Dev 21, If 0, Class=Vendor Specific Class, Driver=cp210x, 12M
            |__ Port 5: Dev 22, If 0, Class=Vendor Specific Class, Driver=cp210x, 12M
            |__ Port 5: Dev 22, If 3, Class=Vendor Specific Class, Driver=cp210x, 12M
            |__ Port 5: Dev 22, If 1, Class=Vendor Specific Class, Driver=cp210x, 12M
            |__ Port 5: Dev 22, If 2, Class=Vendor Specific Class, Driver=cp210x, 12M
            |__ Port 6: Dev 23, If 0, Class=Vendor Specific Class, Driver=cp210x, 12M
            |__ Port 6: Dev 23, If 1, Class=Vendor Specific Class, Driver=cp210x, 12M
            |__ Port 6: Dev 23, If 2, Class=Vendor Specific Class, Driver=cp210x, 12M
            |__ Port 6: Dev 23, If 3, Class=Vendor Specific Class, Driver=cp210x, 12M
            |__ Port 7: Dev 24, If 0, Class=Hub, Driver=hub/7p, 480M
                |__ Port 5: Dev 29, If 2, Class=Vendor Specific Class, Driver=cp210x, 12M
                |__ Port 5: Dev 29, If 0, Class=Vendor Specific Class, Driver=cp210x, 12M
                |__ Port 5: Dev 29, If 3, Class=Vendor Specific Class, Driver=cp210x, 12M
                |__ Port 5: Dev 29, If 1, Class=Vendor Specific Class, Driver=cp210x, 12M
                |__ Port 3: Dev 27, If 3, Class=Vendor Specific Class, Driver=cp210x, 12M
                |__ Port 3: Dev 27, If 1, Class=Vendor Specific Class, Driver=cp210x, 12M
                |__ Port 3: Dev 27, If 2, Class=Vendor Specific Class, Driver=cp210x, 12M
                |__ Port 3: Dev 27, If 0, Class=Vendor Specific Class, Driver=cp210x, 12M
                |__ Port 1: Dev 25, If 2, Class=Vendor Specific Class, Driver=cp210x, 12M
                |__ Port 1: Dev 25, If 0, Class=Vendor Specific Class, Driver=cp210x, 12M
                |__ Port 1: Dev 25, If 3, Class=Vendor Specific Class, Driver=cp210x, 12M
                |__ Port 1: Dev 25, If 1, Class=Vendor Specific Class, Driver=cp210x, 12M
                |__ Port 6: Dev 30, If 1, Class=Vendor Specific Class, Driver=cp210x, 12M
                |__ Port 6: Dev 30, If 2, Class=Vendor Specific Class, Driver=cp210x, 12M
                |__ Port 6: Dev 30, If 0, Class=Vendor Specific Class, Driver=cp210x, 12M
                |__ Port 6: Dev 30, If 3, Class=Vendor Specific Class, Driver=cp210x, 12M
                |__ Port 4: Dev 28, If 0, Class=Vendor Specific Class, Driver=cp210x, 12M
                |__ Port 4: Dev 28, If 3, Class=Vendor Specific Class, Driver=cp210x, 12M
                |__ Port 4: Dev 28, If 1, Class=Vendor Specific Class, Driver=cp210x, 12M
                |__ Port 4: Dev 28, If 2, Class=Vendor Specific Class, Driver=cp210x, 12M
                |__ Port 2: Dev 26, If 1, Class=Vendor Specific Class, Driver=cp210x, 12M
                |__ Port 2: Dev 26, If 2, Class=Vendor Specific Class, Driver=cp210x, 12M
                |__ Port 2: Dev 26, If 0, Class=Vendor Specific Class, Driver=cp210x, 12M
                |__ Port 2: Dev 26, If 3, Class=Vendor Specific Class, Driver=cp210x, 12M

And the udevprefix.rule file not generated in below folder.

admin@sonic:~$ ls /usr/share/sonic/device/x86_64-cel_e1031-r0/plugins/
eeprom.py  eeprom.pyc  pcie.yaml  psuutil.py  sfputil.py

@sandycelestica
Copy link
Contributor

sandycelestica commented Nov 18, 2020 via email

@Blueve
Copy link
Contributor Author

Blueve commented Nov 18, 2020

@sandycelestica Thanks for your quick response!

admin@sonic:~$ cat /etc/udev/rules.d/50-ttyUSB-C0.rules
#ACTION=="add",KERNELS=="ttyUSB0",SUBSYSTEMS=="usb-serial",DRIVERS=="cp210x",ATTRS{port_number}=="0",NAME="ttyUSB30",SYMLINK="ttyUSB30"

#ACTION=="add",RUN+="/bin/mkdir test.txt"
#KERNELS=="1-1.1.3",ATTRS{devpath}=="1.1.3",ATTRS{idProduct}=="2303",ATTRS{idVendor}=="067b",SYMLINK+="ttypl2303-%n" 
#ACTION=="add",KERNELS=="1-1.1.3",ATTRS{devpath}=="1.1.3",ATTRS{idProduct}=="2303",ATTRS{idVendor}=="067b",SYMLINK+="ttypl2303",RUN+="/bin/mkdir 123.txt"


LABEL="parent info"
ACTION=="add",KERNEL=="1-1",SUBSYSTEM=="usb",RUN+="/bin/bash -c '/usr/local/bin/udev_prefix.sh clear'"
#ACTION=="add",KERNEL=="ttyUSB*",SUBSYSTEM=="tty",KERNELS=="1-1.1",ATTRS{idProduct}=="2517",ATTRS{idVendor}=="0424",RUN+="/bin/bash -c '/usr/local/bin popmsg.sh 0'",RUN+="/bin/bash -c '/usr/local/bin udev_prefix.sh C0-'",GOTO="C0 Add"
ACTION=="add",KERNEL=="ttyUSB*",SUBSYSTEM=="tty",KERNELS=="1-1.1",ATTRS{idProduct}=="2517",ATTRS{idVendor}=="0424",RUN+="/bin/bash -c '/usr/local/bin/udev_prefix.sh C0-'",GOTO="C0 Add"
ACTION=="remove",KERNELS=="1-1.1",ENV{PRODUCT}=="*424/2517/*",RUN+="/bin/bash -c '/usr/local/bin/udev_prefix.sh clear'",GOTO="C0 Remove"


LABEL="C0 Add"
ACTION=="add",KERNELS=="1-1.1.1:1.0",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="00",ATTRS{interface}=="CP2108 Interface 0",SYMLINK+="C0-1",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.1:1.1",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="01",ATTRS{interface}=="CP2108 Interface 1",SYMLINK+="C0-2",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.1:1.2",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="02",ATTRS{interface}=="CP2108 Interface 2",SYMLINK+="C0-3",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.1:1.3",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="03",ATTRS{interface}=="CP2108 Interface 3",SYMLINK+="C0-4",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.2:1.0",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="00",ATTRS{interface}=="CP2108 Interface 0",SYMLINK+="C0-5",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.2:1.1",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="01",ATTRS{interface}=="CP2108 Interface 1",SYMLINK+="C0-6",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.2:1.2",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="02",ATTRS{interface}=="CP2108 Interface 2",SYMLINK+="C0-7",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.2:1.3",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="03",ATTRS{interface}=="CP2108 Interface 3",SYMLINK+="C0-8",MODE="0666"

ACTION=="add",KERNELS=="1-1.1.3:1.0",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="00",ATTRS{interface}=="CP2108 Interface 0",SYMLINK+="C0-9",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.3:1.1",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="01",ATTRS{interface}=="CP2108 Interface 1",SYMLINK+="C0-10",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.3:1.2",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="02",ATTRS{interface}=="CP2108 Interface 2",SYMLINK+="C0-11",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.3:1.3",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="03",ATTRS{interface}=="CP2108 Interface 3",SYMLINK+="C0-12",MODE="0666"

ACTION=="add",KERNELS=="1-1.1.4:1.0",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="00",ATTRS{interface}=="CP2108 Interface 0",SYMLINK+="C0-13",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.4:1.1",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="01",ATTRS{interface}=="CP2108 Interface 1",SYMLINK+="C0-14",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.4:1.2",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="02",ATTRS{interface}=="CP2108 Interface 2",SYMLINK+="C0-15",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.4:1.3",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="03",ATTRS{interface}=="CP2108 Interface 3",SYMLINK+="C0-16",MODE="0666"

ACTION=="add",KERNELS=="1-1.1.5:1.0",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="00",ATTRS{interface}=="CP2108 Interface 0",SYMLINK+="C0-17",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.5:1.1",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="01",ATTRS{interface}=="CP2108 Interface 1",SYMLINK+="C0-18",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.5:1.2",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="02",ATTRS{interface}=="CP2108 Interface 2",SYMLINK+="C0-19",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.5:1.3",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="03",ATTRS{interface}=="CP2108 Interface 3",SYMLINK+="C0-20",MODE="0666"

ACTION=="add",KERNELS=="1-1.1.6:1.0",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="00",ATTRS{interface}=="CP2108 Interface 0",SYMLINK+="C0-21",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.6:1.1",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="01",ATTRS{interface}=="CP2108 Interface 1",SYMLINK+="C0-22",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.6:1.2",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="02",ATTRS{interface}=="CP2108 Interface 2",SYMLINK+="C0-23",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.6:1.3",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="03",ATTRS{interface}=="CP2108 Interface 3",SYMLINK+="C0-24",MODE="0666"

ACTION=="add",KERNELS=="1-1.1.7.1:1.0",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="00",ATTRS{interface}=="CP2108 Interface 0",SYMLINK+="C0-25",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.7.1:1.1",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="01",ATTRS{interface}=="CP2108 Interface 1",SYMLINK+="C0-26",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.7.1:1.2",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="02",ATTRS{interface}=="CP2108 Interface 2",SYMLINK+="C0-27",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.7.1:1.3",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="03",ATTRS{interface}=="CP2108 Interface 3",SYMLINK+="C0-28",MODE="0666"

ACTION=="add",KERNELS=="1-1.1.7.2:1.0",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="00",ATTRS{interface}=="CP2108 Interface 0",SYMLINK+="C0-29",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.7.2:1.1",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="01",ATTRS{interface}=="CP2108 Interface 1",SYMLINK+="C0-30",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.7.2:1.2",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="02",ATTRS{interface}=="CP2108 Interface 2",SYMLINK+="C0-31",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.7.2:1.3",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="03",ATTRS{interface}=="CP2108 Interface 3",SYMLINK+="C0-32",MODE="0666"

ACTION=="add",KERNELS=="1-1.1.7.3:1.0",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="00",ATTRS{interface}=="CP2108 Interface 0",SYMLINK+="C0-33",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.7.3:1.1",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="01",ATTRS{interface}=="CP2108 Interface 1",SYMLINK+="C0-34",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.7.3:1.2",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="02",ATTRS{interface}=="CP2108 Interface 2",SYMLINK+="C0-35",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.7.3:1.3",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="03",ATTRS{interface}=="CP2108 Interface 3",SYMLINK+="C0-36",MODE="0666"

ACTION=="add",KERNELS=="1-1.1.7.4:1.0",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="00",ATTRS{interface}=="CP2108 Interface 0",SYMLINK+="C0-37",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.7.4:1.1",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="01",ATTRS{interface}=="CP2108 Interface 1",SYMLINK+="C0-38",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.7.4:1.2",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="02",ATTRS{interface}=="CP2108 Interface 2",SYMLINK+="C0-39",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.7.4:1.3",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="03",ATTRS{interface}=="CP2108 Interface 3",SYMLINK+="C0-40",MODE="0666"

ACTION=="add",KERNELS=="1-1.1.7.5:1.0",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="00",ATTRS{interface}=="CP2108 Interface 0",SYMLINK+="C0-41",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.7.5:1.1",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="01",ATTRS{interface}=="CP2108 Interface 1",SYMLINK+="C0-42",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.7.5:1.2",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="02",ATTRS{interface}=="CP2108 Interface 2",SYMLINK+="C0-43",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.7.5:1.3",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="03",ATTRS{interface}=="CP2108 Interface 3",SYMLINK+="C0-44",MODE="0666"

ACTION=="add",KERNELS=="1-1.1.7.6:1.0",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="00",ATTRS{interface}=="CP2108 Interface 0",SYMLINK+="C0-45",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.7.6:1.1",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="01",ATTRS{interface}=="CP2108 Interface 1",SYMLINK+="C0-46",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.7.6:1.2",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="02",ATTRS{interface}=="CP2108 Interface 2",SYMLINK+="C0-47",MODE="0666"
ACTION=="add",KERNELS=="1-1.1.7.6:1.3",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="03",ATTRS{interface}=="CP2108 Interface 3",SYMLINK+="C0-48",MODE="0666"

LABEL="C0 Remove"
ACTION=="remove",KERNELS=="1-1.1.1:1.0",ENV{PRODUCT}=="10c4/ea71/*",RUN+="/bin/bash -c '/usr/local/bin/popmsg.sh 1'"
ACTION=="remove",KERNELS=="1-1.1.1:1.1",ENV{PRODUCT}=="10c4/ea71/*",RUN+="/bin/bash -c '/usr/local/bin/popmsg.sh 2'"
ACTION=="remove",KERNELS=="1-1.1.1:1.2",ENV{PRODUCT}=="10c4/ea71/*",RUN+="/bin/bash -c '/usr/local/bin/popmsg.sh 3'"
ACTION=="remove",KERNELS=="1-1.1.1:1.3",ENV{PRODUCT}=="10c4/ea71/*",RUN+="/bin/bash -c '/usr/local/bin/popmsg.sh 4'"

ACTION=="remove",KERNELS=="1-1.1.2:1.0",ENV{PRODUCT}=="10c4/ea71/*",RUN+="/bin/bash -c '/usr/local/bin/popmsg.sh 5'"
ACTION=="remove",KERNELS=="1-1.1.2:1.1",ENV{PRODUCT}=="10c4/ea71/*",RUN+="/bin/bash -c '/usr/local/bin/popmsg.sh 6'"
ACTION=="remove",KERNELS=="1-1.1.2:1.2",ENV{PRODUCT}=="10c4/ea71/*",RUN+="/bin/bash -c '/usr/local/bin/popmsg.sh 7'"
ACTION=="remove",KERNELS=="1-1.1.2:1.3",ENV{PRODUCT}=="10c4/ea71/*",RUN+="/bin/bash -c '/usr/local/bin/popmsg.sh 8'"

ACTION=="remove",KERNELS=="1-1.1.3:1.0",ENV{PRODUCT}=="10c4/ea71/*",RUN+="/bin/bash -c '/usr/local/bin/popmsg.sh 9'"
ACTION=="remove",KERNELS=="1-1.1.3:1.1",ENV{PRODUCT}=="10c4/ea71/*",RUN+="/bin/bash -c '/usr/local/bin/popmsg.sh 10'"
ACTION=="remove",KERNELS=="1-1.1.3:1.2",ENV{PRODUCT}=="10c4/ea71/*",RUN+="/bin/bash -c '/usr/local/bin/popmsg.sh 11'"
ACTION=="remove",KERNELS=="1-1.1.3:1.3",ENV{PRODUCT}=="10c4/ea71/*",RUN+="/bin/bash -c '/usr/local/bin/popmsg.sh 12'"

ACTION=="remove",KERNELS=="1-1.1.4:1.0",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="00",ATTRS{interface}=="CP2108 Interface 0",RUN+="/usr/local/bin/popmsg.sh 13"
ACTION=="remove",KERNELS=="1-1.1.4:1.1",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="01",ATTRS{interface}=="CP2108 Interface 1",RUN+="/usr/local/bin/popmsg.sh 14"
ACTION=="remove",KERNELS=="1-1.1.4:1.2",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="02",ATTRS{interface}=="CP2108 Interface 2",RUN+="/usr/local/bin/popmsg.sh 15"
ACTION=="remove",KERNELS=="1-1.1.4:1.3",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="03",ATTRS{interface}=="CP2108 Interface 3",RUN+="/usr/local/bin/popmsg.sh 16"

ACTION=="remove",KERNELS=="1-1.1.5:1.0",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="00",ATTRS{interface}=="CP2108 Interface 0",RUN+="/usr/local/bin/popmsg.sh 17"
ACTION=="remove",KERNELS=="1-1.1.5:1.1",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="01",ATTRS{interface}=="CP2108 Interface 1",RUN+="/usr/local/bin/popmsg.sh 18"
ACTION=="remove",KERNELS=="1-1.1.5:1.2",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="02",ATTRS{interface}=="CP2108 Interface 2",RUN+="/usr/local/bin/popmsg.sh 19"
ACTION=="remove",KERNELS=="1-1.1.5:1.3",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="03",ATTRS{interface}=="CP2108 Interface 3",RUN+="/usr/local/bin/popmsg.sh 20"

ACTION=="remove",KERNELS=="1-1.1.6:1.0",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="00",ATTRS{interface}=="CP2108 Interface 0",RUN+="/usr/local/bin/popmsg.sh 21"
ACTION=="remove",KERNELS=="1-1.1.6:1.1",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="01",ATTRS{interface}=="CP2108 Interface 1",RUN+="/usr/local/bin/popmsg.sh 22"
ACTION=="remove",KERNELS=="1-1.1.6:1.2",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="02",ATTRS{interface}=="CP2108 Interface 2",RUN+="/usr/local/bin/popmsg.sh 23"
ACTION=="remove",KERNELS=="1-1.1.6:1.3",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="03",ATTRS{interface}=="CP2108 Interface 3",RUN+="/usr/local/bin/popmsg.sh 24"

ACTION=="remove",KERNELS=="1-1.1.7.1:1.0",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="00",ATTRS{interface}=="CP2108 Interface 0",RUN+="/usr/local/bin/popmsg.sh 25"
ACTION=="remove",KERNELS=="1-1.1.7.1:1.1",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="01",ATTRS{interface}=="CP2108 Interface 1",RUN+="/usr/local/bin/popmsg.sh 26"
ACTION=="remove",KERNELS=="1-1.1.7.1:1.2",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="02",ATTRS{interface}=="CP2108 Interface 2",RUN+="/usr/local/bin/popmsg.sh 27"
ACTION=="remove",KERNELS=="1-1.1.7.1:1.3",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="03",ATTRS{interface}=="CP2108 Interface 3",RUN+="/usr/local/bin/popmsg.sh 28"

ACTION=="remove",KERNELS=="1-1.1.7.2:1.0",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="00",ATTRS{interface}=="CP2108 Interface 0",RUN+="/usr/local/bin/popmsg.sh 29"
ACTION=="remove",KERNELS=="1-1.1.7.2:1.1",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="01",ATTRS{interface}=="CP2108 Interface 1",RUN+="/usr/local/bin/popmsg.sh 30"
ACTION=="remove",KERNELS=="1-1.1.7.2:1.2",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="02",ATTRS{interface}=="CP2108 Interface 2",RUN+="/usr/local/bin/popmsg.sh 31"
ACTION=="remove",KERNELS=="1-1.1.7.2:1.3",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="03",ATTRS{interface}=="CP2108 Interface 3",RUN+="/usr/local/bin/popmsg.sh 32"

ACTION=="remove",KERNELS=="1-1.1.7.3:1.0",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="00",ATTRS{interface}=="CP2108 Interface 0",RUN+="/usr/local/bin/popmsg.sh 33"
ACTION=="remove",KERNELS=="1-1.1.7.3:1.1",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="01",ATTRS{interface}=="CP2108 Interface 1",RUN+="/usr/local/bin/popmsg.sh 34"
ACTION=="remove",KERNELS=="1-1.1.7.3:1.2",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="02",ATTRS{interface}=="CP2108 Interface 2",RUN+="/usr/local/bin/popmsg.sh 35"
ACTION=="remove",KERNELS=="1-1.1.7.3:1.3",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="03",ATTRS{interface}=="CP2108 Interface 3",RUN+="/usr/local/bin/popmsg.sh 36"

ACTION=="remove",KERNELS=="1-1.1.7.4:1.0",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="00",ATTRS{interface}=="CP2108 Interface 0",RUN+="/usr/local/bin/popmsg.sh 37"
ACTION=="remove",KERNELS=="1-1.1.7.4:1.1",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="01",ATTRS{interface}=="CP2108 Interface 1",RUN+="/usr/local/bin/popmsg.sh 38"
ACTION=="remove",KERNELS=="1-1.1.7.4:1.2",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="02",ATTRS{interface}=="CP2108 Interface 2",RUN+="/usr/local/bin/popmsg.sh 39"
ACTION=="remove",KERNELS=="1-1.1.7.4:1.3",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="03",ATTRS{interface}=="CP2108 Interface 3",RUN+="/usr/local/bin/popmsg.sh 40"

ACTION=="remove",KERNELS=="1-1.1.7.5:1.0",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="00",ATTRS{interface}=="CP2108 Interface 0",RUN+="/usr/local/bin/popmsg.sh 41"
ACTION=="remove",KERNELS=="1-1.1.7.5:1.1",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="01",ATTRS{interface}=="CP2108 Interface 1",RUN+="/usr/local/bin/popmsg.sh 42"
ACTION=="remove",KERNELS=="1-1.1.7.5:1.2",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="02",ATTRS{interface}=="CP2108 Interface 2",RUN+="/usr/local/bin/popmsg.sh 43"
ACTION=="remove",KERNELS=="1-1.1.7.5:1.3",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="03",ATTRS{interface}=="CP2108 Interface 3",RUN+="/usr/local/bin/popmsg.sh 44"

ACTION=="remove",KERNELS=="1-1.1.7.6:1.0",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="00",ATTRS{interface}=="CP2108 Interface 0",RUN+="/usr/local/bin/popmsg.sh 45"
ACTION=="remove",KERNELS=="1-1.1.7.6:1.1",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="01",ATTRS{interface}=="CP2108 Interface 1",RUN+="/usr/local/bin/popmsg.sh 46"
ACTION=="remove",KERNELS=="1-1.1.7.6:1.2",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="02",ATTRS{interface}=="CP2108 Interface 2",RUN+="/usr/local/bin/popmsg.sh 47"
ACTION=="remove",KERNELS=="1-1.1.7.6:1.3",DRIVERS=="cp210x",ATTRS{bInterfaceNumber}=="03",ATTRS{interface}=="CP2108 Interface 3",RUN+="/usr/local/bin/popmsg.sh 48"
admin@sonic:~$ cat /usr/local/bin/udev_prefix.sh
#!/bin/bash

PREV_REBOOT_CAUSE="/host/reboot-cause/"
DEVICE="/usr/share/sonic/device"
PLATFORM=$(/usr/local/bin/sonic-cfggen -H -v DEVICE_METADATA.localhost.platform)
FILES=$DEVICE/$PLATFORM/plugins
FILENAME="udevprefix.conf"

if [ "$1" = "clear" ]
then
        if [ -e $FILES/$FILENAME ]; then
                rm $FILES/$FILENAME
        fi
else
        if [ -e $FILES/$FILENAME ]; then
                : > $FILES/$FILENAME 
                echo -n "$1" > $FILES/$FILENAME
        else
                touch $FILES/$FILENMAE
                echo -n "$1" > $FILES/$FILENAME 
        fi
fi

I will try add something to this script tomorrow and get back to you.
I was wondering if there a hardware different or something cause this problem?
Here is my udev detail for ttyUSB0, but I think it should match the rule...

admin@sonic:~$ udevadm info -a -n /dev/ttyUSB0

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/pci0000:00/0000:00:16.0/usb1/1-1/1-1.1/1-1.1.1/1-1.1.1:1.0/ttyUSB0/tty/ttyUSB0':
    KERNEL=="ttyUSB0"
    SUBSYSTEM=="tty"
    DRIVER==""

  looking at parent device '/devices/pci0000:00/0000:00:16.0/usb1/1-1/1-1.1/1-1.1.1/1-1.1.1:1.0/ttyUSB0':
    KERNELS=="ttyUSB0"
    SUBSYSTEMS=="usb-serial"
    DRIVERS=="cp210x"
    ATTRS{port_number}=="0"

  looking at parent device '/devices/pci0000:00/0000:00:16.0/usb1/1-1/1-1.1/1-1.1.1/1-1.1.1:1.0':
    KERNELS=="1-1.1.1:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="cp210x"
    ATTRS{interface}=="CP2108 Interface 0"
    ATTRS{authorized}=="1"
    ATTRS{bInterfaceClass}=="ff"
    ATTRS{bNumEndpoints}=="02"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{bInterfaceNumber}=="00"
    ATTRS{supports_autosuspend}=="1"
    ATTRS{bInterfaceProtocol}=="00"
    ATTRS{bInterfaceSubClass}=="00"

  looking at parent device '/devices/pci0000:00/0000:00:16.0/usb1/1-1/1-1.1/1-1.1.1':
    KERNELS=="1-1.1.1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{maxchild}=="0"
    ATTRS{manufacturer}=="Silicon Labs"
    ATTRS{speed}=="12"
    ATTRS{rx_lanes}=="1"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{idProduct}=="ea71"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{bcdDevice}=="0100"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{removable}=="unknown"
    ATTRS{configuration}==""
    ATTRS{bNumConfigurations}=="1"
    ATTRS{authorized}=="1"
    ATTRS{devpath}=="1.1.1"
    ATTRS{bMaxPower}=="100mA"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{bDeviceClass}=="00"
    ATTRS{product}=="CP2108 Quad USB to UART Bridge"
    ATTRS{urbnum}=="37"
    ATTRS{tx_lanes}=="1"
    ATTRS{quirks}=="0x0"
    ATTRS{serial}=="0001"
    ATTRS{idVendor}=="10c4"
    ATTRS{ltm_capable}=="no"
    ATTRS{bNumInterfaces}==" 4"
    ATTRS{devnum}=="18"
    ATTRS{bmAttributes}=="80"
    ATTRS{version}==" 2.00"
    ATTRS{busnum}=="1"

  looking at parent device '/devices/pci0000:00/0000:00:16.0/usb1/1-1/1-1.1':
    KERNELS=="1-1.1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{idProduct}=="2517"
    ATTRS{manufacturer}=="Celestica"
    ATTRS{speed}=="480"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{removable}=="unknown"
    ATTRS{serial}=="C1010NNN010A22BY200022"
    ATTRS{bMaxPower}=="2mA"
    ATTRS{busnum}=="1"
    ATTRS{urbnum}=="94"
    ATTRS{idVendor}=="0424"
    ATTRS{maxchild}=="7"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{version}==" 2.00"
    ATTRS{tx_lanes}=="1"
    ATTRS{devnum}=="17"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{ltm_capable}=="no"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{rx_lanes}=="1"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bDeviceProtocol}=="02"
    ATTRS{quirks}=="0x0"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bcdDevice}=="0000"
    ATTRS{devpath}=="1.1"
    ATTRS{authorized}=="1"
    ATTRS{product}=="C1010"
    ATTRS{configuration}==""
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bNumConfigurations}=="1"

  looking at parent device '/devices/pci0000:00/0000:00:16.0/usb1/1-1':
    KERNELS=="1-1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{busnum}=="1"
    ATTRS{configuration}==""
    ATTRS{authorized}=="1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{version}==" 2.00"
    ATTRS{maxchild}=="4"
    ATTRS{removable}=="unknown"
    ATTRS{idVendor}=="8087"
    ATTRS{idProduct}=="07db"
    ATTRS{bmAttributes}=="e0"
    ATTRS{quirks}=="0x0"
    ATTRS{bcdDevice}=="0003"
    ATTRS{ltm_capable}=="no"
    ATTRS{bMaxPower}=="0mA"
    ATTRS{rx_lanes}=="1"
    ATTRS{bDeviceProtocol}=="01"
    ATTRS{speed}=="480"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{devnum}=="2"
    ATTRS{urbnum}=="54"
    ATTRS{bDeviceClass}=="09"
    ATTRS{devpath}=="1"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{tx_lanes}=="1"
    ATTRS{avoid_reset_quirk}=="0"

  looking at parent device '/devices/pci0000:00/0000:00:16.0/usb1':
    KERNELS=="usb1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{maxchild}=="8"
    ATTRS{urbnum}=="36"
    ATTRS{serial}=="0000:00:16.0"
    ATTRS{devnum}=="1"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{interface_authorized_default}=="1"
    ATTRS{busnum}=="1"
    ATTRS{authorized}=="1"
    ATTRS{configuration}==""
    ATTRS{idVendor}=="1d6b"
    ATTRS{tx_lanes}=="1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{bmAttributes}=="e0"
    ATTRS{manufacturer}=="Linux 4.19.0-9-2-amd64 ehci_hcd"
    ATTRS{rx_lanes}=="1"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{speed}=="480"
    ATTRS{devpath}=="0"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{removable}=="unknown"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{quirks}=="0x0"
    ATTRS{bcdDevice}=="0419"
    ATTRS{authorized_default}=="1"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{idProduct}=="0002"
    ATTRS{version}==" 2.00"
    ATTRS{product}=="EHCI Host Controller"
    ATTRS{bMaxPower}=="0mA"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{ltm_capable}=="no"

  looking at parent device '/devices/pci0000:00/0000:00:16.0':
    KERNELS=="0000:00:16.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="ehci-pci"
    ATTRS{driver_override}=="(null)"
    ATTRS{dma_mask_bits}=="32"
    ATTRS{local_cpus}=="3"
    ATTRS{device}=="0x1f2c"
    ATTRS{subsystem_device}=="0x7270"
    ATTRS{class}=="0x0c0320"
    ATTRS{uframe_periodic_max}=="100"
    ATTRS{ari_enabled}=="0"
    ATTRS{revision}=="0x03"
    ATTRS{numa_node}=="-1"
    ATTRS{d3cold_allowed}=="1"
    ATTRS{enable}=="1"
    ATTRS{broken_parity_status}=="0"
    ATTRS{vendor}=="0x8086"
    ATTRS{consistent_dma_mask_bits}=="32"
    ATTRS{irq}=="23"
    ATTRS{subsystem_vendor}=="0x8086"
    ATTRS{local_cpulist}=="0-1"
    ATTRS{companion}==""
    ATTRS{msi_bus}=="1"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""

@sandycelestica
Copy link
Contributor

sandycelestica commented Nov 18, 2020 via email

@Blueve
Copy link
Contributor Author

Blueve commented Nov 19, 2020

I tried let the script output something to a file but no luck. Seems like these two rules are not triggered...
I will go deeper to the udev debug logs.. at the mean while?
@sandycelestica Which image are you using now? How about try master 492 on your side?

@sandycelestica
Copy link
Contributor

sandycelestica commented Nov 19, 2020 via email

@Blueve
Copy link
Contributor Author

Blueve commented Nov 19, 2020

@sandycelestica
Copy link
Contributor

sandycelestica commented Nov 19, 2020 via email

@Blueve
Copy link
Contributor Author

Blueve commented Nov 19, 2020

Interest founding:
The rule actually matched but the bash run failed due to permission issue. I thought the udev will using root to execute scirpt?

Mar 22 10:12:31 sonic systemd-udevd[32296]: '/bin/bash -c '/usr/local/bin/udev_prefix.sh clear''(err) '/bin/bash: /usr/local/bin/udev_prefix.sh: Permission denied'
Mar 22 10:12:31 sonic systemd-udevd[32296]: Process '/bin/bash -c '/usr/local/bin/udev_prefix.sh clear'' failed with exit code 126.
Mar 22 10:13:49 sonic systemd-udevd[32416]: '/bin/bash -c '/usr/local/bin/udev_prefix.sh C0-''(err) '/bin/bash: /usr/local/bin/udev_prefix.sh: Permission denied'
Mar 22 10:13:49 sonic systemd-udevd[32416]: Process '/bin/bash -c '/usr/local/bin/udev_prefix.sh C0-'' failed with exit code 126.

The script's attribute is shown below:

admin@sonic:~$ ls -a -l /usr/local/bin/udev_prefix.sh
-rw-r--r-- 1 root root 531 Mar 22 08:21 /usr/local/bin/udev_prefix.sh

After I executed below command manually, the udev rule script works fine.

admin@sonic:~$ sudo chmod +x /usr/local/bin/udev_prefix.sh

@sandycelestica could you share your script's attributes? May be we need to add execution permission to this script after copy it.

@sandycelestica
Copy link
Contributor

sandycelestica commented Nov 19, 2020 via email

@sandycelestica
Copy link
Contributor

sandycelestica commented Nov 19, 2020 via email

@Blueve
Copy link
Contributor Author

Blueve commented Nov 19, 2020

@sandycelestica Do you know where is the best place to add the chmod script? I try searched in this code repo, but seems like there are no sample...

Maybe platform-modules-haliburton.postinst?

@sandycelestica
Copy link
Contributor

sandycelestica commented Nov 19, 2020 via email

@Blueve
Copy link
Contributor Author

Blueve commented Nov 19, 2020

@sandycelestica
Copy link
Contributor

sandycelestica commented Nov 19, 2020 via email

@sandycelestica
Copy link
Contributor

sandycelestica commented Nov 23, 2020 via email

@Blueve
Copy link
Contributor Author

Blueve commented Nov 24, 2020

@sandycelestica Awesome! Could you please sent out the PR? I can link it to this issue and review it : D

@sandycelestica
Copy link
Contributor

sandycelestica commented Nov 25, 2020 via email

@sandycelestica
Copy link
Contributor

sandycelestica commented Nov 25, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment