SHARE
TWEET

Add soctemp and pmutemp shell function to A20 based distros

a guest Oct 13th, 2014 413 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Add to /etc/zsh/zprofile
  2.  
  3. if [ -d /etc/profile.d ]; then
  4.   for i in /etc/profile.d/*.sh; do
  5.     if [ -r $i ]; then
  6.       . $i
  7.     fi
  8.   done
  9.   unset i
  10. fi
  11.  
  12. Add as /etc/profile.d/get-thermal-data.sh
  13.  
  14. #/bin/sh
  15. soctemp() {
  16.         # ensure module sunxi-dbgreg.ko is loaded
  17.         grep -q sunxi_dbgreg </proc/modules || modprobe sunxi-dbgreg
  18.        
  19.         # prepare registers
  20.         echo 'f1c25000:27003f' > /sys/devices/virtual/misc/sunxi-dbgreg/rw/write;
  21.         echo 'f1c25010:40000' > /sys/devices/virtual/misc/sunxi-dbgreg/rw/write;
  22.         echo 'f1c25018:10fff' > /sys/devices/virtual/misc/sunxi-dbgreg/rw/write;
  23.         echo 'f1c25004:10' > /sys/devices/virtual/misc/sunxi-dbgreg/rw/write;
  24.        
  25.         # write value to syslog
  26.         echo 'f1c25020' > /sys/devices/virtual/misc/sunxi-dbgreg/rw/read;
  27.        
  28.         # wait 0.1 seconds
  29.         sleep 0.1
  30.        
  31.         # read return value from syslog and transform it into degrees Celsius
  32.         HexVal=$(tail /var/log/syslog | awk -F" 0x" '/ 0x/ {print $2}' | tail -n1 | tr '[:lower:]' '[:upper:]')
  33.         RawVal=$(echo "ibase=16; ${HexVal}" | bc)
  34.         echo "scale=1; (${RawVal}-1447)/10" | bc
  35. } # soctemp
  36.  
  37. pmutemp() {
  38.         read RawVal </sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/temp1_input
  39.         echo "scale=1; (${RawVal}/1000" | bc
  40. } # pmutemp
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top