Skip to content

Commit d341ebb

Browse files
authored
Initial hardware support for Rubik pi (#1989)
1 parent d88ea4a commit d341ebb

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

photon-core/src/main/java/org/photonvision/common/hardware/metrics/MetricsManager.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.photonvision.common.hardware.metrics.cmds.FileCmds;
3030
import org.photonvision.common.hardware.metrics.cmds.LinuxCmds;
3131
import org.photonvision.common.hardware.metrics.cmds.PiCmds;
32+
import org.photonvision.common.hardware.metrics.cmds.QCS6490Cmds;
3233
import org.photonvision.common.hardware.metrics.cmds.RK3588Cmds;
3334
import org.photonvision.common.logging.LogGroup;
3435
import org.photonvision.common.logging.Logger;
@@ -49,6 +50,8 @@ public void setConfig(HardwareConfig config) {
4950
cmds = new PiCmds(); // Pi's can use a hardcoded command set
5051
} else if (Platform.isRK3588()) {
5152
cmds = new RK3588Cmds(); // RK3588 chipset hardcoded command set
53+
} else if (Platform.isQCS6490()) {
54+
cmds = new QCS6490Cmds(); // QCS6490 chipset hardcoded command set
5255
} else if (Platform.isLinux()) {
5356
cmds = new LinuxCmds(); // Linux/Unix platforms assume a nominal command set
5457
} else {
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (C) Photon Vision.
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
18+
package org.photonvision.common.hardware.metrics.cmds;
19+
20+
import org.photonvision.common.configuration.HardwareConfig;
21+
22+
public class QCS6490Cmds extends LinuxCmds {
23+
/** Applies pi-specific commands, ignoring any input configuration */
24+
public void initCmds(HardwareConfig config) {
25+
super.initCmds(config);
26+
27+
/* Thermal zone information can be found in /sys/class/thermal/thermal_zone* directories:
28+
* zone/type: Contains the thermal zone type/name (e.g., "acpi", "x86_pkg_temp")
29+
* zone/temp: Current temperature in millidegrees Celsius (divide by 1000 for actual temp)
30+
* zone/policy: Thermal governor policy (e.g., "step_wise", "power_allocator")
31+
* Each thermal_zone* directory represents a different temperature sensor in the system
32+
*/
33+
34+
cpuTemperatureCommand =
35+
"cat /sys/class/thermal/thermal_zone10/temp | awk '{printf \"%.1f\", $1/1000}'";
36+
37+
// TODO: NPU usage, doesn't seem to be in the same place as the opi. We're gonna just wait on QC
38+
// to get back to us on this one.
39+
}
40+
}

photon-targeting/src/main/java/org/photonvision/common/hardware/Platform.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ public enum Platform {
5151
false,
5252
OSType.LINUX,
5353
true),
54+
LINUX_QCS6490(
55+
"Linux AARCH 64-bit with QCS6490",
56+
Platform::getLinuxDeviceTreeModel,
57+
"linuxarm64",
58+
true,
59+
OSType.LINUX,
60+
true), // QCS6490 SBCs
5461
LINUX_AARCH64(
5562
"Linux AARCH64",
5663
Platform::getLinuxDeviceTreeModel,
@@ -124,6 +131,10 @@ public static boolean isRK3588() {
124131
return Platform.isOrangePi() || Platform.isCoolPi4b() || Platform.isRock5C();
125132
}
126133

134+
public static boolean isQCS6490() {
135+
return isRubik();
136+
}
137+
127138
public static boolean isRaspberryPi() {
128139
return currentPlatform.isPi;
129140
}
@@ -162,6 +173,7 @@ public static boolean isAthena() {
162173
String.format("Unknown Platform. OS: %s, Architecture: %s", OS_NAME, OS_ARCH);
163174
private static final String UnknownDeviceModelString = "Unknown";
164175

176+
// TODO: add rubik, but waiting for more info on architecture
165177
public static Platform getCurrentPlatform() {
166178
String OS_NAME;
167179
if (Platform.OS_NAME != null) {
@@ -219,6 +231,9 @@ public static Platform getCurrentPlatform() {
219231
// TODO - os detection needed?
220232
if (isRK3588()) {
221233
return LINUX_RK3588_64;
234+
} else if (isQCS6490()) {
235+
return LINUX_QCS6490;
236+
222237
} else {
223238
return LINUX_AARCH64;
224239
}
@@ -256,6 +271,10 @@ private static boolean isJetsonSBC() {
256271
return fileHasText("/proc/device-tree/model", "NVIDIA Jetson");
257272
}
258273

274+
private static boolean isRubik() {
275+
return fileHasText("/proc/device-tree/model", "Rubik");
276+
}
277+
259278
static String getLinuxDeviceTreeModel() {
260279
var deviceTreeModelPath = Paths.get("/proc/device-tree/model");
261280
try {

0 commit comments

Comments
 (0)