Advertisement
Guest User

Add soctemp and pmutemp shell function to A20 based distros

a guest
Oct 16th, 2014
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.20 KB | None | 0 0
  1. #/bin/sh
  2.  
  3. # SoCTempAdjustment is needed because the A20 SoC delivers uncalibrated temp values
  4. SoCTempAdjustment=1447
  5.  
  6. soctemp() {
  7.         # ensure module sunxi-dbgreg.ko is loaded
  8.         grep -q sunxi_dbgreg </proc/modules || ( modprobe sunxi-dbgreg ; sleep 0.1 )
  9.        
  10.         # prepare registers
  11.         echo 'f1c25000:27003f' > /sys/devices/virtual/misc/sunxi-dbgreg/rw/write;
  12.         echo 'f1c25010:40000' > /sys/devices/virtual/misc/sunxi-dbgreg/rw/write;
  13.         echo 'f1c25018:10fff' > /sys/devices/virtual/misc/sunxi-dbgreg/rw/write;
  14.         echo 'f1c25004:10' > /sys/devices/virtual/misc/sunxi-dbgreg/rw/write;
  15.        
  16.         # let the value be written to syslog
  17.         echo 'f1c25020' > /sys/devices/virtual/misc/sunxi-dbgreg/rw/read;
  18.        
  19.         # wait 0.1 seconds
  20.         sleep 0.1
  21.        
  22.         # read return value from syslog and transform it into degrees Celsius
  23.         HexVal=$(tail /var/log/syslog | awk -F" 0x" '/ 0x/ {print $2}' | tail -n1 )
  24.         echo $(( 0x${HexVal} - ${SoCTempAdjustment} )) | awk '{printf ("%0.1f",$1/10); }'
  25. } # soctemp
  26.  
  27. pmutemp() {
  28.         awk '{printf ("%0.1f",$1/1000); }' </sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/temp1_input
  29. } # pmutemp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement