001/*
002 * Copyright (C) Photon Vision.
003 *
004 * This program is free software: you can redistribute it and/or modify
005 * it under the terms of the GNU General Public License as published by
006 * the Free Software Foundation, either version 3 of the License, or
007 * (at your option) any later version.
008 *
009 * This program is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012 * GNU General Public License for more details.
013 *
014 * You should have received a copy of the GNU General Public License
015 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
016 */
017
018package org.photonvision.common.hardware.metrics.cmds;
019
020import org.photonvision.common.configuration.HardwareConfig;
021
022public class RK3588Cmds extends LinuxCmds {
023    /** Applies pi-specific commands, ignoring any input configuration */
024    public void initCmds(HardwareConfig config) {
025        super.initCmds(config);
026
027        // CPU Temperature
028        /* The RK3588 chip has 7 thermal zones that can be accessed via:
029         *       /sys/class/thermal/thermal_zoneX/temp
030         * where X is an integer from 0 to 6.
031         *
032         * || Zone || Location    || Comments                                                ||
033         * |    0  |  soc         |  soc thermal (near the center of the chip)                |
034         * |    1  |  bigcore0    |  CPU Big Core A76_0/1 (CPU4 and CPU5)                     |
035         * |    2  |  bigcore1    |  CPU Big Core A76_2/3 (CPU6 and CPU7)                     |
036         * |    3  |  littlecore  |  CPU Small Core A55_0/1/2/3 (CPU0, CPU1, CPU2, and CPU3)  |
037         * |    4  |  center      |  also called PD_CENTER                                    |
038         * |    5  |  gpu         |  GPU                                                      |
039         * |    6  |  npu         |  NPU                                                      |
040         *
041         * Sources:
042         *   - http://forum.armsom.org/t/topic/51/3
043         *   - https://lore.kernel.org/lkml/7276280.TLKafQO6qx@archbook/
044         */
045        cpuTemperatureCommand =
046                "cat /sys/class/thermal/thermal_zone1/temp | awk '{printf \"%.1f\", $1/1000}'";
047
048        npuUsageCommand = "cat /sys/kernel/debug/rknpu/load | sed 's/NPU load://; s/^ *//; s/ *$//'";
049    }
050}