[BATT Fix][GB SENSE Kernel] Get your phone charged to 100% when you pick it up

Search This thread

sibere

Retired Recognized Developer
May 14, 2006
2,055
375
Paris
Like you guys, I was fed-up with the HTC battery charging policy. Picking-up my phone charged to 90% after an overnight was really annoying.
Basically, the Desire stops charging when the battery is fully charged and waits for the level to drop to 90% before recharging to 100% again.

I went for a deeper look at sources. I wanted to have a trickle charge on my phone, even at the cost of a battery wear (not even sure about that tho, because it's the way the battery is charging when the phone is turned OFF - not in standby).

With a very minor tweak in the HTC DS2784 driver, it is possible to change this behaviour in a way that the charge doesn't stop @ 100% but a very small current (close to 0mA) keeps your battery @ 4.2v. I have experimented my little hack on my own desire and I can tell you that it's working perfectly well! I monitored for hours the charging process and the current slowly dropped to very small numbers. HTC_BATT was reporting 0 to 2mA charge and was even letting the battery discharging (-2 to -4mA) to keep it at 4.2v

What you get with this is a normal charge, and when the battery is close to 4.2v, the charging current slowly drops to 0mA. I haven't changed anything else so the battery is still overtemp or overcharge protected.

The file involved is drivers/power/ds2784_battery.c
I attached a patched file below (for GB sense kernel)

Here is the diff (the magic bit ;-) ):

Code:
965c965
<               charge_mode = CHARGE_OFF;
---
>               charge_mode = CHARGE_SLOW;
972c972
<                               charge_mode = CHARGE_OFF;
---
>                               charge_mode = CHARGE_SLOW;

The full code now looks like this:

Code:
} else {
        if (htc_batt_info.rep.level <= 99)
                htc_batt_info.rep.battery_full = 0;

        if (htc_batt_info.rep.battery_full) {
                charge_mode = CHARGE_SLOW;
                }
        else if ((htc_batt_info.rep.guage_status_reg & 0x80) &&
            (htc_batt_info.rep.batt_current <= 80) &&
            (htc_batt_info.rep.level == 100)) {
                if (More_Charge_Extend_Time()) {
                                htc_batt_info.rep.battery_full = 1;
                                charge_mode = CHARGE_SLOW;
                }
        }

Cut& paste this thread to your favourite kernel developer :D (For HTC SENSE ROMS / KERNELS ONLY. Others seems to be not affected)

I would like to thank RichardTrip for his kernel and his github.
I would like to thank Mekrel as well, as he showed me the path with his post.

I built a Froyo V5e kernel for you guys just here

Last updated kernel is also attached (GingerBread SENSE kernel) based on bananacakes's patches.
An APP to tweak SVS/HAVS settings: IncrediControl (Thanks to sebastiaan15 who mentioned it). The settings in the general tab are only functional in kernels that have implemented the simple sysfs interfaces for usb fast charging and audio boost.


If your phone is unstable with those kernels, try those stable kernels.
 

Attachments

  • ds2784_battery.zip
    10.8 KB · Views: 462
Last edited:

flash3d

Senior Member
Aug 2, 2010
400
48
Posted a link in the leedroid thread, hopefully it will be picked up. Thanks for your solution.
 

Azurael

Senior Member
Jan 3, 2008
892
219
Bath
My MacBook does the same thing (i.e. allows the charge level to drop off before resuming) and I'm guessing there's a reason for that, not that I know about LiIon/Poly chemistry other than that they supposedly don't have a memory effect and only tend to degrade in terms of the number of charge cycles all added together, part cycles don't cause loads of harm like they do with NiMh/NiCd... At least Desire batteries are cheap if this knackers them in the medium term.
 

sibere

Retired Recognized Developer
May 14, 2006
2,055
375
Paris
My MacBook does the same thing (i.e. allows the charge level to drop off before resuming) and I'm guessing there's a reason for that, not that I know about LiIon/Poly chemistry other than that they supposedly don't have a memory effect and only tend to degrade in terms of the number of charge cycles all added together, part cycles don't cause loads of harm like they do with NiMh/NiCd... At least Desire batteries are cheap if this knackers them in the medium term.

Yep . Actually the charge doesn't really stops. The current slowly drops to 0mA or 1mA.

I've been told that it might not be very healthy for the battery to be maintained at a high voltage for a long period of time, but that's the cost of an always fully charged phone :)
 

Visentinel

Senior Member
May 29, 2007
961
157
Washington
Unfortunately yes when you hold the battery at 4. 2v it hurts it. Instead of getting closer to 18-24 months out of the battery you'll get around 12 months doing this every night. It doesn't matter tho. I already run mine to 4. 2 v overnight I got my 3000mah extended battery for only 22 dollars so why care?

Sent from my HTC Desire using XDA App
 

sibere

Retired Recognized Developer
May 14, 2006
2,055
375
Paris
Unfortunately yes when you hold the battery at 4. 2v it hurts it. Instead of getting closer to 18-24 months out of the battery you'll get around 12 months doing this every night. It doesn't matter tho. I already run mine to 4. 2 v overnight I got my 3000mah extended battery for only 22 dollars so why care?

Sent from my HTC Desire using XDA App

because the battery is fully charged, I recharge it only one night out of two now ;)

We can expect the batteries to be even cheaper in a year from now! :D
 

lordofcamster

Senior Member
Mar 27, 2010
463
107
44
Wallhalben
Is it possible to get the battery to 100 % and let drop to 98% or so and then recarche to 100%? Think this would be better for the battery!?

Sent from my brain using telepathy
 

sibere

Retired Recognized Developer
May 14, 2006
2,055
375
Paris
Can you please share it because I really don't know how to implement this into my Desire..:)
Thanks in advance..;)

Basically, if you don't know how to compile a kernel , forget about it. Just wait for an "official" kernel builder on this forum to apply this hack and post an update.

remember that you have to be root to flash a new kernel ;)
 

ahac85

Senior Member
Aug 7, 2010
1,583
246
Like you guys, I was fed-up with the HTC battery charging policy. Picking-up my phone charged to 90% after an overnight was really annoying.

Thanks to the RichardTrip Kernel and Thread, I went for a deeper look at sources. I wanted to have a trickle charge of my phone, even at the cost of a battery wear (not even sure about that tho).

Basically, the Desire stops charging when the battery is fully charged and waits for the level to drop to 90% before recharging to 100% again.

With a very minor tweak in the DS2784 driver, it is possible to change this behaviour in a way that the charge doesn't stop @ 100% but a very small current (close to 0mA) keeps your battery @ 4.2v. I have experimented my little hack on my own desire and I can tell you that it's working perfectly well!

What you get with this is a normal charge, and when the battery is close to 4.2v, the charging current slowly drops to 0mA. I haven't changed anything else so the battery is still overtemp or overcharge protected.

The file involved is /bravo-2.6.32/drivers/power/ds2784_battery.c (HTC sense 2.6.32.15 kernel)

Here is the diff (the magic bit ;-) ):

Code:
965c965
<               charge_mode = CHARGE_OFF;
---
>               charge_mode = CHARGE_SLOW;
972c972
<                               charge_mode = CHARGE_OFF;
---
>                               charge_mode = CHARGE_SLOW;

The full code now looks like this:

Code:
} else {
        if (htc_batt_info.rep.level <= 99)
                htc_batt_info.rep.battery_full = 0;

        if (htc_batt_info.rep.battery_full) {
                charge_mode = CHARGE_SLOW;
                }
        else if ((htc_batt_info.rep.guage_status_reg & 0x80) &&
            (htc_batt_info.rep.batt_current <= 80) &&
            (htc_batt_info.rep.level == 100)) {
                if (More_Charge_Extend_Time()) {
                                htc_batt_info.rep.battery_full = 1;
                                charge_mode = CHARGE_SLOW;
                }
        }

Cut& paste this thread to your favourite kernel developer :D

I would like to thank Richard for is kernel and is github. (http://xdaforums.com/showthread.php?t=801435)
I would like to thank Mekrel as well, as he showed me the path with his post (http://xdaforums.com/showpost.php?p=8695549&postcount=464).

the battery fix is already in the new kernels isnt it? correct me if im wrong anyone, but richard kernel the battery charges itself again when it drops to 99% and in previous kernel it use to start chargin again at 95% not 90%!!!!
 

sibere

Retired Recognized Developer
May 14, 2006
2,055
375
Paris
Really? I was using v5e and my battery was dropping to 90% before recharging...

The only change made to the driver was a few definitions about critical temps and charging voltage.

From Richard Github:

Code:
#define CHARGE_SLOW  1
#define CHARGE_FAST  2
-#define TEMP_CRITICAL  600 /* no charging at all */
-#define TEMP_HOT  500 /* no fast charge, no charge > 4.1v */
-#define TEMP_WARM  450 /* no fast charge above this */
+#define TEMP_CRITICAL  800 /* no charging at all */
+#define TEMP_HOT  700 /* no fast charge, no charge > 4.1v */
+#define TEMP_WARM  650 /* no fast charge above this */
-#define TEMP_HOT_MAX_MV  4100 /* stop charging here when hot */
-#define TEMP_HOT_MIN_MV  3800 /* resume charging here when hot */
+#define TEMP_HOT_MAX_MV  4500 /* stop charging here when hot */
+#define TEMP_HOT_MIN_MV  4200 /* resume charging here when hot */
 #define TEMP_CRITICAL_BC      570 /* no charging at all */
 #define TEMP_CRITICAL_RECHG_BC  550 /* recharge at 1.temp <= 55C and 2. Vb < 3.8V */

Here in this case it's a battery mod, not a fix ;)
 
Last edited:

Ninolina

Senior Member
Dec 1, 2009
1,433
1,191
Beograd
Basically, if you don't know how to compile a kernel , forget about it. Just wait for an "official" kernel builder on this forum to apply this hack and post an update.

remember that you have to be root to flash a new kernel ;)

Can you at least then share your Kernel? Thanks in advance...:)

Just to add... I have a Rooted and an S-OFF Desire...:) :) :)
 
Last edited:

sibere

Retired Recognized Developer
May 14, 2006
2,055
375
Paris
Can you at least then share your Kernel? Thanks in advance...:)

Year, that's doable.

Be carefull don't use it if you have app2SD because ext2/3/4 are compiled as modules.

I will NOT provide any kind of support, so try it at your own risks (disclaimer done! :D )

it has:

HAVS (@925mV min)
UV/OC (1152mHz)
UC (128mHz min for screen-off power save, to be tuned with SetCPU)
CFQ Sched
All CPU governors, Interactive as default
SDfix
Battery fix for trickle charge (but not the v5f battery mod)
GPU+ (Enhanced GPU performances)
SWAP enabled
ext2/3/4 CIFS, etc... as modules (not good for App2SD users)


http://www.multiupload.com/789P9VYN1C

It is booting perfectly well on my phone. If it is not booting on yours, try to remove all the modules of you old kernel (in /system/lib/modules in recovery mode with ADB) and flash it again. If it still doesn't work, don't ask me why!

More updates within the next pages. (EXT2/3/4 and GROUP_SCHED)
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 14
    New Kernel

    Hi!!
    So just built and tested GB kernel with all the good stuff and patches from bananacakes.
    He really did a good job and many credits to him.

    So here is my last kernel, with all the patches and options from bananacakes kernel (see here for details)

    I've added my battfix, swap, ext4 to kernel and btrfs as module.

    VDD levels interface is working BUT the regulator is still stuck @ 1300mv :(
    11
    Last build.

    All latest mods from bananacakes (thanks again to him for his great work)
    OC to 1.19 and no OC versions
    cifs & btrfs as modules, my battfix and (useless but there anyway) swap ;)
    Code:
    cd /system/lib/modules
    sh-3.2# ls -l
    ls -l
    -rw-r--r-- root     root       285617 2008-08-01 14:00 bcm4329.ko
    -rw-r--r-- root     root      4592993 2008-08-01 14:00 btrfs.ko
    -rw-r--r-- root     root      3177776 2008-08-01 14:00 cifs.ko
    sh-3.2# insmod btrfs.ko
    insmod btrfs.ko
    sh-3.2# lsmod
    lsmod
    btrfs 530147 0 - Live 0xbf03b000
    cifs 229772 0 - Live 0xbf000000
    And insmod tested ;)

    OC is booting @ 998MHz max, then you select whatever you want with setcpu, cpumaster or any of your fav app :)
    7
    ARGH!!!

    Just reaslized that the battfix patch was missing :D

    So I've just build a new one with it and Interactive/Smartass/Conservative/ondemand/powersave/performance cpu govs.
    LZMA compressed kernel too.
    6
    in reality the voltage could be changing

    it could be changing, but it does not, because of an i2c issue
    5
    Thanks, I wonder myself how can that be useful since Android reclaims RAM in a very good way and I'm hardly out of memory. Think I won't activate then. :)
    Going and flash your latest kernel btw, thanks once again! ;)

    Hold your fire, a new build is on it's way, with latests updates (2way call rec and so on) and OC to 1.19 MHz