20250603在荣品的PRO-RK3566开发板的Android13下的使用命令行来查看RK3566的温度【显示优化版本】
2025/6/3 11:58
RK3566的cpu运行效率 top
busybox top
rk3566_t:/ #
rk3566_t:/ #
rk3566_t:/ # cd /sys/class/thermal/
rk3566_t:/sys/class/thermal # ls -l
rk3566_t:/sys/class/thermal # cd thermal_zone0/
rk3566_t:/sys/class/thermal/thermal_zone0 #
rk3566_t:/sys/class/thermal/thermal_zone0 # ls -l
rk3566_t:/sys/class/thermal/thermal_zone0 # cat temp
51875
rk3566_t:/sys/class/thermal/thermal_zone0 #
完整的LOG:
【可以直接将DeepSeek的内容拷贝到XShell的串口界面,但是WIN10的命令行的adb中不行!】
【XShell8】
console:/ $
rmal : $(($(cat /sys/class/thermal/thermal_zone0/temp)/1000))°C" <
CPU thermal : 50°C
console:/ $
: $(($(cat /sys/class/thermal/thermal_zone0/temp)/1000))°C" <
CPU温度: 50°C
console:/ $
console:/ $
【ADB显示异常了!】
Microsoft Windows [版本 10.0.19045.5737]
(c) Microsoft Corporation。保留所有权利。
C:\Users\QQ>adb shell
adb server version (40) doesn't match this client (41); killing...
* daemon started successfully
rk3566_t:/ $ echo "CPU?: $(($(cat /sys/class/thermal/thermal_zone0/temp)/1000))C"
CPU?: 50C
rk3566_t:/ $
rk3566_t:/ $ echo "CPU?: $(($(cat /sys/class/thermal/thermal_zone0/temp)/1000))C"^C
130|rk3566_t:/ $
130|rk3566_t:/ $ echo "CPU thermal : $(($(cat /sys/class/thermal/thermal_zone0/temp)/1000))C"
CPU thermal : 50C
rk3566_t:/ $
rk3566_t:/ $ echo "CPU thermal : $(($(cat /sys/class/thermal/thermal_zone0/temp)/1000))C"
CPU thermal : 50C
rk3566_t:/ $
rk3566_t:/ $ echo "CPU?: $(($(cat /sys/class/thermal/thermal_zone0/temp)/1000))C"
CPU?: 50C
rk3566_t:/ $
rk3566_t:/ #
rk3566_t:/ #
rk3566_t:/ #
rk3566_t:/ # cd /sys/class/thermal/
rk3566_t:/sys/class/thermal #
rk3566_t:/sys/class/thermal # ls -l
total 0
lrwxrwxrwx 1 root root 0 2025-06-02 18:01 cooling_device0 -> ../../devices/virtual/thermal/cooling_device0
lrwxrwxrwx 1 root root 0 2017-08-04 17:00 thermal_zone0 -> ../../devices/virtual/thermal/thermal_zone0
lrwxrwxrwx 1 root root 0 2017-08-04 17:00 thermal_zone1 -> ../../devices/virtual/thermal/thermal_zone1
lrwxrwxrwx 1 root root 0 2017-08-04 17:00 thermal_zone2 -> ../../devices/virtual/thermal/thermal_zone2
rk3566_t:/sys/class/thermal #
rk3566_t:/sys/class/thermal #
rk3566_t:/sys/class/thermal # cd the
thermal_zone0/ thermal_zone1/ thermal_zone2/
rk3566_t:/sys/class/thermal # cd thermal_zone0/
rk3566_t:/sys/class/thermal/thermal_zone0 #
rk3566_t:/sys/class/thermal/thermal_zone0 # ls -l
total 0
-r--r--r-- 1 root root 4096 2025-06-02 18:02 available_policies
lrwxrwxrwx 1 root root 0 2025-06-02 18:02 cdev0 -> ../cooling_device0
-r--r--r-- 1 root root 4096 2025-06-02 18:02 cdev0_trip_point
-rw-r--r-- 1 root root 4096 2025-06-02 18:02 cdev0_weight
drwxr-xr-x 3 root root 0 2017-08-04 17:00 hwmon0
-rw-r--r-- 1 root root 4096 2025-06-02 18:02 integral_cutoff
-rw-r--r-- 1 root root 4096 2025-06-02 18:02 k_d
-rw-r--r-- 1 root root 4096 2025-06-02 18:02 k_i
-rw-r--r-- 1 root root 4096 2025-06-02 18:02 k_po
-rw-r--r-- 1 root root 4096 2025-06-02 18:02 k_pu
-rw-r--r-- 1 root root 4096 2025-06-02 18:02 mode
-rw-r--r-- 1 root root 4096 2025-06-02 18:02 offset
-rw-r--r-- 1 system system 4096 2017-08-04 17:00 policy
drwxr-xr-x 2 root root 0 2017-08-04 17:00 power
-rw-r--r-- 1 root root 4096 2025-06-02 18:02 slope
lrwxrwxrwx 1 root root 0 2025-06-02 18:02 subsystem -> ../../../../class/thermal
-rw-r--r-- 1 root root 4096 2025-06-02 18:02 sustainable_power
-r--r--r-- 1 root root 4096 2025-06-02 17:56 temp
-rw-r--r-- 1 root root 4096 2025-06-02 18:02 trip_point_0_hyst
-rw-r--r-- 1 root root 4096 2025-06-02 18:02 trip_point_0_temp
-r--r--r-- 1 root root 4096 2025-06-02 18:02 trip_point_0_type
-rw-r--r-- 1 root root 4096 2025-06-02 18:02 trip_point_1_hyst
-rw-r--r-- 1 root root 4096 2025-06-02 18:02 trip_point_1_temp
-r--r--r-- 1 root root 4096 2025-06-02 18:02 trip_point_1_type
-rw-r--r-- 1 root root 4096 2025-06-02 18:02 trip_point_2_hyst
-rw-r--r-- 1 root root 4096 2025-06-02 18:02 trip_point_2_temp
-r--r--r-- 1 root root 4096 2025-06-02 18:02 trip_point_2_type
-r--r--r-- 1 root root 4096 2025-06-02 17:56 type
-rw-r--r-- 1 root root 4096 2017-08-04 17:00 uevent
rk3566_t:/sys/class/thermal/thermal_zone0 #
rk3566_t:/sys/class/thermal/thermal_zone0 # cat temp
51875
rk3566_t:/sys/class/thermal/thermal_zone0 #
C:\Users\QQ>
在命令行查看RK3566的温度
在 RK3566 平台上,你可以通过以下方法在命令行中查看 SoC 温度:
方法 1:通过 sysfs 接口查询
RK3566 的温度传感器数据通常通过内核的 thermal 子系统暴露在 /sys/class/thermal 目录下:
bash
# 列出所有 thermal zone
ls /sys/class/thermal/
# 通常 thermal_zone0 对应 SoC 温度
cat /sys/class/thermal/thermal_zone0/temp
# 更友好的显示方式(除以1000得到摄氏度)
echo "CPU温度: $(($(cat /sys/class/thermal/thermal_zone0/temp)/1000))°C"
方法 2:使用 sensors 命令(需安装 lm-sensors)
如果系统支持:
bash
# 安装 lm-sensors(如果未安装)
sudo apt install lm-sensors
# 检测硬件传感器
sudo sensors-detect
# 查看温度信息
sensors
方法 3:通过调试接口(需要 root)
有些 RK3566 平台可能提供额外的调试接口:
bash
# 查看 PMIC 温度(如果支持)
cat /sys/kernel/debug/regulator/regulator_temp
# 或通过 debugfs
cat /sys/kernel/debug/thermal/thermal_zone0/temp
方法 4:使用第三方工具
bash
# 安装并运行 psensor
sudo apt install psensor
psensor
注意事项:
不同厂商的 RK3566 板卡/设备可能温度传感器路径略有不同
某些嵌入式系统可能简化了 thermal 子系统实现
温度值通常是毫摄氏度(需要除以1000得到摄氏度)
如果没有显示,可能需要检查内核配置是否启用了 thermal 驱动:
bash
dmesg | grep thermal
如果需要更精确的信息,建议查阅你所使用的具体 RK3566 平台的硬件手册或内核设备树配置。
在命令行查看RK3566的温度 更加友好的显示方式。RK3566不支持 中文。不支持 温度的度的显示。请切换为 英文状态下的更加友好的显示方式
Here are several English-friendly ways to check the RK3566 temperature in the command line:
Method 1: Simple Temperature Readout
bash
echo "CPU Temp: $(($(cat /sys/class/thermal/thermal_zone0/temp)/1000))C"
Sample output:
CPU Temp: 42C
Method 2: Formatted Thermal Information
bash
temp=$(($(cat /sys/class/thermal/thermal_zone0/temp)/1000))
printf "RK3566 Temperature\n=================\nSOC: %d°C\n" $temp
Sample output:
RK3566 Temperature
=================
SOC: 42°C
Method 3: Continuous Monitoring (refresh every 2 seconds)
bash
watch -n 2 'echo "Current Temp: $(($(cat /sys/class/thermal/thermal_zone0/temp)/1000))C"'
Method 4: Thermal Zone Summary
bash
for zone in $(ls /sys/class/thermal/ | grep thermal_zone); do
type=$(cat /sys/class/thermal/${zone}/type)
temp=$(($(cat /sys/class/thermal/${zone}/temp)/1000))
printf "%-15s: %2dC\n" $type $temp
done
Sample output:
soc_thermal : 42C
Method 5: Color-Coded Temperature (requires terminal with color support)
bash
temp=$(($(cat /sys/class/thermal/thermal_zone0/temp)/1000))
if [ $temp -gt 70 ]; then
echo -e "\033[31mWARNING: High Temp - ${temp}C\033[0m"
elif [ $temp -gt 50 ]; then
echo -e "\033[33mNormal Temp - ${temp}C\033[0m"
else
echo -e "\033[32mCool Temp - ${temp}C\033[0m"
fi
Notes:
All methods use standard POSIX shell commands for maximum compatibility
The degree symbol (°) is optional and may be replaced with just 'C'
For embedded systems with limited shell support, Method 1 is the most universal
If thermal_zone0 doesn't exist, check other zones with ls /sys/class/thermal/
使用shell脚本 表示 温度的度
在 Shell 脚本中,你可以使用 printf 或 echo -e 来显示温度的单位符号(°C)。以下是几种在 RK3566 上友好显示温度的方法:
方法 1:使用 Unicode 编码显示 °C 符号
bash
#!/bin/bash
temp=$(($(cat /sys/class/thermal/thermal_zone0/temp)/1000))
echo "CPU Temp: ${temp}°C"
输出示例:
CPU Temp: 42°C
方法 2:使用 printf 格式化输出
bash
#!/bin/bash
temp=$(($(cat /sys/class/thermal/thermal_zone0/temp)/1000))
printf "Current Temperature: %d°C\n" "$temp"
输出示例:
Current Temperature: 42°C
方法 3:使用 ASCII 替代符号(兼容性更强)
如果终端不支持 Unicode 符号,可以用 C 代替 °C:
bash
#!/bin/bash
temp=$(($(cat /sys/class/thermal/thermal_zone0/temp)/1000))
echo "CPU Temp: ${temp}C"
输出示例:
CPU Temp: 42C
方法 4:带颜色和警告的 Shell 脚本
bash
#!/bin/bash
temp=$(($(cat /sys/class/thermal/thermal_zone0/temp)/1000))
if [ "$temp" -gt 70 ]; then
echo -e "\e[31mWARNING: High Temperature - ${temp}°C\e[0m"
elif [ "$temp" -gt 50 ]; then
echo -e "\e[33mNormal Temperature - ${temp}°C\e[0m"
else
echo -e "\e[32mCool Temperature - ${temp}°C\e[0m"
fi
输出示例:
如果温度 > 70°C → 红色警告
如果温度 50-70°C → 黄色提示
如果温度 < 50°C → 绿色正常
方法 5:持续监控温度(每 2 秒刷新)
bash
#!/bin/bash
while true; do
temp=$(($(cat /sys/class/thermal/thermal_zone0/temp)/1000))
printf "\rCurrent Temperature: %d°C" "$temp"
sleep 2
done
按 Ctrl+C 退出监控
注意事项
确保 /sys/class/thermal/thermal_zone0/temp 存在(不同 RK3566 设备可能路径不同)。
如果终端不支持 Unicode,可以用 C 代替 °C。
部分嵌入式系统可能不支持 echo -e 颜色,可以去掉颜色代码。
你可以选择最适合你的方式,推荐 方法 1 或 方法 2 进行简单温度读取,方法 5 用于实时监控。
在SHELL脚本中,如果让小写的字幕o显示在上面?
在 Shell 脚本中,如果你想让小写字母 o 显示在数字的上方(类似上标效果),可以使用 Unicode 组合字符 或 ANSI 控制码 来实现。但由于终端限制,纯文本环境无法真正实现上标,以下是几种替代方案:
方法 1:使用 Unicode 上标字母(部分支持)
Unicode 提供了上标字母 ᵒ(U+1D52),但并非所有终端都能正确渲染:
bash
echo "42°C" # 正常显示
echo "42ᵒC" # 尝试用小上标 ᵒ 替代(可能显示异常)
输出可能类似:
42°C
42ᵒC
方法 2:用 printf 和垂直偏移(部分终端支持)
某些终端(如 terminator、gnome-terminal)支持 ANSI 控制码调整字符位置:
bash
printf "42\e[1A\e[1Do\e[1B\e[1DC\n" # 尝试将 o 上移一行
效果不稳定,可能显示为:
42
oC
方法 3:直接使用特殊符号 °(推荐)
大多数 Shell 环境支持 Unicode 的度符号 °(U+00B0),这是最可靠的方式:
bash
echo "42°C" # 标准温度显示
输出:
42°C
方法 4:用 ASCII 艺术模拟上标
如果终端完全无法显示 Unicode,可以用换行和空格模拟:
bash
echo -e "42\n oC"
输出:
42
oC
注意事项
终端兼容性:
Unicode 上标(如 ᵒ)在 SSH、嵌入式设备终端中可能显示为乱码。
推荐优先使用 °(U+00B0),它被广泛支持。
脚本可移植性:
如果目标设备是 RK3566 嵌入式系统,建议直接使用 C 或 °C,避免复杂格式。
检查终端支持:
运行 echo -e "\u00B0" 测试是否能正常显示 ° 符号。
最终推荐方案
bash
# 最兼容的写法(支持 Unicode 时用 °,否则用 o)
if echo -e "\u00B0" | grep -q "°"; then
echo "42°C"
else
echo "42oC" # 降级显示
fi
输出:
支持 Unicode → 42°C
不支持 → 42oC