Announcement

Collapse
No announcement yet.

Announcement

Collapse
No announcement yet.

Dynamic CPU speed depending on CPU Temperature - no more crashes :)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Dynamic CPU speed depending on CPU Temperature - no more crashes :)

    I have MK808B original and as we all know if we put a load of 100% on the CPU for a certain period of time (a few minutes if overclocked to 1600, a little more for lower overclocks) it will overheat and either restart or lock.
    Reason - although it DOES HAVE TEMPERATURE SENSOR (some guys said it didn't) it is NOT USING IT.
    Solution - I wrote the script below that will lower the speed if it gets to hot - mine crashes at 123 degrees celsius so I limited it to 115. Change the limit to whatever suits you
    Save the script below as cpucontrol.sh in your sdcard
    and run this command on an android terminal (might work with adb but I never used it)
    Code:
    su -c 'watch -n 10 "sh /sdcard/cpucontrol.sh"' 2>/dev/null 1>/dev/null &

    Code:
     #!/system/bin/sh
     # This script will control the CPU frequency, increasing to maximum if temperature below limit
     # and decreasing to minimum if temperature surpasses the limit
      
     # First we obtain the current temperature and parse the data to variable temp
     temp=$(cat /sys/module/tsadc/parameters/temp0 | awk '{print $2}')
      
     # Next we assign a limit for our maximum temperature
     limit=115
      
     # And we set our cpu governor to powersave because we need a governor with fixed cpu speed 
     # Many changes needed to the script if using performance or another governor.
     echo "powersave" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
      
     # Now we set our condition - if temperature is greater than the limit, send message to decrease cpu speed
    
     if [[ "$temp" -gt "$limit" ]] ;
    
     then echo "252000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq & cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq 
      
     # If temperature is still below limit, increase cpu speed
     else echo "1416000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq & echo "1416000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq & cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
      
     fi
    If you want to check the temperature and cpu speed run this (press CONTROL+C to exit from it):
    Code:
    su -c 'watch -n 5 cat /sys/devices/system/cpu/cpu*/cpufreq/cpuinfo_cur_freq /sys/module/tsadc/parameters/temp*'
    And if you want to do a burn test on the cpu this is an option:
    Code:
     echo "This is a stress test on the cpu"
    for i in 1 2 ; do while : ; do : ; done & done
    To kill/stop it please see the 2 numbers that shows after pressing enter (example 1: 4444 2:4445 and type:
    Code:
     kill 4444 4445
    Good luck and enjoy

    By the way, if someone knows how to put this in init.d so it starts at every boot, please tell me. I've tried and failed... Maybe my rom doesn't have perfect init.d support - Prajister 1.0...

    #2
    Nice script...i wasn't aware that there was a temp sensor. Will test this out.
    Prahjister ****MK808(nonB)****MK808B V5****MK808B Plus****UBOX R89**** CX919****MK808B Pro****Nexbox N9****Eny Em95****Matricon Q2****Tanix TX5 Pro****

    Comment


      #3
      libmedia_MK808B_PassthroughPatchV2_by_Stafstrom.zip
      Originally posted by prahjister View Post
      Nice script...i wasn't aware that there was a temp sensor. Will test this out.
      Thank you prahjister. If you get it working on boot please tell me how to do it ok? Might be helpful for some people...

      I'm using your rom but might give another one a try that's for the mk802iiis and has 5.1 passthrough in xbmc if using a version that supports the libmedia.so patch (like beyondxbmx).
      Requires 3 things:
      - rom with 3 options for sound in android settings: HDMI; HDMI 5.1; and HDMI passthrough... Only this last options works...
      -changing the libmedia.so in system with a patched one as well (Here it is - patched by stafstrom in minix forums).
      -Beyond XBMC or other with patch support...

      Comment


        #4
        Originally posted by joaomfds View Post
        [ATTACH]7137[/ATTACH]

        Thank you prahjister. If you get it working on boot please tell me how to do it ok? Might be helpful for some people...

        I'm using your rom but might give another one a try that's for the mk802iiis and has 5.1 passthrough in xbmc if using a version that supports the libmedia.so patch (like beyondxbmx).
        Requires 3 things:
        - rom with 3 options for sound in android settings: HDMI; HDMI 5.1; and HDMI passthrough... Only this last options works...
        -changing the libmedia.so in system with a patched one as well (Here it is - patched by stafstrom in minix forums).
        -Beyond XBMC or other with patch support...
        to get it working in boot place in /system/etc/init.d and chmod 777 xxxxx

        Try spmc for hdmi passthrough...
        Prahjister ****MK808(nonB)****MK808B V5****MK808B Plus****UBOX R89**** CX919****MK808B Pro****Nexbox N9****Eny Em95****Matricon Q2****Tanix TX5 Pro****

        Comment


          #5
          For passthrough the 3rd option (hdmi passthrough) has to be present in Android Settings and this is dependent on the rom (not only on the xbmc version)...

          Regarding the script I made it simpler and all in one file... It should run well if put in /etc/init.d/
          But try first running it in the android terminal and then doing the below command to check the current frequency (should be 1416000):
          Code:
          cat /sys/devices/system/cpu/cpu*/cpufreq/cpuinfo_cur_freq
          Code:
           
          while true
           do
            temp=$(cat /sys/module/tsadc/parameters/temp0 | awk '{print $2}')
            limit=115
            echo "powersave" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
            if [[ "$temp" -gt "$limit" ]] ;
             then echo "252000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
             else echo "1416000" >/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq & echo "1416000"> /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
            fi
          sleep 10 &
          done
          Last edited by joaomfds; 07-15-2014, 09:04. Reason: Deleted some new line stuff that could screw up the script if using copy and paste

          Comment


            #6
            Thanks for the script. What rom are you referring to? I am guessing it works on on a mk808b original? I would love to have working passthrough in xbmc.

            Comment


              #7
              Originally posted by Takenover83 View Post
              Thanks for the script. What rom are you referring to? I am guessing it works on on a mk808b original? I would love to have working passthrough in xbmc.
              Try spmc and my rom 1.2
              Prahjister ****MK808(nonB)****MK808B V5****MK808B Plus****UBOX R89**** CX919****MK808B Pro****Nexbox N9****Eny Em95****Matricon Q2****Tanix TX5 Pro****

              Comment


                #8
                Originally posted by prahjister View Post
                Try spmc and my rom 1.2
                Hi, your roms are great work. Is HDMI passthrough proven to work with your rom and spmc 13.2?
                or are you just asking to give a try and see?

                Comment


                  #9
                  Originally posted by PMisYMMV View Post
                  Hi, your roms are great work. Is HDMI passthrough proven to work with your rom and spmc 13.2?
                  or are you just asking to give a try and see?
                  prahjister, simple way to check is go to android sound settings and see how many options you have: hdmi, hdmi 5.1 multipoint, hdmi passthrough...
                  If it has only the first 2 options, no 5.1 in XBMC possible...

                  Comment

                  Working...
                  X