meta-arago.lists.yoctoproject.org archive mirror
 help / color / mirror / Atom feed
* [meta-arago][kirkstone/master][PATCH v2] systemd: Add udev rules for persistent naming of the can devices
@ 2024-02-07 19:22 Aniket Limaye
  0 siblings, 0 replies; only message in thread
From: Aniket Limaye @ 2024-02-07 19:22 UTC (permalink / raw)
  To: meta-arago; +Cc: reatmon, Aniket Limaye, Bhavya Kapoor

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.

Signed-off-by: Bhavya Kapoor <b-kapoor@ti.com>
Signed-off-by: Aniket Limaye <a-limaye@ti.com>
---
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/k3/37-can-am62.rules      |  4 ++
 .../systemd/systemd/k3/37-can-j7.rules        | 20 +++++++
 .../recipes-core/systemd/systemd_%.bbappend   | 58 +++++++++++++++++++
 3 files changed, 82 insertions(+)
 create mode 100644 meta-arago-distro/recipes-core/systemd/systemd/k3/37-can-am62.rules
 create mode 100644 meta-arago-distro/recipes-core/systemd/systemd/k3/37-can-j7.rules

diff --git a/meta-arago-distro/recipes-core/systemd/systemd/k3/37-can-am62.rules b/meta-arago-distro/recipes-core/systemd/systemd/k3/37-can-am62.rules
new file mode 100644
index 00000000..59dc8075
--- /dev/null
+++ b/meta-arago-distro/recipes-core/systemd/systemd/k3/37-can-am62.rules
@@ -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"
diff --git a/meta-arago-distro/recipes-core/systemd/systemd/k3/37-can-j7.rules b/meta-arago-distro/recipes-core/systemd/systemd/k3/37-can-j7.rules
new file mode 100644
index 00000000..f2804ecd
--- /dev/null
+++ b/meta-arago-distro/recipes-core/systemd/systemd/k3/37-can-j7.rules
@@ -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"
diff --git a/meta-arago-distro/recipes-core/systemd/systemd_%.bbappend b/meta-arago-distro/recipes-core/systemd/systemd_%.bbappend
index f38606f2..04460220 100644
--- a/meta-arago-distro/recipes-core/systemd/systemd_%.bbappend
+++ b/meta-arago-distro/recipes-core/systemd/systemd_%.bbappend
@@ -14,6 +14,11 @@ SRC_URI:append = " \
     file://timesyncd.conf \
 "
 
+SRC_URI:append:k3 = " \
+    file://37-can-j7.rules \
+    file://37-can-am62.rules \
+"
+
 do_install:append() {
     install -d ${D}${sysconfdir}/udev/rules.d/
     install -m 0644 ${WORKDIR}/local.rules ${D}${sysconfdir}/udev/rules.d/
@@ -43,3 +48,56 @@ do_install:append() {
     install -d ${D}${sysconfdir}/systemd/
     install -m 0644 ${WORKDIR}/timesyncd.conf ${D}${sysconfdir}/systemd/
 }
+
+do_install:append:j721e() {
+    install -d ${D}/${libdir}/udev/rules.d
+    install -m 0644 ${WORKDIR}/37-can-j7.rules ${D}${libdir}/udev/rules.d/37-can.rules
+}
+
+do_install:append:j7200() {
+    install -d ${D}/${libdir}/udev/rules.d
+    install -m 0644 ${WORKDIR}/37-can-j7.rules ${D}${libdir}/udev/rules.d/37-can.rules
+}
+
+do_install:append:j721s2() {
+    install -d ${D}/${libdir}/udev/rules.d
+    install -m 0644 ${WORKDIR}/37-can-j7.rules ${D}${libdir}/udev/rules.d/37-can.rules
+}
+
+do_install:append:j784s4() {
+    install -d ${D}/${libdir}/udev/rules.d
+    install -m 0644 ${WORKDIR}/37-can-j7.rules ${D}${libdir}/udev/rules.d/37-can.rules
+}
+
+do_install:append:am65xx() {
+    install -d ${D}/${libdir}/udev/rules.d
+    install -m 0644 ${WORKDIR}/37-can-j7.rules ${D}${libdir}/udev/rules.d/37-can.rules
+}
+
+do_install:append:am62xx() {
+    install -d ${D}/${libdir}/udev/rules.d
+    install -m 0644 ${WORKDIR}/37-can-am62xx.rules ${D}${libdir}/udev/rules.d/37-can.rules
+}
+
+do_install:append:am62pxx() {
+    install -d ${D}/${libdir}/udev/rules.d
+    install -m 0644 ${WORKDIR}/37-can-am62xx.rules ${D}${libdir}/udev/rules.d/37-can.rules
+}
+
+do_install:append:am62axx() {
+    install -d ${D}/${libdir}/udev/rules.d
+    install -m 0644 ${WORKDIR}/37-can-am62xx.rules ${D}${libdir}/udev/rules.d/37-can.rules
+}
+
+do_install:append:am64xx() {
+    install -d ${D}/${libdir}/udev/rules.d
+    install -m 0644 ${WORKDIR}/37-can-am62xx.rules ${D}${libdir}/udev/rules.d/37-can.rules
+}
+
+do_install:append:j722s() {
+    install -d ${D}/${libdir}/udev/rules.d
+    install -m 0644 ${WORKDIR}/37-can-am62xx.rules ${D}${libdir}/udev/rules.d/37-can.rules
+}
+
+FILES:udev += "${libdir}/udev/rules.d/37-can.rules"
+
-- 
2.34.1



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-02-07 19:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-07 19:22 [meta-arago][kirkstone/master][PATCH v2] systemd: Add udev rules for persistent naming of the can devices Aniket Limaye

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).