Name each CAN bus using udev
The names were consistent before purely because the probe order appeared
consistent... Instead, use udev to name them can[abc] and have the
order be static based on the port.
Change-Id: I13ad066699bb2a5af60abceb3c59451ecec0bc1f
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/frc971/orin/build_rootfs.py b/frc971/orin/build_rootfs.py
index ec8d955..c378226 100755
--- a/frc971/orin/build_rootfs.py
+++ b/frc971/orin/build_rootfs.py
@@ -765,7 +765,7 @@
resolved_deps.sort()
rule_name = obj[1:].replace('/', '_')
rule_deps = ''.join([
- ' ":%s",\n'.format(d[1:].replace('/', '_'))
+ ' ":{}",\n'.format(d[1:].replace('/', '_'))
for d in resolved_deps if d not in skip_set
])
rules.append(
@@ -843,6 +843,8 @@
with open("../../compilers/orin_debian_rootfs.BUILD", "w") as file:
file.write(template.render(substitutions))
+ subprocess.run(['buildifier', "../../compilers/orin_debian_rootfs.BUILD"])
+
def do_package(partition):
tarball = datetime.date.today().strftime(
@@ -1112,8 +1114,11 @@
target_mkdir("root:root", "755", "etc/systemd/network")
copyfile("root:root", "644", "etc/systemd/network/eth0.network")
- copyfile("root:root", "644", "etc/systemd/network/80-can.network")
+ copyfile("root:root", "644", "etc/systemd/network/80-cana.network")
+ copyfile("root:root", "644", "etc/systemd/network/80-canb.network")
+ copyfile("root:root", "644", "etc/systemd/network/80-canc.network")
copyfile("root:root", "644", "etc/udev/rules.d/nvidia.rules")
+ copyfile("root:root", "644", "etc/udev/rules.d/can.rules")
target(["/root/bin/change_hostname.sh", "pi-971-1"])
target(["systemctl", "enable", "systemd-networkd"])
diff --git a/frc971/orin/contents/etc/systemd/network/80-can.network b/frc971/orin/contents/etc/systemd/network/80-cana.network
similarity index 64%
copy from frc971/orin/contents/etc/systemd/network/80-can.network
copy to frc971/orin/contents/etc/systemd/network/80-cana.network
index e75db33..0e4ad11 100644
--- a/frc971/orin/contents/etc/systemd/network/80-can.network
+++ b/frc971/orin/contents/etc/systemd/network/80-cana.network
@@ -1,9 +1,7 @@
[Match]
-Name=can0
+Name=cana
[CAN]
BitRate=1M
-DataBitRate=8M
RestartSec=1000ms
BusErrorReporting=yes
-FDMode=yes
diff --git a/frc971/orin/contents/etc/systemd/network/80-can.network b/frc971/orin/contents/etc/systemd/network/80-canb.network
similarity index 90%
rename from frc971/orin/contents/etc/systemd/network/80-can.network
rename to frc971/orin/contents/etc/systemd/network/80-canb.network
index e75db33..1bef0ee 100644
--- a/frc971/orin/contents/etc/systemd/network/80-can.network
+++ b/frc971/orin/contents/etc/systemd/network/80-canb.network
@@ -1,5 +1,5 @@
[Match]
-Name=can0
+Name=canb
[CAN]
BitRate=1M
diff --git a/frc971/orin/contents/etc/systemd/network/80-can.network b/frc971/orin/contents/etc/systemd/network/80-canc.network
similarity index 90%
copy from frc971/orin/contents/etc/systemd/network/80-can.network
copy to frc971/orin/contents/etc/systemd/network/80-canc.network
index e75db33..cdcbe81 100644
--- a/frc971/orin/contents/etc/systemd/network/80-can.network
+++ b/frc971/orin/contents/etc/systemd/network/80-canc.network
@@ -1,5 +1,5 @@
[Match]
-Name=can0
+Name=canc
[CAN]
BitRate=1M
diff --git a/frc971/orin/contents/etc/udev/rules.d/can.rules b/frc971/orin/contents/etc/udev/rules.d/can.rules
new file mode 100644
index 0000000..83aa68e
--- /dev/null
+++ b/frc971/orin/contents/etc/udev/rules.d/can.rules
@@ -0,0 +1,3 @@
+SUBSYSTEM=="net", ACTION=="add", ATTR{dev_id}=="0x0", ENV{ID_PATH_TAG}=="platform-c310000_mttcan", NAME="cana"
+SUBSYSTEM=="net", ACTION=="add", ATTR{dev_id}=="0x0", ENV{ID_PATH_TAG}=="platform-14100000_pcie-pci-0001_01_00_0", NAME="canb"
+SUBSYSTEM=="net", ACTION=="add", ATTR{dev_id}=="0x1", ENV{ID_PATH_TAG}=="platform-14100000_pcie-pci-0001_01_00_0", NAME="canc"