Battery Voltage Reduction
When using an old smartphone as a permanent server with power always connected, keeping the battery voltage at maximum is not desirable.
This guide shows how to change the maximum voltage of the battery. This involves decompiling the device tree, finding and changing the maximum voltage, and then recompiling.
That sounds very intimidating, but it is very simple and is done directly on the device running PostmarketOS
The guide is based on an Xiaomi A1 tissot, but I hope can be adapted for other devices.
Battery Control
Different devices have different PMICs (Power Management Integrated Circuits) that have different firmware and control parameters.
The power supply parameters are exposed in folders under /sys/class/power_supply/
To find the voltage settings:
ls -l /sys/class/power_supply/*/voltage*
On a Xiaomi A1 (tissot), this gives:
-r--r--r-- 1 root root 4096 Jan 22 12:42 /sys/class/power_supply/qcom-battery/voltage_max_design
-r--r--r-- 1 root root 4096 Jan 22 12:42 /sys/class/power_supply/qcom-battery/voltage_min_design
-r--r--r-- 1 root root 4096 Jan 22 12:42 /sys/class/power_supply/qcom-battery/voltage_nowIf you are very lucky, voltage_max_design maybe writable and the value can be changed directly. If not, the value can be changed by modifying the device tree. The following procedure is for the 'tissot' device, but should serve as a guide for other devices.
Procedure
Install Device Tree Compiler
The device tree compiler (dtc) is needed to convert the binary device tree blob (.dtb) into human-readable text (.dts) for editing, and then compile it back.
# sudo apk add dtc
Backup Original Device Tree
Create a backup before modifying system files to allow restoration of the original configuration if needed.
Replace 'tissot' with the appropriate device name from /boot/*.dtb
# sudo cp /boot/msm8953-xiaomi-tissot.dtb /boot/msm8953-xiaomi-tissot.dtb.backup
Decompile Device Tree
Convert the binary device tree blob into a text file for editing:
$ dtc -I dtb -O dts /boot/msm8953-xiaomi-tissot.dtb -o ~/tissot.dts
| Warnings during decompilation are normal and can be ignored. These are usually about minor formatting issues that don't affect functionality. |
Find Current Battery Voltage Setting
Search for the line containing the voltage setting and note its line number:
$ grep -n "voltage-max-design" ~/tissot.dts
This will output something like:
3959: voltage-max-design-microvolt = <0x432380>;The number before the colon (3959) is the line number needed in the next step.
Modify the Voltage
Use sed to change from 4.4V (0x432380) to 3.8V (0x39f880).
IMPORTANT: Adjust the line number (3959) based on the grep output from the previous step:
sed -i '3959s/0x432380/0x39f880/' ~/tissot.dts
Converting voltage to hex: The voltage is specified in microvolts (μV) and must be in hexadecimal format. To convert: multiply the target voltage by 1,000,000 (e.g., 3.8V × 1,000,000 = 3,800,000 μV), then convert to hexadecimal and prefix with 0x.
Example conversion command: printf "0x%x\n" 3800000
0x39f880 |
Verify the Change
Check that the modification was applied correctly:
grep -n -A 2 -B 2 "voltage-max-design-microvolt" ~/tissot.dts
The output should show the new hex value (e.g., 0x39f880) instead of the original 0x432380.
Recompile Device Tree
Convert the modified text file back into a binary device tree blob:
dtc -I dts -O dtb ~/tissot.dts -o ~/tissot-modified.dtb
| Warnings during compilation are normal and can be ignored, similar to the decompilation step. |
Install Modified Device Tree
Replace the original device tree file with the modified version:
sudo cp ~/tissot-modified.dtb /boot/msm8953-xiaomi-tissot.dtb
Reboot
Apply all changes by rebooting the system:
sudo reboot
Verify the Change
After reboot, wait approximately 15 seconds for the startup script to complete, then verify:
cat /sys/class/power_supply/qcom-battery/voltage_max_design
cat /sys/class/power_supply/qcom-battery/voltage_now
cat /sys/class/power_supply/qcom-smbchg-usb/status
cat /sys/class/power_supply/qcom-battery/status
Expected results:
voltage_max_design: Should show 3800000 (3.8V) instead of 4400000 (4.4V)voltage_now: Current voltage in microvolts (will vary based on charge level)status: Should show "Charging" if below 3.8V, or "Not charging" if at the voltage limit
Reverting Changes
To restore the original settings, restore the backup device tree:
sudo cp /boot/msm8953-xiaomi-tissot.dtb.backup /boot/msm8953-xiaomi-tissot.dtb
sudo reboot
Troubleshooting
Problem: Continually discharges even when voltage is well below design_max.
Solution: This 'sometime' happens after a reboot. I don't know why this happens. Simply unplug and replug the USB cable resets the charging. If the 'server' is inaccessible, run the following commands to force USB disconnect and reconnect:
$ cd /sys/class/power_supply/qcom-smbchg-usb
$ echo 0 | sudo tee online > /dev/null
$ sleep 2
$ echo 1 | sudo tee online > /dev/null
Problem: Voltage never reaches the new maximum
Solution: This is normal if a low voltage is set; the battery may stabilize below the maximum during normal discharge.
Problem: System won't boot after changes ( Never happened to me...)
Solution: Boot into recovery mode, I think battery will charge to origional value, then restore the backup device tree file from /boot/*.dtb.backup.