Skip to content

Commit 43338a4

Browse files
authored
Temperature monitoring for RK3588 (#1186)
1 parent bcea6fc commit 43338a4

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-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
@@ -28,6 +28,7 @@
2828
import org.photonvision.common.hardware.metrics.cmds.FileCmds;
2929
import org.photonvision.common.hardware.metrics.cmds.LinuxCmds;
3030
import org.photonvision.common.hardware.metrics.cmds.PiCmds;
31+
import org.photonvision.common.hardware.metrics.cmds.RK3588Cmds;
3132
import org.photonvision.common.logging.LogGroup;
3233
import org.photonvision.common.logging.Logger;
3334
import org.photonvision.common.util.ShellExec;
@@ -44,6 +45,8 @@ public void setConfig(HardwareConfig config) {
4445
cmds = new FileCmds();
4546
} else if (Platform.isRaspberryPi()) {
4647
cmds = new PiCmds(); // Pi's can use a hardcoded command set
48+
} else if (Platform.isRK3588()) {
49+
cmds = new RK3588Cmds(); // RK3588 chipset hardcoded command set
4750
} else if (Platform.isLinux()) {
4851
cmds = new LinuxCmds(); // Linux/Unix platforms assume a nominal command set
4952
} else {
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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 RK3588Cmds extends LinuxCmds {
23+
/** Applies pi-specific commands, ignoring any input configuration */
24+
public void initCmds(HardwareConfig config) {
25+
super.initCmds(config);
26+
27+
// CPU Temperature
28+
/* The RK3588 chip has 7 thermal zones that can be accessed via:
29+
* /sys/class/thermal/thermal_zoneX/temp
30+
* where X is an interger from 0 to 6.
31+
*
32+
* || Zone || Location || Comments ||
33+
* | 0 | soc | soc thermal (near the center of the chip) |
34+
* | 1 | bigcore0 | CPU Big Core A76_0/1 (CPU4 and CPU5) |
35+
* | 2 | bigcore1 | CPU Big Core A76_2/3 (CPU6 and CPU7) |
36+
* | 3 | littlecore | CPU Small Core A55_0/1/2/3 (CPU0, CPU1, CPU2, and CPU3) |
37+
* | 4 | center | also called PD_CENTER |
38+
* | 5 | gpu | GPU |
39+
* | 6 | npu | NPU |
40+
*
41+
* Sources:
42+
* - http://forum.armsom.org/t/topic/51/3
43+
* - https://lore.kernel.org/lkml/7276280.TLKafQO6qx@archbook/
44+
*/
45+
cpuTemperatureCommand =
46+
"cat /sys/class/thermal/thermal_zone1/temp | awk '{printf \"%.1f\", $1/1000}'";
47+
}
48+
}

0 commit comments

Comments
 (0)