Project

General

Profile

Reading Temperature and Power Monitors

Objective

This example will demonstrate multiple ways to read the two available CPU die temperature monitor as well as display the current and power consumption of the MitySOM-AM62 module.

The sensors command, part of the lmsensors package, included in yocto, will display the information:

root@mitysom-am62x:/tmp# sensors
ltc2945-i2c-1-6f
Adapter: OMAP I2C adapter
in1:           3.27 V  (min =  +0.00 V, max = +102.38 V)
                       (lowest =  +3.27 V, highest =  +3.30 V)
in2:         983.00 mV (min =  +0.00 V, max =  +2.05 V)
                       (lowest =  +0.98 V, highest =  +0.99 V)
power1:        1.13 W  (lowest = 317.62 mW, highest =   1.97 W)
                       (max = 524.29 W, min =   0.00 W)
curr1:       344.00 mA (min =  +0.00 A, max =  +5.12 A)
                       (lowest =  +0.10 A, highest =  +0.60 A)

main0_thermal-virtual-0
Adapter: Virtual device
temp1:        +53.5 C  (crit = +105.0 C)

main1_thermal-virtual-0
Adapter: Virtual device
temp1:        +52.4 C  (crit = +105.0 C)

root@mitysom-am62x:/tmp#

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 k3-am62-thermal.dtsi The same file sets a critical shutdown temperature of 105C. If either sensor hits this temperature, the linux kernel will issue an orderly shutdown to protect the hardware.

thermal_zones: thermal-zones {
    main0_thermal: main0-thermal {
        polling-delay-passive = <250>; /* milliseconds */
        polling-delay = <500>; /* milliseconds */
        thermal-sensors = <&wkup_vtm0 0>;

        trips {
            main0_crit: main0-crit {
                temperature = <105000>; /* milliCelsius */
                hysteresis = <2000>; /* milliCelsius */
                type = "critical";
            };
        };
    };

    main1_thermal: main1-thermal {
        polling-delay-passive = <250>; /* milliseconds */
        polling-delay = <500>; /* milliseconds */
        thermal-sensors = <&wkup_vtm0 1>;

        trips {
            main1_crit: main1-crit {
                temperature = <105000>; /* milliCelsius */
                hysteresis = <2000>; /* milliCelsius */
                type = "critical";
            };
        };
    };
};

There are 2 thermal zones, listed below:

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

==> /sys/class/thermal/thermal_zone1/type <==
main1-thermal

You can get the temperatures by reading the temp file in each zone, or using the sensors command mentioned above (they read the same information).

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

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

Conclusion

Multiple methods for reading different temperatures have been demonstrated.

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