Adjust the charging speed to your likings

Search This thread

Mumxek

Member
Jan 1, 2021
22
3
Did you experinced periodic switching from qc to slow? Unfortunately im unable force go for higher voltages like whyred, so its 6v/2.5a or v/0.5-1a every few seconds.

(the usb doesnt last much long at 2.5a , and thermal are intentionally set to extreme)
 

OnePlusUser01

Member
Aug 22, 2021
18
0
OnePlus 9 Pro
Hey guys,

this thread is supposed to show you exactly, how you can change the charging voltage and charging current of the Xiaomi Redmi 5 Plus (vince). This could very well also work with other phones, as I first heard of them in a Magisk module, NOT related to this phone. This is my first thread on xda and I'm not a native speaker, so please excuse mistakes :)

So, there are two files associated with the kernel, that control voltage and current. For most kernels for vince, these files exist (DA, Zucc, Genom, and maybe also the others... doesn't work on Kirks Kernel) at the moment. Of course I don't know if these files still exist when a new android version is brought to this phone ^^

So let's start. The two files I mentioned are located here:
Current: /sys/devices/platform/soc/200f000.qcom,spmi/spmi-0/spmi0-02/200f000.qcom,spmi:qcom,[email protected]:qcom,qpnp-smbcharger/power_supply/battery/constant_charge_current_max
Voltage: /sys/devices/platform/soc/200f000.qcom,spmi/spmi-0/spmi0-02/200f000.qcom,spmi:qcom,[email protected]:qcom,qpnp-smbcharger/power_supply/battery/voltage_max


For Linux 3.18 Kernels:
Current: /sys/devices/soc/qpnp-smbcharger-18/power_supply/battery/constant_charge_current_max (stock value: 2000000 = 2000mA)
Voltage: /sys/devices/soc/qpnp-smbcharger-18/power_supply/battery/voltage_max (stock value: 4380 = 4,38V)

The values in constant_charge_current_max are measured in mA/1000. So that means, if you want to set 2000mA, you have to type 2000000 in this file.
The values in voltage_max are in mV, so if you want to set for example 4,2V as a maximum, you would have to type 4200 in this file.

MY RECOMMENDATIONS:
To set good values on these interfaces, we have to understand them correctly. Let's start with the voltage. The charging voltage (in order to charge) always has to be higher than the voltage the battery has. The battery of this specific phone ranges from 4,3V to 3,7V (4,3V on 100%, gradually going to 3,7V when reaching 0% (not sure about the 3,7V, correct me if you can :p )). I wouldn't change it. The voltage needs to be 4380 mA if you want you phone to charge until it's full. Even if you don't want that, I'd take another way to stop your phone from charging any further (there are good magisk modules that do exactly that, even with more features).

Now let's speak about the charging current, the holy grail of charging haha :laugh: Basically, if you want faster charging, go with values higher than 2000mA. I'd take 2500mA max, as the battery can get very hot. If you want your phone to stay cool while charging, which causes the battery to last way longer (https://www.sciencedirect.com/science/article/abs/pii/S0378775314004352), I'd recommend finding a charging current which keeps your temperature at about 25°C, which is the optimal temperature (see the reference, it's not a long text). For me, this is 1850mA, but if you live somewhere where it's very cold or hot, this can vary significantly. In the end, this is personal preference and should depend on how long you want to keep your phone, and how important charging speed is to you.
As for all kernel or /sys values, these will be reset on every reboot, so you'll have to find a way to set in on every boot. I tried creating a init.d file, but even though I set the permissions of the init.d file etc, it failed every time. So personally, I use Custom Controls in Kernel Adiutor, but I think EXKM has something similar. Of course I can only show the way with Kernel Adiutor and FKM in the following, as I don't have EXKM.

How to set these values with Kernel Adiutor:

For this, you have to enable the Custom Controls in Kernel Adiutor settings, if you disabled it previously.

Let's start with the current:
Go in the Custom Controls menu, click on the + and then "create". For this type of value, we need a seekbar. The title is irrelevant really, I'd choose "Charging Current". As a min, choose 0, and as max, choose the exact same value you want to use (if you're still unsure, just take 2000000/2500000, depending on if you want to increase it or not). I do this, because it is very hard to get the seekbar to an exact value (for example 1850000), because the numbers are so high. So i just set the max to what I want, and just max out the seekbar.
In "Progress", you have to put in exactly this:

For 3.18 kernels:

#!/system/bin/sh
head /sys/devices/soc/qpnp-smbcharger-18/power_supply/battery/constant_charge_current_max

Press test to confirm you typed it in correctly. Otherwise you also won't be able to set this control :)

in "Applying", put in exactly this:

#!/system/bin/sh
progress=$1
echo $progress > /sys/devices/soc/qpnp-smbcharger-18/power_supply/battery/constant_charge_current_max

Don't forget to delete the # before the second line (progress=$1), otherwise this will set nothing.

For 4.9 kernels:

#!/system/bin/sh
head /sys/devices/platform/soc/200f000.qcom,spmi/spmi-0/spmi0-02/200f000.qcom,spmi:qcom,[email protected]:qcom,qpnp-smbcharger/power_supply/battery/constant_charge_current_max

Press test to confirm you typed it in correctly. Otherwise you also won't be able to set this control :)

in "Applying", put in exactly this:

#!/system/bin/sh
progress=$1
echo $progress > /sys/devices/platform/soc/200f000.qcom,spmi/spmi-0/spmi0-02/200f000.qcom,spmi:qcom,[email protected]:qcom,qpnp-smbcharger/power_supply/battery/constant_charge_current_max

Don't forget to delete the # before the second line (progress=$1), otherwise this will set nothing.

That's it, you can use this control now ^^ But if you want this to set on every boot, after setting it up, you have to click on the 3 dots of this control and check "On boot".

Basically, for the voltage, I'd take 0 as minimum, and 4400 as maximum, and change the file location to the voltage (on progress and applying), and the rest is the same!
So, that's it! It's possible that someone will write a magisk module for that some day, but until then, I think this is a very easy solution. Have fun with it!

How to set these values with Franco Kernel Manager:
These screenshots are provided by @Niamotullah
CRL7VAW.jpg

fRlQ5yH.jpg

sNpiAUi.jpg

7lOjpVO.jpg
what may be the right folder in lineage os ?
I looked at any folder but looks like my folder structure is different than yours.
can you check this thread and eventually reply there?
 

Doomkopf

Senior Member
May 14, 2016
267
106
what may be the right folder in lineage os ?
I looked at any folder but looks like my folder structure is different than yours.
can you check this thread and eventually reply there?
Hey man, try navigating to /sys/class/power_supply/battery with a root explorer. On my current device its not there anymore, so I guess Android updates could have moved it somewhere else :( If that path ends after /sys/class/power_supply, you could try installing the magisk module "Advanced Charging Controller". When you look into its config after its installed (in data/adb/vr25/acc-data/config.txt), you can look at which charging controller it automatically detected and use that one.
 
Last edited:

OnePlusUser01

Member
Aug 22, 2021
18
0
OnePlus 9 Pro
Hey man, try navigating to /sys/class/power_supply/battery with a root explorer. On my current device its not there anymore, so I guess Android updates could have moved it somewhere else :( If that path ends after /sys/class/power_supply, you could try installing the magisk module "Advanced Charging Controller". When you look into its config after its installed (in data/adb/vr25/acc-data/config.txt), you can look at which charging controller it automatically detected and use that one.
I installed the module, I runned the command: acc -s mcc=1000000
this should set max charging current to 1A, I restarted the daemon via app and the limit doens't work...
any idea?
 

Doomkopf

Senior Member
May 14, 2016
267
106
I installed the module, I runned the command: acc -s mcc=1000000
this should set max charging current to 1A, I restarted the daemon via app and the limit doens't work...
any idea?
For me the module doesnt work either. But try grabbing the path like I advised in the message before, in that path you should find kernel files for charging current and voltage (files should be called constant_charge_current_max and voltage_max). But you can only get that path from the acc config file while your phone is charging and acc daemon is running.
If you manage to get that path, you can just edit the file values with a text editor (or automate at every boot with a Kernel Manager or a bootscript)
 

OnePlusUser01

Member
Aug 22, 2021
18
0
OnePlus 9 Pro
For me the module doesnt work either. But try grabbing the path like I advised in the message before, in that path you should find kernel files for charging current and voltage (files should be called constant_charge_current_max and voltage_max). But you can only get that path from the acc config file while your phone is charging and acc daemon is running.
If you manage to get that path, you can just edit the file values with a text editor (or automate at every boot with a Kernel Manager or a bootscript)
I attached to this message the config.txt file.
path /sys/class/power_supply/battery exists for real, but I still don't know to remove the 4,88A limit.
in the file you will find a commented line (with //), line 11, read it. read also line 260
let me know how can I proceed.

conf file download link: https://drive.google.com/file/d/1HxC6MyziGLhifYuYWpCx4Ae4ZIRCVSVv/view?usp=sharing

I did a short video of ACCA app... showing different switches, one of them contains the magic number 4880000, the max charging current to remove. maybe it's everything already obvious to you but I have no idea what should I edit/run to achieve the result.
 

Attachments

  • 4554.mp4
    426.6 KB · Views: 0

Doomkopf

Senior Member
May 14, 2016
267
106
I attached to this message the config.txt file.
path /sys/class/power_supply/battery exists for real, but I still don't know to remove the 4,88A limit.
in the file you will find a commented line (with //), line 11, read it. read also line 260
let me know how can I proceed.

conf file download link: https://drive.google.com/file/d/1HxC6MyziGLhifYuYWpCx4Ae4ZIRCVSVv/view?usp=sharing

I did a short video of ACCA app... showing different switches, one of them contains the magic number 4880000, the max charging current to remove. maybe it's everything already obvious to you but I have no idea what should I edit/run to achieve the result.
The magic sauce should be on line 8, charging switch... but thats empty, did you grab that conf file while you were charging?
Is the last thing on that path (battery) a folder or a file? If its a file, its a dead end.
 

OnePlusUser01

Member
Aug 22, 2021
18
0
OnePlus 9 Pro
I
The magic sauce should be on line 8, charging switch... but thats empty, did you grab that conf file while you were charging?
Is the last thing on that path (battery) a folder or a file? If its a file, its a dead end.
I've never changed the line 8, I just noticed that sometime when I edit line 11:
maxChargingCurrent=(1000000),
I managed to make it work at 1A, but .... quite not sure about the result. I changed the value to 5200000 (5.2A)
in order to see wheter I'll be able to go over 4.8A, but we have no guarantee.
I would start thinking what to do if it doesn't work, yes it's very likely that the charging switch is limiting it to 4.8A no matter the content of maxChargingCurrent (line 11).
the switch is currently set on "auto" via the ACC app. this is a screenshot of what is available. you'll see one called usb/currentmax 4.8A.... maybe we should just change switch
 

Attachments

  • 4608.png
    4608.png
    167.8 KB · Views: 5

OnePlusUser01

Member
Aug 22, 2021
18
0
OnePlus 9 Pro
The magic sauce should be on line 8, charging switch... but thats empty, did you grab that conf file while you were charging?
Is the last thing on that path (battery) a folder or a file? If its a file, its a dead end.
I confirm, it won't charge over 4.8A even if set anything higher than 4800000 on the config file. so it's a matter of the switch, which may have this intrinsic limit
 

Mumxek

Member
Jan 1, 2021
22
3
I reached max 2500, but no way increase the usb voltage erequest. Whyred takes up to 8V, so less current. I think its in the charger or hvdcp_opti binary. Interesting is different recoveries behave different as the BL. Thre pulsing i assume to HW overheat of the PMIC. Well charging with 1C (4A for 4Ah, usually less, most batts are fake. I tested some phones use just 50-70% from 4000+mAh from zero. The algorithm uses low current until some charge, and above. How the thermal files logic works is unknown to me). BTW A2 lite/daisy or redmi6 pro sakura have the identic ircuitry, yet the daisy is impossible convince to go into HVDCP mode. Asking kernel developers lead to the answer its impossible, which i told WHY if the HW is identical and this lead to a ban. Theres lack of informatio and most on telegram :(. I think some unoffic. roms use blobsb from various hw identical/similar devices...
OT: Vincehas a rgb driver, just replace the led, and there was my end, because i dont know where o change sources or dts... Manually sending i2cm commands works.
OT2: Aliepress batteries have usually 3.5-3.7Ah, And are prettty forgiving, I charged them 2-4A , discharged 1C - unrealistic, but with lower currents the capacity was like i wrote. It pays off test them few cycles and they even not heat up much. Most does the PMIC , Also the subboard USB with loose coontacts gets heat damaged. Thats why im for higher voltage, the PMIC should take 9V...

Battery goes up to 45C, thermal is 50 but the PMIC throttles at above 70. The cheap batteries and fast charging are acceptable. Usually i get about 15W
 

OnePlusUser01

Member
Aug 22, 2021
18
0
OnePlus 9 Pro
I reached max 2500, but no way increase the usb voltage erequest. Whyred takes up to 8V, so less current. I think its in the charger or hvdcp_opti binary. Interesting is different recoveries behave different as the BL. Thre pulsing i assume to HW overheat of the PMIC. Well charging with 1C (4A for 4Ah, usually less, most batts are fake. I tested some phones use just 50-70% from 4000+mAh from zero. The algorithm uses low current until some charge, and above. How the thermal files logic works is unknown to me). BTW A2 lite/daisy or redmi6 pro sakura have the identic ircuitry, yet the daisy is impossible convince to go into HVDCP mode. Asking kernel developers lead to the answer its impossible, which i told WHY if the HW is identical and this lead to a ban. Theres lack of informatio and most on telegram :(. I think some unoffic. roms use blobsb from various hw identical/similar devices...
OT: Vincehas a rgb driver, just replace the led, and there was my end, because i dont know where o change sources or dts... Manually sending i2cm commands works.
OT2: Aliepress batteries have usually 3.5-3.7Ah, And are prettty forgiving, I charged them 2-4A , discharged 1C - unrealistic, but with lower currents the capacity was like i wrote. It pays off test them few cycles and they even not heat up much. Most does the PMIC , Also the subboard USB with loose coontacts gets heat damaged. Thats why im for higher voltage, the PMIC should take 9V...

Battery goes up to 45C, thermal is 50 but the PMIC throttles at above 70. The cheap batteries and fast charging are acceptable. Usually i get about 1
 

OnePlusUser01

Member
Aug 22, 2021
18
0
OnePlus 9 Pro
at the end I discovered it is normal for my oneplus 9 pro to never reach 65w. it peaks at 55-57w between 0-10% according to the website android authority. then it stays at 44w (the famously mentioned 4.8a 9v) up until 40ish%.

this website is the only one complaining how also xiaomi, oppo etc never reache the labeled power.
 

Mumxek

Member
Jan 1, 2021
22
3
at the end I discovered it is normal for my oneplus 9 pro to never reach 65w. it peaks at 55-57w between 0-10% according to the website android authority. then it stays at 44w (the famously mentioned 4.8a 9v) up until 40ish%.

this website is the only one complaining how also xiaomi, oppo etc never reache the labeled power.
With such poweras the battery /which capacity/ probably doesnt last much. Usually the healthy optimum is 1-1.5C. Different chemistry take more, but have lower capacity per weight and volume. The heat from often poor thermal design can cause issues. Just a overcharged 50% xiaomi old battery 4Ah made a bit smoke after puncturing. An old 10 years nikia 3310 li-ion charged 5 years ago made a nice fireball. Definitely the chemistry changed to more safe, yet Wheres the point where heat production surpasses charge is unknown. Pulling 2.5A thouch the flimsy flex is probably worst problem

What are your temps during charging? Device HW info shows all TZs when rooted. Improvin thermal conductivity help a lot in case of xiaomis.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 5
    Hey guys,

    this thread is supposed to show you exactly, how you can change the charging voltage and charging current of the Xiaomi Redmi 5 Plus (vince). This could very well also work with other phones, as I first heard of them in a Magisk module, NOT related to this phone. This is my first thread on xda and I'm not a native speaker, so please excuse mistakes :)

    So, there are two files associated with the kernel, that control voltage and current. For most kernels for vince, these files exist (DA, Zucc, Genom, and maybe also the others... doesn't work on Kirks Kernel) at the moment. Of course I don't know if these files still exist when a new android version is brought to this phone ^^

    So let's start. The two files I mentioned are located here:
    Current: /sys/devices/platform/soc/200f000.qcom,spmi/spmi-0/spmi0-02/200f000.qcom,spmi:qcom,[email protected]:qcom,qpnp-smbcharger/power_supply/battery/constant_charge_current_max
    Voltage: /sys/devices/platform/soc/200f000.qcom,spmi/spmi-0/spmi0-02/200f000.qcom,spmi:qcom,[email protected]:qcom,qpnp-smbcharger/power_supply/battery/voltage_max

    For Linux 3.18 Kernels:
    Current: /sys/devices/soc/qpnp-smbcharger-18/power_supply/battery/constant_charge_current_max (stock value: 2000000 = 2000mA)
    Voltage: /sys/devices/soc/qpnp-smbcharger-18/power_supply/battery/voltage_max (stock value: 4380 = 4,38V)

    The values in constant_charge_current_max are measured in mA/1000. So that means, if you want to set 2000mA, you have to type 2000000 in this file.
    The values in voltage_max are in mV, so if you want to set for example 4,2V as a maximum, you would have to type 4200 in this file.

    MY RECOMMENDATIONS:
    To set good values on these interfaces, we have to understand them correctly. Let's start with the voltage. The charging voltage (in order to charge) always has to be higher than the voltage the battery has. The battery of this specific phone ranges from 4,3V to 3,7V (4,3V on 100%, gradually going to 3,7V when reaching 0% (not sure about the 3,7V, correct me if you can :p )). I wouldn't change it. The voltage needs to be 4380 mA if you want you phone to charge until it's full. Even if you don't want that, I'd take another way to stop your phone from charging any further (there are good magisk modules that do exactly that, even with more features).

    Now let's speak about the charging current, the holy grail of charging haha :laugh: Basically, if you want faster charging, go with values higher than 2000mA. I'd take 2500mA max, as the battery can get very hot. If you want your phone to stay cool while charging, which causes the battery to last way longer (https://www.sciencedirect.com/science/article/abs/pii/S0378775314004352), I'd recommend finding a charging current which keeps your temperature at about 25°C, which is the optimal temperature (see the reference, it's not a long text). For me, this is 1850mA, but if you live somewhere where it's very cold or hot, this can vary significantly. In the end, this is personal preference and should depend on how long you want to keep your phone, and how important charging speed is to you.
    As for all kernel or /sys values, these will be reset on every reboot, so you'll have to find a way to set in on every boot. I tried creating a init.d file, but even though I set the permissions of the init.d file etc, it failed every time. So personally, I use Custom Controls in Kernel Adiutor, but I think EXKM has something similar. Of course I can only show the way with Kernel Adiutor and FKM in the following, as I don't have EXKM.

    How to set these values with Kernel Adiutor:

    For this, you have to enable the Custom Controls in Kernel Adiutor settings, if you disabled it previously.

    Let's start with the current:
    Go in the Custom Controls menu, click on the + and then "create". For this type of value, we need a seekbar. The title is irrelevant really, I'd choose "Charging Current". As a min, choose 0, and as max, choose the exact same value you want to use (if you're still unsure, just take 2000000/2500000, depending on if you want to increase it or not). I do this, because it is very hard to get the seekbar to an exact value (for example 1850000), because the numbers are so high. So i just set the max to what I want, and just max out the seekbar.
    In "Progress", you have to put in exactly this:

    For 3.18 kernels:

    #!/system/bin/sh
    head /sys/devices/soc/qpnp-smbcharger-18/power_supply/battery/constant_charge_current_max

    Press test to confirm you typed it in correctly. Otherwise you also won't be able to set this control :)

    in "Applying", put in exactly this:

    #!/system/bin/sh
    progress=$1
    echo $progress > /sys/devices/soc/qpnp-smbcharger-18/power_supply/battery/constant_charge_current_max

    Don't forget to delete the # before the second line (progress=$1), otherwise this will set nothing.

    For 4.9 kernels:

    #!/system/bin/sh
    head /sys/devices/platform/soc/200f000.qcom,spmi/spmi-0/spmi0-02/200f000.qcom,spmi:qcom,[email protected]:qcom,qpnp-smbcharger/power_supply/battery/constant_charge_current_max

    Press test to confirm you typed it in correctly. Otherwise you also won't be able to set this control :)

    in "Applying", put in exactly this:

    #!/system/bin/sh
    progress=$1
    echo $progress > /sys/devices/platform/soc/200f000.qcom,spmi/spmi-0/spmi0-02/200f000.qcom,spmi:qcom,[email protected]:qcom,qpnp-smbcharger/power_supply/battery/constant_charge_current_max

    Don't forget to delete the # before the second line (progress=$1), otherwise this will set nothing.

    That's it, you can use this control now ^^ But if you want this to set on every boot, after setting it up, you have to click on the 3 dots of this control and check "On boot".

    Basically, for the voltage, I'd take 0 as minimum, and 4400 as maximum, and change the file location to the voltage (on progress and applying), and the rest is the same!
    So, that's it! It's possible that someone will write a magisk module for that some day, but until then, I think this is a very easy solution. Have fun with it!

    How to set these values with Franco Kernel Manager:
    These screenshots are provided by @Niamotullah
    CRL7VAW.jpg

    fRlQ5yH.jpg

    sNpiAUi.jpg

    7lOjpVO.jpg
    2
    As you guys may have noticed, Linux 4.9 got ported to our device. It broke my setup (Kernel Adiutor said it can't get an integer value out of the file), but it still works! The symlinks got changed, so these are the new paths to the files:

    /sys/devices/platform/soc/200f000.qcom,spmi/spmi-0/spmi0-02/200f000.qcom,spmi:qcom,[email protected]:qcom,qpnp-smbcharger/power_supply/battery/constant_charge_current_max

    /sys/devices/platform/soc/200f000.qcom,spmi/spmi-0/spmi0-02/200f000.qcom,spmi:qcom,[email protected]:qcom,qpnp-smbcharger/power_supply/battery/voltage_max

    Enjoy!
    1
    Good job mate! Keep up the work!
    8t really works and I get full control over charging speed now.
    1
    Is there any way to do this thing without root ?
    Maybe by changing some files through twrp and adb.?
    I'd say no, because those values always reset after a reboot so they shouldn't stick if you set it in twrp and reboot to your system :D Maybe there is a way, but I don't see one :/