From d341ebbadf1af98f9792c177af349bb1b058088a Mon Sep 17 00:00:00 2001 From: Sam Freund Date: Sun, 6 Jul 2025 14:39:29 -0500 Subject: [PATCH] Initial hardware support for Rubik pi (#1989) --- .../hardware/metrics/MetricsManager.java | 3 ++ .../hardware/metrics/cmds/QCS6490Cmds.java | 40 +++++++++++++++++++ .../common/hardware/Platform.java | 19 +++++++++ 3 files changed, 62 insertions(+) create mode 100644 photon-core/src/main/java/org/photonvision/common/hardware/metrics/cmds/QCS6490Cmds.java diff --git a/photon-core/src/main/java/org/photonvision/common/hardware/metrics/MetricsManager.java b/photon-core/src/main/java/org/photonvision/common/hardware/metrics/MetricsManager.java index cfddf8f82..053f14a70 100644 --- a/photon-core/src/main/java/org/photonvision/common/hardware/metrics/MetricsManager.java +++ b/photon-core/src/main/java/org/photonvision/common/hardware/metrics/MetricsManager.java @@ -29,6 +29,7 @@ import org.photonvision.common.hardware.metrics.cmds.CmdBase; import org.photonvision.common.hardware.metrics.cmds.FileCmds; import org.photonvision.common.hardware.metrics.cmds.LinuxCmds; import org.photonvision.common.hardware.metrics.cmds.PiCmds; +import org.photonvision.common.hardware.metrics.cmds.QCS6490Cmds; import org.photonvision.common.hardware.metrics.cmds.RK3588Cmds; import org.photonvision.common.logging.LogGroup; import org.photonvision.common.logging.Logger; @@ -49,6 +50,8 @@ public class MetricsManager { cmds = new PiCmds(); // Pi's can use a hardcoded command set } else if (Platform.isRK3588()) { cmds = new RK3588Cmds(); // RK3588 chipset hardcoded command set + } else if (Platform.isQCS6490()) { + cmds = new QCS6490Cmds(); // QCS6490 chipset hardcoded command set } else if (Platform.isLinux()) { cmds = new LinuxCmds(); // Linux/Unix platforms assume a nominal command set } else { diff --git a/photon-core/src/main/java/org/photonvision/common/hardware/metrics/cmds/QCS6490Cmds.java b/photon-core/src/main/java/org/photonvision/common/hardware/metrics/cmds/QCS6490Cmds.java new file mode 100644 index 000000000..a625900e9 --- /dev/null +++ b/photon-core/src/main/java/org/photonvision/common/hardware/metrics/cmds/QCS6490Cmds.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) Photon Vision. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.photonvision.common.hardware.metrics.cmds; + +import org.photonvision.common.configuration.HardwareConfig; + +public class QCS6490Cmds extends LinuxCmds { + /** Applies pi-specific commands, ignoring any input configuration */ + public void initCmds(HardwareConfig config) { + super.initCmds(config); + + /* Thermal zone information can be found in /sys/class/thermal/thermal_zone* directories: + * zone/type: Contains the thermal zone type/name (e.g., "acpi", "x86_pkg_temp") + * zone/temp: Current temperature in millidegrees Celsius (divide by 1000 for actual temp) + * zone/policy: Thermal governor policy (e.g., "step_wise", "power_allocator") + * Each thermal_zone* directory represents a different temperature sensor in the system + */ + + cpuTemperatureCommand = + "cat /sys/class/thermal/thermal_zone10/temp | awk '{printf \"%.1f\", $1/1000}'"; + + // TODO: NPU usage, doesn't seem to be in the same place as the opi. We're gonna just wait on QC + // to get back to us on this one. + } +} diff --git a/photon-targeting/src/main/java/org/photonvision/common/hardware/Platform.java b/photon-targeting/src/main/java/org/photonvision/common/hardware/Platform.java index 5603989a4..087d36428 100644 --- a/photon-targeting/src/main/java/org/photonvision/common/hardware/Platform.java +++ b/photon-targeting/src/main/java/org/photonvision/common/hardware/Platform.java @@ -51,6 +51,13 @@ public enum Platform { false, OSType.LINUX, true), + LINUX_QCS6490( + "Linux AARCH 64-bit with QCS6490", + Platform::getLinuxDeviceTreeModel, + "linuxarm64", + true, + OSType.LINUX, + true), // QCS6490 SBCs LINUX_AARCH64( "Linux AARCH64", Platform::getLinuxDeviceTreeModel, @@ -124,6 +131,10 @@ public enum Platform { return Platform.isOrangePi() || Platform.isCoolPi4b() || Platform.isRock5C(); } + public static boolean isQCS6490() { + return isRubik(); + } + public static boolean isRaspberryPi() { return currentPlatform.isPi; } @@ -162,6 +173,7 @@ public enum Platform { String.format("Unknown Platform. OS: %s, Architecture: %s", OS_NAME, OS_ARCH); private static final String UnknownDeviceModelString = "Unknown"; + // TODO: add rubik, but waiting for more info on architecture public static Platform getCurrentPlatform() { String OS_NAME; if (Platform.OS_NAME != null) { @@ -219,6 +231,9 @@ public enum Platform { // TODO - os detection needed? if (isRK3588()) { return LINUX_RK3588_64; + } else if (isQCS6490()) { + return LINUX_QCS6490; + } else { return LINUX_AARCH64; } @@ -256,6 +271,10 @@ public enum Platform { return fileHasText("/proc/device-tree/model", "NVIDIA Jetson"); } + private static boolean isRubik() { + return fileHasText("/proc/device-tree/model", "Rubik"); + } + static String getLinuxDeviceTreeModel() { var deviceTreeModelPath = Paths.get("/proc/device-tree/model"); try {