在Beaglebone Black上读取CPU温度

7

我有一块运行Ubuntu 14.04的Beaglebone Black。我使用预先构建的映像闪存指南将其刷写。

从我看到的指南来看,我应该能够读取/sys/class/hwmon/hwmon0/device/temp1_input来获取CPU温度。但是,在我的系统上,我没有这样的路径;我猜测Beaglebone Black的AM3358 ARM CPU的内核模块提供了此功能,并且我的映像缺少这样的模块,但我不知道从何处开始获取这样的模块。实际上,/sys/class/hwmon是一个空目录。

这些是我已经拥有的模块:

$ lsmod | sort
6lowpan_iphc           10154  1 bluetooth
bluetooth             316797  10 bnep,rfcomm
bnep                   11946  2
can_dev                 7430  1 c_can
c_can                   9400  1 c_can_platform
c_can_platform          5927  0
g_multi                 3238  0
iptable_filter          1149  1
ip_tables              11857  1 iptable_filter
libcomposite           38715  5 usb_f_acm,usb_f_ecm,usb_f_rndis,g_multi,usb_f_mass_storage
musb_am335x             1075  0
musb_dsps               8369  0
musb_hdrc              76236  1 musb_dsps
rfcomm                 46571  0
rfkill                 14659  2 bluetooth
u_ether                 9524  3 usb_f_ecm,usb_f_rndis,g_multi
usb_f_acm               5687  1
usb_f_ecm               7901  1
usb_f_mass_storage     34664  2 g_multi
usb_f_rndis            17711  2 g_multi
u_serial                9631  1 usb_f_acm
x_tables               12575  3 ip_tables,xt_multiport,iptable_filter
xt_multiport            2051  1

...以及总体状态:

$ uname -a
Linux hostname 3.14.26-ti-r43 #1 SMP PREEMPT Wed Dec 24 05:27:12 UTC 2014 armv7l armv7l armv7l GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.1 LTS
Release:        14.04
Codename:       trusty

那么,如果一台Beaglebone Black没有这个文件,我该如何读取CPU温度?
2个回答

5

我已经在互联网上进行了一番搜索,但毫无收获。

目前的Debian(我使用的是Linux bbone 4.1.12-ti-r29 #1 SMP PREEMPT Mon Nov 9 22:46:19 UTC 2015 armv7l GNU/Linux),以及可能所有的衍生版本,很可能包括它的最近前身(至少回溯到你的内核3.14.26),都不再填充 /sys/class/hwmon

此外,lm-sensors 在板子上找不到任何传感器,所以这也是一个死胡同。

根据TI的说法,温度传感器从来没有真正意义上被终端用户使用。 TI甚至规定了一种通过外部传感器测量板温度的方法(请参见here)。

所以,这很遗憾,但事实就是如此。

编辑:我还发现Debian 8.2显示了我在这里描述的行为,但是今天我刷了Debian 7.9(从here; Linux bbone 3.8.13-bone79 #1 SMP Tue Oct 13 20:44:55 UTC 2015 armv7l GNU/Linux),那个版本带有一个完全填充的/sys,包括/sys/class/hwmon/hwmon0/device/temp1_input,这是以毫摄氏度为单位的温度读数。请注意,这可能是一个相对温度,不应该依赖于它(根据TI)。


你好,来自2021年和Debian 10,hwmon仍为空。你是否偶然想到了如何在Debian 7.9中填充/sys/class/hwmon - Osman-pasha
@Osman-pasha 我已经放弃了Beaglebone,现在专注于Raspberry Pi。 - Mausy5043

0

我还没有在Ubuntu 14.04上测试过它,但是这是关于这个问题的我的意见。有一个非常简单的工具tmon,在运行另一个进程时读取温度,就像timewatchtimeout等等。 tmon/sys/class/thermal/thermal_zone*周围的薄包装器,在运行CPU密集型进程(模拟、游戏等)时监视Linux计算机/服务器的温度时可能很有用。

您可以从这里下载.AppImage"二进制文件":https://github.com/gmagno/tmon/releases并立即方便地运行:

安装

wget https://github.com/gmagno/tmon/releases/download/v0.3.7/tmon-a461481-x86_64.AppImage
chmod +x tmon*.AppImage
# optional: you may put it somewhere convenient in your file system and add a symlink in /usr/local/bin/tmon

或者如果您更喜欢:

pip install tmonpy

使用方法

./tmon*.AppImage -h

示例

./tmon*.AppImage echo "Quick programs return a single value of temperature"
Quick programs return a single value of temperature


===================
Temp Monitor Report:

   Temp (°C) for a period of 0:00:00
   >> 58.0 °C <<

   /tmp/tmon-20200207@16h07m05-znn0x1o9.txt
===================

./tmon*.AppImage bash -c 'echo not so quick ones will show a chart; sleep 6'
not so quick ones will show a chart


===================
Temp Monitor Report:

   Temp (°C) for a period of 0:00:06
   60.0059.8659.7159.5759.4359.2959.1459.00  ┼╮   ╭─
   58.86  ┤│   │
   58.71  ┤│   │
   58.57  ┤│   │
   58.43  ┤│   │
   58.29  ┤│   │
   58.14  ┤│   │
   58.00  ┤╰───╯

   >> min: 58.0 °C <<
   >> avg: 58.4 °C <<
   >> max: 59.0 °C <<

   /tmp/tmon-20200207@16h08m25-p010ojhq.txt
===================

你也可以直接运行tmon,不带任何参数,它会按照你的期望运行。按下Ctrl-C终止进程并获取温度报告。

./tmon*.AppImage  # and wait a few seconds before pressing Ctrl-C
^C

===================
Temp Monitor Report:

   Temp (°C) for a period of 0:00:08
   60.0059.7159.4359.1458.86  ┤  ╭╮
   58.57  ┤  ││
   58.29  ┤  ││
   58.00  ┼╮╭╯│
   57.71  ┤││ │
   57.43  ┤││ │
   57.14  ┤││ │
   56.86  ┤╰╯ │
   56.57  ┤   │
   56.29  ┤   │
   56.00  ┤   ╰────

   >> min: 56.0 °C <<
   >> avg: 56.9 °C <<
   >> max: 59.0 °C <<

   /tmp/tmon-20200207@15h59m37-u4cd94qh.txt
===================

在我的 BeagleBone Black 上,/sys/class/thermal/ 是一个空目录。你在 BeagleBone Black 上使用的是什么操作系统/镜像以填充它呢? - Rick

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接