飞腾派监测CPU频率和温度的脚本
发布时间:2025-05-16
文章来源:ifan.lian
1. 调试目标
编写一个脚本,实现对飞腾派CPU频率和温度的监测
2. 项目准备
(1) 基本硬件:飞腾派4G内存V2.1版本;
(2) 操作系统: Ubuntu_xfce_4GB_250327版本
下载链接:飞腾派资料包链接
(3) 镜像烧录:USB读卡器;microSD卡;USB转TTL调试串口;Win32DiskImager烧录软件;MobaXterm_Personal_23.2终端软件;
3. 操作步骤
(1) 用Win32DiskImager烧录软件把Ubuntu镜像烧录到microSD卡,然后上电启动飞腾派
(2) 新建一个脚本文件,命名为temptest.sh,并给可执行权限
touch temptest.sh
chmod +x temptest.sh
(3) 用vi编辑器修改temptest.sh文件
sudo vi temptest.sh
在文件中写入下面的内容
#!/bin/bash
echo Temperature Testing
while [ 1 ]
do
time=$(date "+%Y-%m-%d %H:%M:%S")
temp=$(cat /sys/class/thermal/thermal_zone0/temp)
cpu0=$(cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq)
cpu1=$(cat /sys/devices/system/cpu/cpu1/cpufreq/cpuinfo_cur_freq)
cpu2=$(cat /sys/devices/system/cpu/cpu2/cpufreq/cpuinfo_cur_freq)
cpu3=$(cat /sys/devices/system/cpu/cpu3/cpufreq/cpuinfo_cur_freq)
let temp=${temp}/1000
echo $time temp: $temp ℃ cpu0_freq: $cpu0 Hz cpu1_freq: $cpu1 Hz cpu2_freq: $cpu2 Hz cpu3_freq: $cpu3 Hz
sleep 5
done
4. 功能测试与验证
(1) 执行脚本文件,每五秒会打印一次温度和频率
sudo ./ temptest.sh
(2) 如果要生成监控日志文件可以执行如下命令,则会生成一个temptest.log的文件
sudo ./temptest.sh > temptest.log
5. 常见问题与解决办法
暂无问题
飞腾派V3 现货支持
飞腾派V3 现货发售,支持全四口USB 3.0接口,PWM智能调速散热风扇,国标/美标耳机自动识别等功能,售价649元包邮。
https://www.iceasy.com/product/1875487334855221250
飞腾派资料下载专区
提供飞腾派相关资料下载,包括开发板手册、开源项目文档等。
https://www.iceasy.com/cloud/Phytium?pid=1877646941793374213
开源口碑案例分享
可参考飞腾派开发板的用户评价和社区反馈。
https://www.iceasy.com/review/list