Jump to content


Photo

[INIT.D][SCRIPT] SetCPU like Profiles with init.d!

init.d tweakerz Script governor

  • Please log in to reply
17 replies to this topic

#1 MarkusMcNugen

MarkusMcNugen

    Blurred Effectz

  • Developer
  • 277 posts
  • LocationDecatur, MI
  • Current Device(s):Bionic

Posted 31 May 2013 - 09:31 PM

I was perusing the internets and found a init.d script to change governors based on screen state and I thought "Maybe I can take this one step further."

I originally made it just for a new Bionic Blurry JB update, but then figured I should share it with all of you!

*This script will only set CPU frequencies if Tweakerz OC Modules are installed*

*This script is currently set up with Stock Bionic frequencies.*

What does the script do?
It automatically changes the governor, scheduler, and CPU frequencies based on screen state, current battery level, and battery state. It originally had a CPU slot # check, but the razr doesnt have that problem so I removed it.

How does it work?

Note: There is a 10 second timer when the screen turns off. If turned back on within 10 seconds, it will not apply the sleep frequencies.

Infinite While Loop

  • Battery Discharging
    • Battery percentage greater than 15%
      • Screen On
        • If CPU Slots = 5
          • Set CPU Frequencies to (300,600,800,1000,1200)
        • If CPU Slots = 4
          • Set CPU Frequencies to (300,600,800,1000)
        • Set Governor to HotplugX
        • Set Scheduler to Noop
      • Screen Off
        • If CPU Slots = 5
          • Set CPU Frequencies to (300,350,450,525,600)
        • If CPU Slots = 4
          • Set CPU Frequencies to (300,400,500,600)
        • Set Governor to PegasusQ
        • Set Scheduler to SIO
    • Battery percentage less than or equal to 15%
      • Screen On
        • If CPU Slots = 5
          • Set CPU Frequencies to (300,450,600,800,1000)
        • If CPU Slots = 4
          • Set CPU Frequencies to (300,475,650,800)
        • Set Governor to PegasusQ
        • Set Scheduler to SIO
      • Screen Off
        • If CPU Slots = 5
          • Set CPU Frequencies to (300,350,450,525,600)
        • If CPU Slots = 4
          • Set CPU Frequencies to (300,400,500,600)
        • Set Governor to PegasusQ
        • Set Scheduler to SIO
  • Battery Charging
    • Screen On
      • If CPU Slots = 5
        • Set CPU Frequencies to (300,600,800,1000,1200)
      • If CPU Slots = 4
        • Set CPU Frequencies to (300,600,800,1000)
      • Set Governor to HotplugX
      • Set Scheduler to Noop
    • Screen Off
      • If CPU Slots = 5
        • Set CPU Frequencies to (300,350,450,525,600)
      • If CPU Slots = 4
        • Set CPU Frequencies to (300,400,500,600)
      • Set Governor to PegasusQ
      • Set Scheduler to SIO

End Infinite While Loop

*Its purposely set up to underclock the phone when less than 15% to save battery life till you can get to a charger. Obviously this can be changed with some simple editing.*

 

UPDATE: There are now two options that can be enabled that will turn off data when wifi is connected or turn data off when the screen if off. Unfortunately because I dont want to run a real infinite while loop, which would be bad for battery life, the option to turn data off when wifi is connected will only turn data on/off when the screen turns on or off. So if you enable that option and turn wifi off or on manually, you will have to turn the screen on or off or turn data on/off manually with a toggle or in settings.

 

Infinite While Loop... Isnt that bad for the CPU?

Traditionally yes, but this doesnt work like a traditional while loop. Thats because of the way /sys/power/wait_for_fb_wake and /sys/power/wait_for_fb_sleep work. Instead of just checking for the screen state, these files actually pause the script until that screen state is true. Basically, the script sets the awake profile then pauses until the screen turns off. Then it tries to apply the sleep profile. If the sleep profile is applied successfully, it pauses the script until the screen turns back on. Then the process repeats.

 

Why isnt it setting the CPU frequencies?

Download the tweakerz OC modules from the razr thread below if they are not already included with your ROM. Keep in mind that there are two different sets of flashable modules, one for the OTA and one for Kexec ROMs like AOKP and CM10.1.

Please Login or Register to see this Hidden Content

 

*I do not maintain the OC modules. If they do not work on your rom, then you will just have to settle with alternative way it sets the screen off frequencies which can be read below*

 

What if I dont have the OC modules?

Change the governor and schedulers to match your ROM. Its as easy as adding a # to the beginning of the current governor or scheduler line, and then deleting the # at the beginning of the line with the governor or scheduler you want. Default schedulers are usually interactive, hotplug, ondemand, userspace, and performance. Default schedulers are usually noop, deadline, and cfq.

 

 Without the OC modules the script will not set the custom CPU frequencies, but dont fret. Instead it sets the max frequency and minimum frequency for the lock screen. So basically instead of having 300, 350, 450, 525, and 600Mhz when the screen is off, it will have just 300, and 600Mhz wen the screen is off. Its not as efficient, but it will still help save battery life.

 

Customization:

I tried to set the script up so its fairly easy to understand and customize to your needs. Remember to change the governor, scheduler, and CPU frequencies to match your needs.

Installation:
Download and extract the script from below and place it in /system/etc/init.d on your phone and set permissions to 0644 and owner:group to 0:2000. Reboot, and enjoy!

 

Download:

Please Login or Register to see this Hidden Content

 

Script Code:

Please Login or Register to see this Hidden Content


  • soocold likes this

#2 Quadroller

Quadroller

    Member

  • Dedicated Supporter
  • PipPip
  • 29 posts
  • LocationWilmington, NC
  • Current Device(s):MOTO DROID BIONIC-2

Posted 01 June 2013 - 08:43 AM


How do I execute the bin file with the tweakerz app? I apologize if it's a dumbass question, but I'm learning & I don't want to screw anything up. I've got two slots set up with Blurry. My dd is on slot 1 & slot 2 is the one I'm learning with.
Sent from my BLURRED OUT BIONIC!!

#3 DLuke

DLuke

    Bionic Modder

  • Superuser
  • 69 posts
  • LocationNor*Cal

Posted 01 June 2013 - 12:46 PM

wow.. i like it.. nice work man!
Posted Image Posted Image
**So ive always held out on adding a donate link because this is just something i do for enjoyment.. but i have received a few requests recently to add one.. so if you enjoy my work and would like to buy me a beer or put some gas in my car, that would be very much appreciated.. but please continue to freely enjoy my mods without any feeling of obligation what-so-ever.. the last thing i want by adding this is for people to stop using my mods because they fell obligated.. Thanks

#4 MarkusMcNugen

MarkusMcNugen

    Blurred Effectz

  • Developer
  • 277 posts
  • LocationDecatur, MI
  • Current Device(s):Bionic

Posted 01 June 2013 - 03:26 PM

How do I execute the bin file with the tweakerz app? I apologize if it's a dumbass question, but I'm learning & I don't want to screw anything up. I've got two slots set up with Blurry. My dd is on slot 1 & slot 2 is the one I'm learning with.
Sent from my BLURRED OUT BIONIC!!

 

Its alright, we all began somewhere! This is an init.d script, it doesnt load through the tweakerz app. It goes into /system/etc/init.d/ with 755 permissions, owner: root, group: shell. But if you read the OP, the frequencies arent perfect. Ive been tweaking the script trying to get them right. This was more or less for experienced android users, and rom devs that use the Tweakerz modules.


  • Quadroller likes this

#5 Quadroller

Quadroller

    Member

  • Dedicated Supporter
  • PipPip
  • 29 posts
  • LocationWilmington, NC
  • Current Device(s):MOTO DROID BIONIC-2

Posted 01 June 2013 - 03:46 PM

Ok, thanks Markus. That pointed me in the right direction.

Sent from my BLURRED OUT DROID BIONIC!!
  • MarkusMcNugen likes this

#6 MarkusMcNugen

MarkusMcNugen

    Blurred Effectz

  • Developer
  • 277 posts
  • LocationDecatur, MI
  • Current Device(s):Bionic

Posted 01 June 2013 - 03:52 PM

Ok, thanks Markus. That pointed me in the right direction.

Sent from my BLURRED OUT DROID BIONIC!!

 

Once I get it perfected, this will actually be included in a new Blurry JB OTA. Blurry already has one built in, so in order to properly use it before the Blurry JB OTA comes out, you will need to delete 04modules and 07governor from the init.d folder.



#7 nakedtime

nakedtime

    Sauce Boss

  • Members
  • PipPip
  • 200 posts
  • LocationOhio
  • Current Device(s):iPhod 3gs, Droid 2, Droid Bionic

Posted 01 June 2013 - 08:54 PM

Infinite while loop???
Those usually are bad for teh battery life. :/
I'm from the internet and so can you!

#8 MarkusMcNugen

MarkusMcNugen

    Blurred Effectz

  • Developer
  • 277 posts
  • LocationDecatur, MI
  • Current Device(s):Bionic

Posted 01 June 2013 - 10:28 PM

Infinite while loop???
Those usually are bad for teh battery life. :/

 

There are other init.d scripts that do the same thing. It wont stop the phone from going into deep sleep, and you can change all 5 cpu slots frequencies instead of just setting 300Mhz and 600Mhz for the lockscreen. With other frequencies between for it to step up or down to, it can save more standby battery life than SetCPU would. Plus, although its different, SetCPU does the same type of thing. It runs a service in the background that changes the frequencies based on the users variables, constantly monitoring those variables for when to switch. Much like an infinite while loop.



#9 MarkusMcNugen

MarkusMcNugen

    Blurred Effectz

  • Developer
  • 277 posts
  • LocationDecatur, MI
  • Current Device(s):Bionic

Posted 05 June 2013 - 09:12 PM

Will be updating tomorrow with a rewritten script. It still does exactly what OP says it does, but is more efficient. It doesnt constantly reapply the governor, scheduler, and frequency values if already awake or asleep like this one did.

 

It also has a 10 second timer when the screen goes off, and if turned back on before it counts to 10 it will not apply sleep frequencies. < This helps avoid lag from the screen switching on and off quickly or multiple times in a row.


  • nakedtime likes this

#10 nakedtime

nakedtime

    Sauce Boss

  • Members
  • PipPip
  • 200 posts
  • LocationOhio
  • Current Device(s):iPhod 3gs, Droid 2, Droid Bionic

Posted 05 June 2013 - 11:23 PM

I want to manipulate my CPU table on 4.2.2. Any idea on how to do this? I tried the regular "insmod /system/lib/modules/symsearch.ko" way but that totally doesn't work.
I'm from the internet and so can you!

#11 MarkusMcNugen

MarkusMcNugen

    Blurred Effectz

  • Developer
  • 277 posts
  • LocationDecatur, MI
  • Current Device(s):Bionic

Posted 06 June 2013 - 02:52 AM

I want to manipulate my CPU table on 4.2.2. Any idea on how to do this? I tried the regular "insmod /system/lib/modules/symsearch.ko" way but that totally doesn't work.

 

Im assuming you mean for CM10 or AOKP... you can try flashing the CM10.1 Kexec modules from this thread

Please Login or Register to see this Hidden Content


  • nakedtime likes this

#12 nakedtime

nakedtime

    Sauce Boss

  • Members
  • PipPip
  • 200 posts
  • LocationOhio
  • Current Device(s):iPhod 3gs, Droid 2, Droid Bionic

Posted 06 June 2013 - 07:59 PM

Im assuming you mean for CM10 or AOKP... you can try flashing the CM10.1 Kexec modules from this thread

Please Login or Register to see this Hidden Content

Excellent. Thank you Sir
I'm from the internet and so can you!

#13 MarkusMcNugen

MarkusMcNugen

    Blurred Effectz

  • Developer
  • 277 posts
  • LocationDecatur, MI
  • Current Device(s):Bionic

Posted 13 June 2013 - 11:59 AM

Script has been updated to be more efficient. I didnt pretty up the code this time in the post. If you want to see it with the different colors and such like it was before, open the script with Notepad++ and select Language>S>Shell.



#14 MarkusMcNugen

MarkusMcNugen

    Blurred Effectz

  • Developer
  • 277 posts
  • LocationDecatur, MI
  • Current Device(s):Bionic

Posted 15 June 2013 - 03:17 PM

UPDATE:

Fixed some programming errors that stopped it from applying the sleep frequencies. Had to change the method for checking screen state, but it completely works now.


  • nakedtime likes this

#15 MarkusMcNugen

MarkusMcNugen

    Blurred Effectz

  • Developer
  • 277 posts
  • LocationDecatur, MI
  • Current Device(s):Bionic

Posted 01 July 2013 - 12:29 AM

Script updated. 

 

No longer writes a log file in /data/ to read the screen state and 2 options have been added that allow data to be turned off when the screen turns off, or when wifi is connected (Read the update in the OP, it has some more info you will need for disabling data when wifi connected.)



#16 Int_Rnd_Pooka

Int_Rnd_Pooka

    Member

  • Members
  • PipPip
  • 284 posts
  • Current Device(s):Bionic

Posted 21 July 2013 - 05:06 PM

Anyone have a link to working OC modules for the kexec kernels?


  • nakedtime likes this

#17 nakedtime

nakedtime

    Sauce Boss

  • Members
  • PipPip
  • 200 posts
  • LocationOhio
  • Current Device(s):iPhod 3gs, Droid 2, Droid Bionic

Posted 21 July 2013 - 06:04 PM

Anyone have a link to working OC modules for the kexec kernels?

This. I want
I'm from the internet and so can you!

#18 MarkusMcNugen

MarkusMcNugen

    Blurred Effectz

  • Developer
  • 277 posts
  • LocationDecatur, MI
  • Current Device(s):Bionic

Posted 21 July 2013 - 08:27 PM

I wish I could help you but I havent been able to find any for the newer kexec kernels.







Also tagged with one or more of these keywords: init.d, tweakerz, Script, governor

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users