Project

General

Profile

Example SOM Temperature Monitors

TODO temp monitors

Objective

This example will demonstrate multiple ways to read the temperature monitors that are available. These include:

  • Using omapconf
  • Using the sysfs thermal zones
  • Using the standard lm-sensors
  • Using the FPGA value available through the Xilinx XADC IP core.

Using omapconf

The TI-provided omapconf tool has a shortcut to view the different temperatures quickly. See the example below:

root@mitysom-am57x:~# omapconf show temp
OMAPCONF (rev v1.74-1-g40ab0a2 built Fri Jan 22 21:22:26 UTC 2021)

...

|--------------------------------------------|
| Sensor | Temperature (C) | Temperature (F) |
|--------------------------------------------|
| MPU    | 52              | 125             |
| GPU    | 53              | 127             |
| CORE   | 52              | 125             |
| IVA    | 52              | 125             |
| DSPEVE | 51              | 123             |
|--------------------------------------------|

Using sysfs thermal_zones

The kernel provides the thermal zone subsystem to auto monitor temperature sensors and can take different actions based on configurable thresholds.

The thermal zones are defined in the dra7.dtsi file and a cpu temp alert threshold has been set in am57xx-mitysom.dtsi to turn on the cpu fan output (J11). Look for cpu_alert1 with the following text:

/* Update cpu temp alert threshold so fan turns on at 45C */
/* Note: A threshold of 45C at room temp leads to the fan being on most of the time
 * 45C-69C: The fan goes on and off every few seconds which is audibly distracting
 * 70C: The fan comes on only when CPU is active
 */
&cpu_trips {
    cpu_alert1: cpu_alert1 {
        temperature = <45000>; /* millicelsius */
        hysteresis = <2000>; /* millicelsius */
        type = "active";
    };
};

/* Use gpio_fan for cpu temp alert1 */
&cpu_cooling_maps {
    map1 {
        trip = <&cpu_alert1>;
        cooling-device = <&gpio_fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
    };
};

There are 5 thermal zones, listed below:

root@mitysom-am57x:~# tail /sys/class/thermal/thermal_zone*/type
==> /sys/class/thermal/thermal_zone0/type <==
cpu_thermal

==> /sys/class/thermal/thermal_zone1/type <==
gpu_thermal

==> /sys/class/thermal/thermal_zone2/type <==
core_thermal

==> /sys/class/thermal/thermal_zone3/type <==
dspeve_thermal

==> /sys/class/thermal/thermal_zone4/type <==
iva_thermal

You can get the temperatures by reading the temp file in each zone

root@mitysom-am57x:~# tail /sys/class/thermal/thermal_zone*/temp
==> /sys/class/thermal/thermal_zone0/temp <==
52600

==> /sys/class/thermal/thermal_zone1/temp <==
52600

==> /sys/class/thermal/thermal_zone2/temp <==
53000

==> /sys/class/thermal/thermal_zone3/temp <==
52200

==> /sys/class/thermal/thermal_zone4/temp <==
53800

Using standard lm-sensors

The lm-sensors package provides user-space support for hardware monitoring drivers. Many Linux applications use libsensors to detect and read a devices temperature sensors.

  • Attached is a zip file containing the v3.6.0 lm-sensors. They can be installed using the following command:
    lmsensors_3.6.0_armv7at2hf-neon.zip
    root@mitysom-am57x:~# opkg install libsensors5_3.6.0-r0_armv7at2hf-neon.ipk lmsensors-sensord_3.6.0-r0_armv7at2hf-neon.ipk lmsensors-sensors_3.6.0-r0_armv7at2hf-neon.ipk rrdtool_1.7.0-r0_armv7at2hf-neon.ipk
    
  • The sensors command can then be used to show the different hardware sensors on the board.
    root@mitysom-am57x:~# sensors
    core_thermal-virtual-0
    Adapter: Virtual device
    temp1:        +53.0 C  (crit = +105.0 C)
    
    cpu_thermal-virtual-0
    Adapter: Virtual device
    temp1:        +52.2 C  (crit = +105.0 C)
    
    gpio_fan-isa-0000
    Adapter: ISA adapter
    fan1:        13000 RPM  (min =    0 RPM, max = 13000 RPM)
    
    dspeve_thermal-virtual-0
    Adapter: Virtual device
    temp1:        +52.2 C  (crit = +105.0 C)
    
    gpu_thermal-virtual-0
    Adapter: Virtual device
    temp1:        +53.0 C  (crit = +105.0 C)
    
    ltc2945-i2c-4-6e
    Adapter: OMAP I2C adapter
    in1:           4.97 V  (min =  +0.00 V, max = +102.38 V)
                           (lowest =  +4.97 V, highest =  +4.97 V)
    in2:           1.01 V  (min =  +0.00 V, max =  +2.05 V)
                           (lowest =  +1.01 V, highest =  +1.01 V)
    power1:        3.84 W  (lowest =   2.59 W, highest =   6.93 W)
                           (max =   1.05 kW, min =   0.00 W)
    curr1:       773.00 mA (min =  +0.00 A, max = +10.24 A)
                           (lowest =  +0.52 A, highest =  +1.39 A)
    
    iva_thermal-virtual-0
    Adapter: Virtual device
    temp1:        +52.2 C  (crit = +105.0 C)
    

Note: In an older kernel, the power and current values shown for the ltc2945 need to be divided by 10 to get the correct values. In the table above, a newer kernel has been used.

Note: If you only see the "ltc2945-i2c-4-6e" and "gpio_fan-isa-0000" devices. Make sure you compile and run the latest kernel version as of 2022/11/10
A fix was applied in this commit: https://support.criticallink.com/gitweb/?p=processor-sdk-linux.git;a=commit;h=004d7911fbfb19e1503c1d249bb610410d8717cd

Using the FPGA

The FPGA temperature can be obtained through Xilinx's XADC IP core. With this core enabled in the FPGA, the temperature can be accessed via
the GPMC interface. See Critical Links example FPGA that includes the XADC IP core found here: https://support.criticallink.com/git/mitysom-am57x-ref.git
Documentation for the XADC can be found here: https://www.xilinx.com/support/documentation/user_guides/ug480_7Series_XADC.pdf

If using Critical Link's example FPGA found here: https://support.criticallink.com/git/mitysom-am57x-ref.git
You can access the FPGA temperature as follows:

root@mitysom-am57x:~# devmem2 0x01000180 h
/dev/mem opened.
Memory mapped at address 0xb6fda000.
Read at address  0x01000180 (0xb6fda180): 0x9AA7
root@mitysom-am57x:~#

Now convert the returned value to Celsius by ((ADC_CODE * 503.975) / 4096) - 273.15
1. 0x9AA7 >> 4 --> 0x9AA (The XADC core uses the upper 12 bits for data)
2. 0x9AA --> 2474 decimal
3. ((2474 * 503.975) / 4096) - 273.15 = 31.25 C

The FPGA also supports outputting the temperature via a remote temperature sensor (e.g. LTC2997) which would need to be placed on the baseboard that would output a linear VPTAT analog voltage representing the temperature which could be read by an ADC.

Note: (todo) The output of the devmem2 command when reading this location may have some instability. Multiple reads may be needed to get the correct value.

Conclusion

Multiple methods for reading different temperatures have been demonstrated.

Go to top
Add picture from clipboard (Maximum size: 1 GB)