Skip to contentSkip to conversation

systemd: Add udev rules for persistent naming of the can devices

PATCH New Aniket Limaye 1 participant 1 message Feb 9, 2024

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 systemd: Add udev rules for persistent naming of the can devices

When multiple CAN's are present, then names that are getting assigned change after every boot even after providing alias in the device tree.
So add udev rules to specify the interface name to use for each mcan device, to make it persistent across reboots.

---
v5: Just simply package all udev rules for all platforms
v4:
- Reformat patch to avoid repeated code for k3 devices
- Add udev rules for dra7xx and ti33x too, as suggested
- Still keeping separate files per platform to avoid potential confusion created by merging all the rules into one file
v3: Fix typos in the filename being installed in v2
v2:
- Switch to udev rules instead of systemd network links, as per feedback from v1: https://lists.yoctoproject.org/g/meta-arago/message/15104
- Also, extend to Sitara devices as well

---
 .../systemd/systemd/37-can-am62.rules         |  4 ++++
 .../systemd/systemd/37-can-dra7.rules         |  2 ++
 .../systemd/systemd/37-can-j7.rules           | 20 +++++++++++++++++++
 .../systemd/systemd/37-can-ti33x.rules        |  2 ++
 .../recipes-core/systemd/systemd_%.bbappend   | 18 +++++++++++++++++
 5 files changed, 46 insertions(+)
 create mode 100644 meta-arago-distro/recipes-core/systemd/systemd/37-can-am62.rules
 create mode 100644 meta-arago-distro/recipes-core/systemd/systemd/37-can-dra7.rules
 create mode 100644 meta-arago-distro/recipes-core/systemd/systemd/37-can-j7.rules
 create mode 100644 meta-arago-distro/recipes-core/systemd/systemd/37-can-ti33x.rules
meta-arago-distro/recipes-core/systemd/systemd/37-can-am62.rules new file +4 -0
new file mode 100644
index 00000000..59dc8075
@@ -0,0 +1,4 @@
+SUBSYSTEM=="net", ACTION=="add", KERNELS=="4e08000.can", NAME="mcu_mcan0"
+SUBSYSTEM=="net", ACTION=="add", KERNELS=="4e18000.can", NAME="mcu_mcan1"
+SUBSYSTEM=="net", ACTION=="add", KERNELS=="20701000.can", NAME="main_mcan0"
+SUBSYSTEM=="net", ACTION=="add", KERNELS=="20711000.can", NAME="main_mcan1"
meta-arago-distro/recipes-core/systemd/systemd/37-can-dra7.rules new file +2 -0
new file mode 100644
index 00000000..3b14150d
@@ -0,0 +1,2 @@
+SUBSYSTEM=="net", ACTION=="add", KERNELS=="4ae3c000.can", NAME="main_dcan1"
+SUBSYSTEM=="net", ACTION=="add", KERNELS=="48480000.can", NAME="main_dcan2"
meta-arago-distro/recipes-core/systemd/systemd/37-can-j7.rules new file +20 -0
new file mode 100644
index 00000000..f2804ecd
@@ -0,0 +1,20 @@
+SUBSYSTEM=="net", ACTION=="add", KERNELS=="40528000.can", NAME="mcu_mcan0"
+SUBSYSTEM=="net", ACTION=="add", KERNELS=="40568000.can", NAME="mcu_mcan1"
+SUBSYSTEM=="net", ACTION=="add", KERNELS=="2701000.can", NAME="main_mcan0"
+SUBSYSTEM=="net", ACTION=="add", KERNELS=="2711000.can", NAME="main_mcan1"
+SUBSYSTEM=="net", ACTION=="add", KERNELS=="2721000.can", NAME="main_mcan2"
+SUBSYSTEM=="net", ACTION=="add", KERNELS=="2731000.can", NAME="main_mcan3"
+SUBSYSTEM=="net", ACTION=="add", KERNELS=="2741000.can", NAME="main_mcan4"
+SUBSYSTEM=="net", ACTION=="add", KERNELS=="2751000.can", NAME="main_mcan5"
+SUBSYSTEM=="net", ACTION=="add", KERNELS=="2761000.can", NAME="main_mcan6"
+SUBSYSTEM=="net", ACTION=="add", KERNELS=="2771000.can", NAME="main_mcan7"
+SUBSYSTEM=="net", ACTION=="add", KERNELS=="2781000.can", NAME="main_mcan8"
+SUBSYSTEM=="net", ACTION=="add", KERNELS=="2791000.can", NAME="main_mcan9"
+SUBSYSTEM=="net", ACTION=="add", KERNELS=="27a1000.can", NAME="main_mcan10"
+SUBSYSTEM=="net", ACTION=="add", KERNELS=="27b1000.can", NAME="main_mcan11"
+SUBSYSTEM=="net", ACTION=="add", KERNELS=="27c1000.can", NAME="main_mcan12"
+SUBSYSTEM=="net", ACTION=="add", KERNELS=="27d1000.can", NAME="main_mcan13"
+SUBSYSTEM=="net", ACTION=="add", KERNELS=="2681000.can", NAME="main_mcan14"
+SUBSYSTEM=="net", ACTION=="add", KERNELS=="2691000.can", NAME="main_mcan15"
+SUBSYSTEM=="net", ACTION=="add", KERNELS=="26a1000.can", NAME="main_mcan16"
+SUBSYSTEM=="net", ACTION=="add", KERNELS=="26b1000.can", NAME="main_mcan17"
meta-arago-distro/recipes-core/systemd/systemd/37-can-ti33x.rules new file +2 -0
new file mode 100644
index 00000000..62d650fe
@@ -0,0 +1,2 @@
+SUBSYSTEM=="net", ACTION=="add", KERNELS=="481cc000.can", NAME="main_dcan0"
+SUBSYSTEM=="net", ACTION=="add", KERNELS=="481d0000.can", NAME="main_dcan1"
meta-arago-distro/recipes-core/systemd/systemd_%.bbappend +18 -0
index f38606f2..40aa393b 100644
@@ -12,6 +12,10 @@ SRC_URI:append = " \
     file://60-usb.network \
     file://sync-clocks.service \
     file://timesyncd.conf \
+    file://37-can-j7.rules \
+    file://37-can-am62.rules \
+    file://37-can-dra7.rules \
+    file://37-can-ti33x.rules \
 "
 
 do_install:append() {
@@ -42,4 +46,18 @@ do_install:append() {
 
     install -d ${D}${sysconfdir}/systemd/
     install -m 0644 ${WORKDIR}/timesyncd.conf ${D}${sysconfdir}/systemd/
+
+    install -d ${D}${libdir}/udev/rules.d
+    install -m 0644 ${WORKDIR}/37-can-j7.rules ${D}${libdir}/udev/rules.d/
+    install -m 0644 ${WORKDIR}/37-can-am62.rules ${D}${libdir}/udev/rules.d/
+    install -m 0644 ${WORKDIR}/37-can-dra7.rules ${D}${libdir}/udev/rules.d/
+    install -m 0644 ${WORKDIR}/37-can-ti33x.rules ${D}${libdir}/udev/rules.d/
 }
+
+FILES:udev += " \
+    ${libdir}/udev/rules.d/37-can-j7.rules \
+    ${libdir}/udev/rules.d/37-can-am62.rules \
+    ${libdir}/udev/rules.d/37-can-dra7.rules \
+    ${libdir}/udev/rules.d/37-can-ti33x.rules \
+"
+
Signature · 1 line
2.34.1