Bananian Linux - Bananian Linux
View Issue Details
0000056Bananian Linux[All Projects] Userlandpublic2014-10-13 17:292014-11-19 10:41
Thomas Kaiser 
Nico 
lowfeaturehave not tried
resolvedfixed 
 
14.09 
14.1114.11 
0000056: Add two shell functions to read out thermal sensors inside the A20 SoC and the AXP209 PMU
If these small shell code snippets http://pastebin.com/ZC5k9X2q [^] would be included the two shell functions soctemp and pmutemp would be available:

root@bananas ~ # soctemp 
42.5
root@bananas ~ # pmutemp
29.8

For more details compare with http://forum.lemaker.org/redirect.php?goto=findpost&ptid=6457&pid=33122&fromuid=33332 [^]
No tags attached.
Issue History
2014-10-13 17:29Thomas KaiserNew Issue
2014-10-13 17:33Thomas KaiserNote Added: 0000054
2014-10-14 20:44guestNote Added: 0000055
2014-10-16 13:37Thomas KaiserNote Added: 0000056
2014-10-19 12:46NicoAssigned To => Nico
2014-10-19 12:46NicoStatusnew => assigned
2014-10-19 12:46NicoTarget Version => later
2014-10-22 09:18Thomas KaiserNote Added: 0000061
2014-10-22 09:23Thomas KaiserNote Added: 0000062
2014-10-23 23:47guestNote Added: 0000063
2014-11-05 13:58NicoTarget Versionlater => 15.04
2014-11-05 14:08Thomas KaiserNote Added: 0000072
2014-11-10 11:42Thomas KaiserNote Added: 0000074
2014-11-13 14:00guestNote Added: 0000077
2014-11-13 14:41guestNote Added: 0000078
2014-11-14 11:56Thomas KaiserNote Added: 0000081
2014-11-19 08:44NicoTarget Version15.04 => 14.11
2014-11-19 10:40NicoStatusassigned => resolved
2014-11-19 10:40NicoResolutionopen => fixed
2014-11-19 10:41NicoFixed in Version => 14.11

Notes
(0000054)
Thomas Kaiser   
2014-10-13 17:33   
Silly me, there was a mistake in the pastebin code. The next to last line should read 'echo "scale=1; ${RawVal}/1000" | bc' without trailing parenthesis
(0000055)
guest   
2014-10-14 20:44   
Just a sidenote: The package 'bc' is not available by default in Bananian and must be installed manually.
(0000056)
Thomas Kaiser   
2014-10-16 13:37   
Thx for paying attention. Here is the bc free version that makes also temperature correction adjustable: http://pastebin.com/60mhgvaS [^]

Yesterday my A20-OLinuXIno-LIME2 arrived (which seems to be 100% compatible to Banana Pi -- I just rewrote fex/bin stuff and bootet a Banana distro). The temperatures outputted by soctemp were a few degrees to low so I had to adjust SoCTempAdjustment=1415 (estimated by finger sensing ;-)
(0000061)
Thomas Kaiser   
2014-10-22 09:18   
BTW: When these two functions will be added to Bananian then it has to be ensured that sunxi-dbgreg.ko will be loaded automatically at boot time otherwise the execution of the soctemp function with an UID != 0 will always fail.
(0000062)
Thomas Kaiser   
2014-10-22 09:23   
And here's one more fix: http://pastebin.com/Rspxv4bx [^] (the definition of ${SoCTempAdjustment} must be part of the function)
(0000063)
guest   
2014-10-23 23:47   
Does it happen on your machines as well, that sometimes soctemp() reports -144.7 degrees? This is the adjustment value which means that the actual read is empty or zero. It happens from time to time on my machine. When I try to rerun the command a few times, it works again.

Why is the sleep time necessary? Might it help to increase/decrease this value?
(0000072)
Thomas Kaiser   
2014-11-05 14:08   
Until it's not really clear how to interpret the values read out from A20 it's not a good idea to follow this approach right now. See the end of this thread or the referenced forum post for details:

https://groups.google.com/forum/#!topic/linux-sunxi/2zoxTcepPVo%5B1-25-false%5D [^]

People believe in numbers. Currently they get the thermal value from the PMU in their distros (and believe it's the CPU's), with the soctemp function they get some value without any meaning (and believe it's the CPU's).Since Nico postponed the inclusion of this RfE I'm sure the issue can be resolved in the meantime. For discussions related to this please use the forum link. This is a bug tracker :-)
(0000074)
Thomas Kaiser   
2014-11-10 11:42   
Final fixes: http://pastebin.com/FSvCXx6p [^]

When reading the A20's temperature the CHOP_TEMP_EN register (according to the A20's user manual: "Chop temperature calibration enable: 0: Disable, 1: Enable") remains enabled.

And I added a conversion to Fahrenheit: When the functions will be called with f or F as only argument then values will be converted from Celsius to Fahrenheit (without using bc of course ;-)
(0000077)
guest   
2014-11-13 14:00   
i got an error:
root@bananapi /usr/local/bin # ./cputemp
./cputemp: 28: ./cputemp: 378: not found
approx. °C
approx. 39.4°C
(0000078)
guest   
2014-11-13 14:41   
fixed by changing line 28:

CelsiusVal=$(echo $(( 0x${HexVal} - ${SoCTempAdjustment} )) | awk '{printf ("%0.1f",$1/10); }' )
(0000081)
Thomas Kaiser   
2014-11-14 11:56   
Thx, the fix of the fix: http://pastebin.com/jNLfSS4U [^]