[Samsung Galaxy S 5 Unified Development] Boatshow:
Changelog:

2021-06-06

-Merge to 54ffccbf053b5b6ca4f6e45094b942fab92a25fc

Disclaimer: I have no idea what I'm doing, I just copy pasted some stuff together and compiled the kernel. This kernel was only momentarily tested on an SM-G900T (klte). If there's a compatibility problem you will probably boot loop until you fix it. Undervolting can cause issues. You have been warned!

This is the LOS 18.1 kernel from https://github.com/LineageOS/android_kernel_samsung_msm8974/ with the KTOONSEZ undervolting control mods from https://github.com/alaskalinuxuser/...mmit/37664e51977ccd27563458526463f53c6be0490a

The gcc version is a 4.9 I got from this GitHub page:

https://github.com/Duhjoker/arm-linux-androideabi-4.9

Intro:

This kernel allows tweaking CPU voltages. We're interested in undervolting the CPU so it uses less voltage to operate. The extent you can undervolt your CPU is based on luck. While your CPU will run more efficiently with an undervolt, real-world benefits are sometimes hard to tell. For example, your phone may compensate for cooler operation by running at a higher speed more often. Any battery life benefits to undervolting this one part of the phone are ambiguous, it's really hard to test.

Prerequisites:

You will need root on your phone! If you don't have root you can get it by installing Magisk. First install Magisk's apk file in Android. Then rename the apk so it has a .zip file extension and leave it in your phone's storage.

Releases · topjohnwu/Magisk

The Magic Mask for Android. Contribute to topjohnwu/Magisk development by creating an account on GitHub.

github.com

Instructions:

0. Keep a copy of Magisk's .zip on your phone!

1. Download the latest *boot.img and place it in your phone's storage

2. Boot to TWRP recovery or the recovery you use

3. Tap Install -> Tap "Install Image" to toggle the button

4. Select boot.img and FLASH TO YOUR BOOT PARTITION

4a. If you use Magisk it's broken now. Tap "Install Zip" to toggle the button and flash Magisk's zip

5. Reboot

6. Install SmartPack Kernel Manager OR Kernel Adiutor and grant it root privileges. You may now tweak your CPU voltage in the app. Once you are happy with your settings use the "Apply on Boot" to make the settings permanent.

https://f-droid.org/en/packages/com.smartpack.kernelmanager/

https://f-droid.org/en/packages/com.nhellfire.kerneladiutor/

Note: The kernel does not persist. You will need to reinstall it after every LOS update.

(Not) Optional: Consider making a TWRP backup of your phone. Unstable undervolting can result in data loss.

Help, I'm boot looping/can't boot because of unstable undervolt:

Download your phone's particular LineageOS zip from https://download.lineageos.org/ and unzip it. Put the boot.img file on your phone and flash it to the BOOT partition in recovery.

Undervolting guide:

Not all two phones are the same. Look at your stock voltages or old forum posts for reference. The S5's SoC is the MSM8974PRO/MSM8974AC, marketed as the Snapdragon 801. Also see the binning info at the bottom of this guide to learn your phone's binning.

Open SmartPack and go to CPU Voltage in the menu. It will display a big list of CPU clock speeds and voltages. These are your stock voltages. Your goal is to lower them some amount without your phone crashing. On the top part of the app you can scroll to "Global Offset" and enter one number to lower all the voltages at once.

I recommend trying a -30 mV or -40 mV global offset first, it seems like most phones can handle this. After you set your undervolt you should test for stability before making it permanent. Here are some ideas:

-Use your phone as you normally would.

-Keep playing videos on your phone

-Try the stress test in the bottom of this guide

Do not daily drive your phone for work until you're reasonably sure your undervolt is stable. You don't want it to crash when doing something important.

Once you have a good global offset you can start tweaking individual CPU states to lower voltages even more. This can get really annoying since there are so many. If you want to fine-tune I recommend only giving special attention to the top speed (2457), the middle speeds (1574 in particular, but include everything up to 1267 if you have to), and the lowest speed (300.)

The average phone tends to spend the most time in those states so focusing on those will help save your sanity.

To set your undervolt permanently enable "Apply on Boot" and SmartPack will set the values when your phone starts.

Spotting an unstable undervolt:

If one or more CPU states are unstable your phone will suddenly hang, hard reboot, fast reboot or other anomalies. You will probably also see CPU problems in the logs. Do "su; dmesg" in a Terminal or "su;logcat" to see. The cure for a bad undervolt is not undervolting so much. It can be hard to tell which CPU states are unstable unfortunately, you may have to adjust all of them to be sure,

Tips:

-Undervolts can be hard to test for stability, so try to leave some overhead if you don't have all day. SmartPack/Kernel Adiutor lets you set a global offset if you only want a small UV!

-You can set unusually low voltages for 300 MHz. Its stock voltage is about 750-800 mV but it will usually work on 650 mV and go as low as 600 mV if you're lucky.

-Low freqs are usually better at getting undervolted than the top freqs

-Not all cores will run at the same freqs/voltages. Disabling most of your cores is a good way to prevent your phone from heating up during stress tests but may lead to instability when you reactivate all of your cores.

-Your phone's battery draining may spontaneously cause your undervolt to become unstable. Unfortunately you just have to make the UV less aggressive if this happens.

-Try not switch the governor. To change CPU behavior go to Settings > Battery >Battery Saver and Performance > Performance Profile and toggle the slider as you see fit.

I recommend using Balanced and switching to Quick when you need your phone to be faster.

Performance is very energy inefficient. It prevents all cores from parking and tries to peg at least some of them to top speed. One core performance can be better than quick but multi-core makes it very easy for the phone to throttle.

LOS uses Qualcomm's MPDecision hotplugger. Switching governors causes glitches MPDecision and prevent CPU cores from parking. If you really want to try out governor tweaks, you should disable MPDecision in SmartPack first. Disabling MPDecision will incur a battery life penalty since your CPU will no longer park.

Synthetic stress test:

Install Termux and run this one-liner to stress one core:

while true; do openssl speed -evp aes-256-gcm; sleep 15s; done

For 4 cores:

while true; do openssl speed -multi 4 -evp aes-256-gcm; sleep 15s; done

You can also use this test to compare performance or to observe thermal throttling. OpenSSL will return a performance score after each run.

Sample stock/undervolt values from my speed3-pvs9-bin-v1 SM-G900T:

View attachment 5302815View attachment 5302817

Very minor LOS power saving tweaks that don't help very much but they're funny:

-Search "Backlight" in the settings and turn off the backlight for the Menu and Back keys.

-The battery/notification LED can be adjusted down to about 7% brightness

-LOS has several settings for turning off haptic feedback/vibrations. I turned them off for the touch keyboard and the Menu/Back keys.

SoC Binning Information:

Your phone's SoC is tested for quality and assigned a PVS number at the factory. For S5, it ranges from PVS0 (low quality) to PVS15 (high quality). Higher quality have lower stock voltages. Check by running these in a terminal:

su
cat /sys/module/clock_krait_8974/parameters/table_name

You can compare the bins here