Forums › Reference, Evaluation, and Development Boards › OSD32MP1-RED › How to read OSD32MP1-RED CPU/SiP Temperature in Debian Image
Tagged: OSD32MP1-RED Temperature
As per data sheet, the STM32MP157C devices embed a temperature sensor that is internally connected to ADC2_INP12.
The OSD32MP1-RED device tree also shows “temperature sensor” at adc2 and jadc2 channels 12.
I don’t see any kernel attribute to read current temperature value from this sesnor.
debian@osd1rmk3:~$ ls -al /sys/firmware/devicetree/base/soc/adc@48003000/adc@100
-r–r–r– 1 root root 4 Oct 22 19:13 ‘#io-channel-cells’
-r–r–r– 1 root root 16 Oct 22 19:13 compatible
-r–r–r– 1 root root 3 Oct 22 19:13 dma-names
-r–r–r– 1 root root 16 Oct 22 19:13 dmas
-r–r–r– 1 root root 4 Oct 22 19:13 interrupt-parent
-r–r–r– 1 root root 4 Oct 22 19:13 interrupts
-r–r–r– 1 root root 4 Oct 22 19:13 name
-r–r–r– 1 root root 4 Oct 22 19:13 phandle
-r–r–r– 1 root root 4 Oct 22 19:13 reg
-r–r–r– 1 root root 4 Oct 22 19:13 st,adc-channels
-r–r–r– 1 root root 4 Oct 22 19:13 st,min-sample-time-nsecs
-r–r–r– 1 root root 5 Oct 22 19:13 status
debian@osd1rmk3:~$
debian@osd1rmk3:~$ ls -al /sys/firmware/devicetree/base/soc/adc@48003000/jadc@100
-r–r–r– 1 root root 4 Oct 22 19:13 ‘#io-channel-cells’
-r–r–r– 1 root root 16 Oct 22 19:13 compatible
-r–r–r– 1 root root 4 Oct 22 19:13 interrupt-parent
-r–r–r– 1 root root 4 Oct 22 19:13 interrupts
-r–r–r– 1 root root 5 Oct 22 19:13 name
-r–r–r– 1 root root 4 Oct 22 19:13 reg
-r–r–r– 1 root root 4 Oct 22 19:13 st,adc-channels
-r–r–r– 1 root root 0 Oct 22 19:13 st,injected
-r–r–r– 1 root root 4 Oct 22 19:13 st,min-sample-time-nsecs
-r–r–r– 1 root root 9 Oct 22 19:13 status
debian@osd1rmk3:~$
How do I enable and read this internal temperature sensor using echo/cat command?
Any help much appricated.
Here is a script that works on the BRK to display the ADC temperatures. I found that the temperature device driver is disabled on the RED so you will need to enable it in the device tree for this to work.
EDIT: I am not sure why stray HTML tags are getting injected in the code block below. You will need to fix this before running the script.
1 2 3 4 5 6 7 8 9 10 11 12 | #!/bin/sh # See: https://elixir.bootlin.com/linux/v4.19.94/source/Documentation/ABI/testing/sysfs-bus-iio dir='/sys/bus/platform/drivers/stm32-adc-temp/48003000.adc:temp/iio:device2' raw=<code>cat $dir/in_temp_raw offset=<code>cat $dir/in_temp_offset scale=<code>cat $dir/in_temp_scale printf "Value read: raw %0f\n" $raw printf "Value read: offset %0f\n" $offset printf "Value read: scale %0f\n" $scale temperature=<code>echo "scale=3;($raw*$scale + $offset*$scale) / 1000" | bc echo "Temperature $temperature C" printf "Temperature %.01f C\n" $temperature |
In addition to inputs from Carlos, please take a look at the temp sensor device tree entries for OSD32MP1-BRK here: https://github.com/octavosystems/OSD32MP1-BRK-device-tree/blob/master/linux-v5.4/stm32mp157c-osd32mp1-brk.dts#L993
Best,
Neeraj
Octavo Systems LLC all rights reserved
OCTAVO is registered in the U.S. Patent and Trademark Office. OSD, C-SiP, and the Octavo Logo are trademarks of Octavo Systems LLC.
"*" indicates required fields
"*" indicates required fields
"*" indicates required fields
"*" indicates required fields