• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

[MOD][LP-MM] Z5 Endurance Tweaks v5 (battery life) (Upd 27/11: new profile Xenon v2)

Search This thread

nreuge

Senior Member
Apr 22, 2013
2,641
2,395
Saint-Nazaire
Some system tweaks specifically conceived for our SoC Snapdragon 810 can enhance the battery life of our Xperia Z5.

Features:
- Power Tweaks for S810 (no performance loss)
- Various common performance / battery friendly system tweaks (no performance loss)
- Tuned Interactive Governor Profiles for S810 (performance depends on the chosen profile)


Requirements:
- Z5 and Z3+/Z4 series
- Root
- Busybox app installed and activated
- SManager app installed

Installation:

- If you were using a previous version of this mod, delete all the scripts

- Download the attached Z5_Endurance_Tweaks_v5.zip (this is not a flashable zip)
- Copy the folder Z5_Endurance_Tweaks from the zip and paste it to "/system/etc/"
- Open SManager and navigate up to /system/etc/Z5_Endurance_Tweaks
- Select the file "Power_tweaks.sh" and set it as su and boot, save the configuration, and run it
- Select the file "Setprop_tweaks.sh" and set it as su and boot, save the configuration, and run it
- Select the file "Gov_prof_Deadpool.sh" and set it as su and if you want to use it as your default profile governor, set it as boot, save the configuration,
- Select the file "Gov_prof_DragonFly.sh" and set it as su and if you want to use it as your default profile governor, set it as boot, save the configuration,
- Select the file "Gov_prof_Excalibur.sh" and set it as su and if you want to use it as your default profile governor, set it as boot, save the configuration,
- Run your chosen default profile governor
In the SManager dashboard, you should have something like this:

29ewWRr.jpg


Governor profiles indications:

Performance: Stock > DragonFly > Excalibur > Deadpool
Battery life: Deadpool > Excalibur > DragonFly > Stock

Update (27/11): new profile attached - Xenon v2 especially made for Z5 by @koekoek91 and @_LLJY
Potentially as battery friendly as Deadpool (?) but with great performance (as good as Dragonfly ? stock ? better ?), good for common users and for gamers... Pls give feedback!

- Enjoy :D

Notes:
- Alternately, you can put your chosen scripts in your init.d folder if you have init.d support, but I strongly encourage to use SManager, it's much more reliable and versatile
- Wait a little before to draw any opinions on this tweaks mod.
- Feedbacks and suggestions for futures versions are strongly encouraged.

Credits:
@Naman Bhalla and @henryzhang317 for their Power Tweaks for SnapDragon 810 Devices
@xperator for his tuned interactive governor profiles
@zacharias.maladroit
@_LLJY and @androidexpert35 for some tweaks

Changelog:
v5 (08/10)
- Darkspice and Heimdall interactive governor profiles removed (outdated)
- DeadPool, Excalibur and DragonFly interactive governor profiles added
v4 (05/09):
- Some tweaks added, some other removed
v3 (05/03):
- HEIMDALLv3 interactive governor profile slightly modified by me
- DarkSpiceR7.5 interactive governor profile added, slightly modified by me
- New tweaks added in Setprop_tweaks.sh
v2 (27/02): All the scripts rewritten and various common performance / battery friendly system tweaks added (Setprop_tweaks.sh)
v1 (24/02): Initial release
 

Attachments

  • Z5_Endurance_tweaks_v3.zip
    4.5 KB · Views: 1,946
  • Z5_Endurance_tweaks_v4.zip
    5 KB · Views: 428
  • Z5_Endurance_tweaks_v5.zip
    6 KB · Views: 2,758
  • Gov_prof_Xenon_v2.sh.txt
    10.4 KB · Views: 1,592
Last edited:

ChristianLetti

Senior Member
May 20, 2014
156
57
Hey nreuge,

First of all, thanks for the scripts. Hope they work really nice :)

About the modifications/tweaks, could you please specify what changes have been made, and what to expect from them?

---- Edit

Just made some tests over here...
It actually made my phone a bit laggy.
 
Last edited:
  • Like
Reactions: SynysterGates123

nreuge

Senior Member
Apr 22, 2013
2,641
2,395
Saint-Nazaire
Hey nreuge,

First of all, thanks for the scripts. Hope they works really nice :)

About the modifications/tweaks, could you please specify what changes have been made, and what to expect from them?

Hi !
The Power Teaks controls the qualcomm power drivers in a more efficient way than stock.
The Tuned Interactive Governor Profile is made to be very battery friendly with great responsiveness/snappyness.

If you want more information, follow the links given in credits section. Note that only some tweaks have been selected by me. If you still want more information, just look at the script ^^
 

zacharias.maladroit

Recognized Developer
Last edited:

nreuge

Senior Member
Apr 22, 2013
2,641
2,395
Saint-Nazaire
Just made some tests over here...
It actually made my phone a bit laggy.

For me, hard to say...

Seeing all these permissions makes me feel dizzy - but it guarantees that the job gets done :cool:

:p

@nreuge how much of an SOT improvement did you observe ? (already several days of usage with those scripts ?)

Or did you spot these tweaks today ? :)

I've tested these tweaks the last 2 days.
I've not etablished any reliable testing methodology to measure any improvements on battery life. It's why I'm eagerly waiting for feedbacks.
I've the feeling they are efficient in conditions of moderate usage, maybe less for intensive tasks...
 
Last edited:

zacharias.maladroit

Recognized Developer
Leaving this here:

https://github.com/zachariasmaladro...ntation/devicetree/bindings/power/qpnp-fg.txt
QTI's QPNP PMIC Fuel Gauge Device

https://github.com/zachariasmaladro...devicetree/bindings/power/qpnp-smbcharger.txt
QPNP SMB Battery Charger


https://github.com/zachariasmaladro..._Sun-Kernel_v6-stable/drivers/power/qpnp-fg.c


So you're dealing with one of the most essential parts of your phone (charger and [assumedly] how much the battery offers the system)

Any no one can give more details on this ... tough stuff



drivers/power/qpnp-smbcharger.c:static int vf_adjust_low_threshold = 5;
drivers/power/qpnp-smbcharger.c:module_param(vf_adjust_low_threshold, int, 0644);
drivers/power/qpnp-smbcharger.c:static int vf_adjust_high_threshold = 7;
drivers/power/qpnp-smbcharger.c:module_param(vf_adjust_high_threshold, int, 0644);
drivers/power/qpnp-smbcharger.c:static int vf_adjust_n_samples = 3;
drivers/power/qpnp-smbcharger.c:static int vf_adjust_n_samples = 10;
drivers/power/qpnp-smbcharger.c:module_param(vf_adjust_n_samples, int, 0644);
drivers/power/qpnp-smbcharger.c:static int vf_adjust_max_delta_mv = 200;
drivers/power/qpnp-smbcharger.c:static int vf_adjust_max_delta_mv = 40;
drivers/power/qpnp-smbcharger.c:module_param(vf_adjust_max_delta_mv, int, 0644);
drivers/power/qpnp-smbcharger.c:static int vf_adjust_trim_steps_per_adjust = 3;
drivers/power/qpnp-smbcharger.c:static int vf_adjust_trim_steps_per_adjust = 1;
drivers/power/qpnp-smbcharger.c:module_param(vf_adjust_trim_steps_per_adjust, int, 0644);
drivers/power/qpnp-smbcharger.c: && i <= vf_adjust_trim_steps_per_adjust; i++) {
drivers/power/qpnp-smbcharger.c: if ((vbat_mv - chip->vfloat_mv) < -1 * vf_adjust_max_delta_mv) {
drivers/power/qpnp-smbcharger.c: if (chip->n_vbat_samples < vf_adjust_n_samples) {
drivers/power/qpnp-smbcharger.c: if (delta_vfloat_mv > vf_adjust_high_threshold
drivers/power/qpnp-smbcharger.c: || delta_vfloat_mv < -1 * vf_adjust_low_threshold) {

that's quite a difference to the suggest values of 55 for low (vs. 5) and 99 for high (vs. 7)

https://en.wikipedia.org/wiki/Float_voltage


I feel rather uneasy after having gone through all these files to adjust these settings,

perhaps anyone with some in-depth knowledge can say whether it's relatively safe or a red flag to change the values:

Code:
	pr_smb(PR_STATUS, "sample number = %d vbat_mv = %d ibat_ua = %d\n",
		chip->n_vbat_samples,
		vbat_mv,
		ibat_ua);

	chip->max_vbat_sample = max(chip->max_vbat_sample, vbat_mv);
	chip->n_vbat_samples += 1;
	if (chip->n_vbat_samples < vf_adjust_n_samples) {
		pr_smb(PR_STATUS, "Skip %d samples; max = %d\n",
			chip->n_vbat_samples, chip->max_vbat_sample);
		goto reschedule;
	}
	/* if max vbat > target vfloat, delta_vfloat_mv could be negative */
	delta_vfloat_mv = chip->vfloat_mv - chip->max_vbat_sample;
	pr_smb(PR_STATUS, "delta_vfloat_mv = %d, samples = %d, mvbat = %d\n",
		delta_vfloat_mv, chip->n_vbat_samples, chip->max_vbat_sample);
	/*
	 * enough valid samples has been collected, adjust trim codes
	 * based on maximum of collected vbat samples if necessary
	 */
	if (delta_vfloat_mv > vf_adjust_high_threshold
			|| delta_vfloat_mv < -1 * vf_adjust_low_threshold) {
		rc = smbchg_adjust_vfloat_mv_trim(chip, delta_vfloat_mv);
		if (rc) {
			pr_smb(PR_STATUS,
				"Stopping vfloat adj after trim adj rc = %d\n",
				 rc);
			goto stop;
		}
		chip->max_vbat_sample = 0;
		chip->n_vbat_samples = 0;
		goto reschedule;
#ifdef CONFIG_QPNP_SMBCHARGER_EXTENSION
	} else {
		pr_smb(PR_STATUS, "reschedule vfloat adj\n");
		chip->max_vbat_sample = 0;
		chip->n_vbat_samples = 0;
		goto reschedule;
#endif
 
Last edited:

zacharias.maladroit

Recognized Developer
SD810-fg-scripts.sh

Code:
#!/system/bin/sh

# kudos to Nama Bhalla, henryzhang317, nreuge on XDA


echo "setting 'debug_mask' to 1"
echo "1" >  /sys/module/qpnp_fg/parameters/debug_mask
echo " "
cat /sys/module/qpnp_fg/parameters/debug_mask
echo " "
echo "1 means 'debug_mask' enabled"

echo " "
echo "..."
echo " "

echo "setting 'sense_type' to 0"
echo "0" >  /sys/module/qpnp_fg/parameters/sense_type
echo " "
cat /sys/module/qpnp_fg/parameters/sense_type
echo " "
echo "0 means alternative 'sense resistor' successfully set"

echo " "
echo "..."
echo " "

echo "enabling setting 'first_est_dump', to 1"
echo "1" >  /sys/module/qpnp_fg/parameters/first_est_dump
echo " "
cat /sys/module/qpnp_fg/parameters/first_est_dump
echo " "
echo "1 means 'first_est_dump' set"

echo " "
echo "..."
echo " "

echo "done ..."


Launch SManager (Script Manager) with root rights,

then tap on the SU icon (yes, you need root twice - that equals doing su - in terminal )

after that it should launch


Unless you know what you are doing with the modifications of the charger - I'd keep to this and see whether that makes difference at all.


No permission changes needed
 
  • Like
Reactions: nreuge

nreuge

Senior Member
Apr 22, 2013
2,641
2,395
Saint-Nazaire
So you're dealing with one of the most essential parts of your phone (charger and [assumedly] how much the battery offers the system)

that's quite a difference to the suggest values of 55 for low (vs. 5) and 99 for high (vs. 7)

perhaps anyone with some in-depth knowledge can say whether it's relatively safe or a red flag to change the values:

Perhaps can you ask to @Naman Bhalla by mp if you are worried, these tweaks are from him...
Thanks for the script, it's well written, I'll update mine but keeping the smbcharger tweaks.

Good evening ! :)
 
  • Like
Reactions: zacharias.maladroit

nreuge

Senior Member
Apr 22, 2013
2,641
2,395
Saint-Nazaire
what to expect from them?

how much of an SOT improvement did you observe ?

I'm now convinced of the efficiency of these tweaks. I would say that the battery life is increased by at least 10-15% for a daily usage, maybe more. I have the impresion of having my old Z2 in my hands (in term of battery life).
It would be interesting to test all of these tweaks independently to quantify the gain for each of them. But I don't feel the courage to do it... :eek:
 
Last edited:
  • Like
Reactions: zacharias.maladroit

zacharias.maladroit

Recognized Developer
Perhaps can you ask to @Naman Bhalla by mp if you are worried, these tweaks are from him...
Thanks for the script, it's well written, I'll update mine but keeping the smbcharger tweaks.

Good evening ! :)

Thanks,

maybe adding some kind of feedback (output) ?

otherwise you don't know if it was applied successfully or not :)
 
  • Like
Reactions: nreuge

Funkmasterchilla

Senior Member
May 13, 2014
452
128
Lorient
Hi, do we have to set specific permissions regarding both the script files and the folder ? Also, I am currently using kernel adiutor, will it mess with your tweaks when applying settings after boot is done ?
Thx for your work !
 

Top Liked Posts

  • There are no posts matching your filters.
  • 35
    Some system tweaks specifically conceived for our SoC Snapdragon 810 can enhance the battery life of our Xperia Z5.

    Features:
    - Power Tweaks for S810 (no performance loss)
    - Various common performance / battery friendly system tweaks (no performance loss)
    - Tuned Interactive Governor Profiles for S810 (performance depends on the chosen profile)


    Requirements:
    - Z5 and Z3+/Z4 series
    - Root
    - Busybox app installed and activated
    - SManager app installed

    Installation:

    - If you were using a previous version of this mod, delete all the scripts

    - Download the attached Z5_Endurance_Tweaks_v5.zip (this is not a flashable zip)
    - Copy the folder Z5_Endurance_Tweaks from the zip and paste it to "/system/etc/"
    - Open SManager and navigate up to /system/etc/Z5_Endurance_Tweaks
    - Select the file "Power_tweaks.sh" and set it as su and boot, save the configuration, and run it
    - Select the file "Setprop_tweaks.sh" and set it as su and boot, save the configuration, and run it
    - Select the file "Gov_prof_Deadpool.sh" and set it as su and if you want to use it as your default profile governor, set it as boot, save the configuration,
    - Select the file "Gov_prof_DragonFly.sh" and set it as su and if you want to use it as your default profile governor, set it as boot, save the configuration,
    - Select the file "Gov_prof_Excalibur.sh" and set it as su and if you want to use it as your default profile governor, set it as boot, save the configuration,
    - Run your chosen default profile governor
    In the SManager dashboard, you should have something like this:

    29ewWRr.jpg


    Governor profiles indications:

    Performance: Stock > DragonFly > Excalibur > Deadpool
    Battery life: Deadpool > Excalibur > DragonFly > Stock

    Update (27/11): new profile attached - Xenon v2 especially made for Z5 by @koekoek91 and @_LLJY
    Potentially as battery friendly as Deadpool (?) but with great performance (as good as Dragonfly ? stock ? better ?), good for common users and for gamers... Pls give feedback!

    - Enjoy :D

    Notes:
    - Alternately, you can put your chosen scripts in your init.d folder if you have init.d support, but I strongly encourage to use SManager, it's much more reliable and versatile
    - Wait a little before to draw any opinions on this tweaks mod.
    - Feedbacks and suggestions for futures versions are strongly encouraged.

    Credits:
    @Naman Bhalla and @henryzhang317 for their Power Tweaks for SnapDragon 810 Devices
    @xperator for his tuned interactive governor profiles
    @zacharias.maladroit
    @_LLJY and @androidexpert35 for some tweaks

    Changelog:
    v5 (08/10)
    - Darkspice and Heimdall interactive governor profiles removed (outdated)
    - DeadPool, Excalibur and DragonFly interactive governor profiles added
    v4 (05/09):
    - Some tweaks added, some other removed
    v3 (05/03):
    - HEIMDALLv3 interactive governor profile slightly modified by me
    - DarkSpiceR7.5 interactive governor profile added, slightly modified by me
    - New tweaks added in Setprop_tweaks.sh
    v2 (27/02): All the scripts rewritten and various common performance / battery friendly system tweaks added (Setprop_tweaks.sh)
    v1 (24/02): Initial release
    5
    Update (27/02): v2

    Z5 Endurance Tweaks v2 (27/02) : all the scripts rewritten and various common performance / battery friendly system tweaks added (Setprop_tweaks.sh)
    4
    Leaving this here:

    https://github.com/zachariasmaladro...ntation/devicetree/bindings/power/qpnp-fg.txt
    QTI's QPNP PMIC Fuel Gauge Device

    https://github.com/zachariasmaladro...devicetree/bindings/power/qpnp-smbcharger.txt
    QPNP SMB Battery Charger


    https://github.com/zachariasmaladro..._Sun-Kernel_v6-stable/drivers/power/qpnp-fg.c


    So you're dealing with one of the most essential parts of your phone (charger and [assumedly] how much the battery offers the system)

    Any no one can give more details on this ... tough stuff



    drivers/power/qpnp-smbcharger.c:static int vf_adjust_low_threshold = 5;
    drivers/power/qpnp-smbcharger.c:module_param(vf_adjust_low_threshold, int, 0644);
    drivers/power/qpnp-smbcharger.c:static int vf_adjust_high_threshold = 7;
    drivers/power/qpnp-smbcharger.c:module_param(vf_adjust_high_threshold, int, 0644);
    drivers/power/qpnp-smbcharger.c:static int vf_adjust_n_samples = 3;
    drivers/power/qpnp-smbcharger.c:static int vf_adjust_n_samples = 10;
    drivers/power/qpnp-smbcharger.c:module_param(vf_adjust_n_samples, int, 0644);
    drivers/power/qpnp-smbcharger.c:static int vf_adjust_max_delta_mv = 200;
    drivers/power/qpnp-smbcharger.c:static int vf_adjust_max_delta_mv = 40;
    drivers/power/qpnp-smbcharger.c:module_param(vf_adjust_max_delta_mv, int, 0644);
    drivers/power/qpnp-smbcharger.c:static int vf_adjust_trim_steps_per_adjust = 3;
    drivers/power/qpnp-smbcharger.c:static int vf_adjust_trim_steps_per_adjust = 1;
    drivers/power/qpnp-smbcharger.c:module_param(vf_adjust_trim_steps_per_adjust, int, 0644);
    drivers/power/qpnp-smbcharger.c: && i <= vf_adjust_trim_steps_per_adjust; i++) {
    drivers/power/qpnp-smbcharger.c: if ((vbat_mv - chip->vfloat_mv) < -1 * vf_adjust_max_delta_mv) {
    drivers/power/qpnp-smbcharger.c: if (chip->n_vbat_samples < vf_adjust_n_samples) {
    drivers/power/qpnp-smbcharger.c: if (delta_vfloat_mv > vf_adjust_high_threshold
    drivers/power/qpnp-smbcharger.c: || delta_vfloat_mv < -1 * vf_adjust_low_threshold) {

    that's quite a difference to the suggest values of 55 for low (vs. 5) and 99 for high (vs. 7)

    https://en.wikipedia.org/wiki/Float_voltage


    I feel rather uneasy after having gone through all these files to adjust these settings,

    perhaps anyone with some in-depth knowledge can say whether it's relatively safe or a red flag to change the values:

    Code:
    	pr_smb(PR_STATUS, "sample number = %d vbat_mv = %d ibat_ua = %d\n",
    		chip->n_vbat_samples,
    		vbat_mv,
    		ibat_ua);
    
    	chip->max_vbat_sample = max(chip->max_vbat_sample, vbat_mv);
    	chip->n_vbat_samples += 1;
    	if (chip->n_vbat_samples < vf_adjust_n_samples) {
    		pr_smb(PR_STATUS, "Skip %d samples; max = %d\n",
    			chip->n_vbat_samples, chip->max_vbat_sample);
    		goto reschedule;
    	}
    	/* if max vbat > target vfloat, delta_vfloat_mv could be negative */
    	delta_vfloat_mv = chip->vfloat_mv - chip->max_vbat_sample;
    	pr_smb(PR_STATUS, "delta_vfloat_mv = %d, samples = %d, mvbat = %d\n",
    		delta_vfloat_mv, chip->n_vbat_samples, chip->max_vbat_sample);
    	/*
    	 * enough valid samples has been collected, adjust trim codes
    	 * based on maximum of collected vbat samples if necessary
    	 */
    	if (delta_vfloat_mv > vf_adjust_high_threshold
    			|| delta_vfloat_mv < -1 * vf_adjust_low_threshold) {
    		rc = smbchg_adjust_vfloat_mv_trim(chip, delta_vfloat_mv);
    		if (rc) {
    			pr_smb(PR_STATUS,
    				"Stopping vfloat adj after trim adj rc = %d\n",
    				 rc);
    			goto stop;
    		}
    		chip->max_vbat_sample = 0;
    		chip->n_vbat_samples = 0;
    		goto reschedule;
    #ifdef CONFIG_QPNP_SMBCHARGER_EXTENSION
    	} else {
    		pr_smb(PR_STATUS, "reschedule vfloat adj\n");
    		chip->max_vbat_sample = 0;
    		chip->n_vbat_samples = 0;
    		goto reschedule;
    #endif
    3
    Thanks for patch – it really improves battery life for Z5 Premium and makes it on the same level as Z3.
    3
    I'm using this on my z3+. Works great phone seems more snappier

    Thanks, good to know :)