Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,732,479 Members 48,144 Now Online
XDA Developers Android and Mobile Development Forum

PowerSaverKernel - Usb battery drain bugs solved [UPDATED 2011/08/07]

Tip us?
 
farmatito
Old
(Last edited by farmatito; 8th August 2011 at 05:07 AM.)
#1  
Senior Member - OP
Thanks Meter 125
Posts: 544
Join Date: Apr 2009
Default PowerSaverKernel - Usb battery drain bugs solved [UPDATED 2011/08/07]

In this thread you will find a set a patches I've applied to pershoot's
kernel2635 source (https://github.com/pershoot/kernel-2635.git) in a
attempt to compile my own kernels and to fix the long standing and not cared of usb
battery drain bug (able to eat your battery in less than 2hrs).
A (outdated) list of the applied patches is:
  • 001-fix_msm_clock_warning.patch
  • 002_fix_msm_nand_warning.patch
  • 003-2.6.35.13-sched-bfs-404.patch this is by Con Kolivas http://ck.kolivas.org/patches/bfs/2.6.35/
  • 004-bfs_fix.patch
  • 006-msm_evlog_fix.patch
  • 007-hw3d_refdata.fix
  • 008-htc_pwrsink_refdata.patch
  • 009-board_trout_sapphire_fix.patch
  • 010-eventpoll_fix.patch
  • 011-dm-crypt_fix.patch
  • 012-mt9t013_fix.patch
  • 013-msm_smd_fix.patch
  • 014-pm_fix.patch
  • 016-mddi_refdata_fix.patch
  • 017-lowmemorykiller_fix.patch
  • 022-adb_2.6.29_forward_porting.patch
  • 023-htc_battery.patch
  • 024-msm72k_udc.patch
  • 025-patch-2.6.35.11-12
  • 026-BFQ-v2.patch
  • 027-BFQ-v2-r1.patch
  • 028-smd_rpcrouter.patch
  • 029-audpp_missed_DMA.patch
  • 030-msm_serial_hs.patch
  • 031-irq_pm.patch
  • 032-smd_tty.patch
  • 033-linux-2.6.38.y.git-524429c31b486c05449666b94613f59f729c0a84.patch
  • 034-10mb_32A.patch (MT1.2/Old 32a memory map)
  • 035-9aa258a27b6183e8e80241e4820883eaed23139f.patch (Magic Plus (32a) extra 10MB ram)
  • 036-kmalloc_b0937124b376946a5c93504f34ac932dffb23e3e.p atch
  • 037-2.6.36_lowmemorykiller+fudgeswap.patch
  • 038-minfree_stats-bb4a7baa64d9a56124e1f13510e9688aeed0cc10.patch
  • 039-msm72k_udc_fix_msm.git-1aa53ebd36088a60fcf4a498f763358598a477b9.patch
  • 040-synaptics_warning_fix.patch
  • 041-BFS-401-2388fb7aee855019c4a7560efb54cc7550a09743.patch
  • 042-BFS-rr_interval_335f482a0274a640ae6ab1a0036a3b263de575 b6.patch
  • 043-i2c_msm_a146e17dd81a2e4eaf67928c945038f521409384.p atch
  • 044-BFS-1000Hz.patch
  • 045-patch-2.6.35.12-13
  • 046-zram.patch
  • 047-vzalloc_for_zram_linux-2.6.38.y.git-e1ca7788dec6773b1a2bce51b7141948f2b8bccf.patch
  • 049-pmem_c21c461ce3e32d26abebe6243039824839748dc5.patc h
  • 050-gingerbread_gadget_update.patch
  • 051-adb_2.6.29_forward_porting.patch
  • 052-msm72k_udc.patch
  • 053_msm72k_udc_warning_fix.patch
  • 054-ae9bd4d574b7b8480aee162273d58d0c3840510a.patch
  • 055-ARM-zImage.patch
  • 056-wifi-3e6f7025178699b354e0e9fd94331f47ebb82763.patch
  • 057-arm-mm-cache-ecce0382ee54a765abcdc982e01a5fd30099f52d.patch
  • 058-autogroup patches
  • 059-patch-2.6.35.13-14
  • 060-cpufreq_stat_fix.patch
  • configs for 2708, ebi0 and ebi1
Please refer to the attached patches.zip files for the latest
patch series.

Main features of this kernel are:
  • BFS (in the BFS versions)
  • BFQv2r1
  • Overclocking
  • various fixes and minor enhancements
  • autogroup patches (in the autogroup versions)
BUG 1 (adb):
Patches 1-2, 4-17 are rather trivial stuff as they just silence some warnings.
Patch 22 is the one that seems to fix or reduce the "usb battery drain bug"
in the sense that after applying this patch I was not able to trigger the bug
again and I've tried several times the last days. The same result was reported
by a few courageous testers that risked to install one of my precompiled kernels
and whom I would like to thank for their collaborative effort.
The steps used to trigger the bug were:
  1. plug in usb
  2. start adb session
  3. remove usb plug
  4. check if a sticky android os entry is in the battery stats (a sure sign of incipient drain)
The patch reverts f_adb.c to be more similar to how it was in kernel 2.6.29-msm.
Similar code could also be found in HTC's 2.6.35 sources for the Incredible S
at http://dl4.htc.com/RomCode/Source_an...89aa373.tar.gz
so it could also be a alternative to use this code base for future G1 kernels.

Attached you'll find also the config I used to build the kernels posted
in the ezGingerbread thread and in Enomther's thread.

I hope this patch fixes this bug also for you as it did for me
making me a happy G1 user again.

I would thank to all who collaborated to this effort with facts
or with their wise words and advices.

BUG 2 (drain after reboot with usb connected):
After studying more and more bug N2 and thanks to the comments of the posters who sent me in the right direction
I've made a good progress. It is very early to call it a conclusive solution yet, but I was able to reboot my phone
with usb connected and after 3 hrs it is fully charged.
What did the trick was to disable:

CONFIG_SERIAL_MSM

in the kernel. I don't know what it was there for but at least
on my G1 I've tested all basic functions:

  • phone call
  • sms
  • data
  • wifi
  • BT
  • adb
  • music
  • GPS

and every thing seems to work. More test are needed tough,
there are also some minor leftovers to fix (more on this
in the next days).
For the bold a new kernel to test (tested on enomther's rom,
so I don't know if it will work on other roms).

You'll also find a VERY EXPERIMENTAL
anykernel/autokernel flashable zip archive with
EBI0/EBI1/2708+ kernels. Use it AT YOUR OWN RISK
and kindly report success or failure while flashing.
I cannot test it on all device/ROM combinations
so it may or may not work for you.
MAKE A BACKUP BEFORE USING IT so if something
goes wrong you can restore your previous rom.
I can give you very limited support due to missing
free time nonetheless patches are welcome!

Autokernel with BFS v0.401 and 1000Hz Kernel timer resolution for Froyo (discontinued):
auto-boot-2.6.35.13-farmatito-pershoot-ds-BFS+-20110428.zip
http://www.multiupload.com/8CKICMRK6B
MD5SUM 999770a413cbe93be75e00b1529f2300

Autokernel with BFS v0.404 for Gingerbread (experimental):
auto-boot-2.6.35.13-farmatito-pershoot-ds-BFS+-20110518.zip
http://www.multiupload.com/YRXWMK1AY3
MD5SUM c1373c915c8bfe3ebb470e839756a735

Standard Autokernel for Froyo (discontinued):

auto-boot-2.6.35.13-farmatito-pershoot-ds+-20110428.zip
http://www.multiupload.com/LLMKG4TRTO
MD5SUM ee3f5c53b4871076f123491c9dc388e2

Standard Autokernel for Gingerbread (stable):
auto-boot-2.6.35.13-farmatito-pershoot-ds+-20110505.zip
http://www.multiupload.com/0SJ77OM4HA
MD5SUM61a8bb913ca43a355e1eef3152b008db

Standard Autokernel for Gingerbread
with autogroup patches and memory compaction (experimental):
auto-boot-2.6.35.14-farmatito-pershoot-ds+-20110802.zip
http://www.multiupload.com/3NJ7Q0Y4TN
MD5SUM 27536ef42348dd92bb006cd8511df5d9

This kernels are unsupported they worked for me and I hope
they work for you, feel free to report problems and I will try to
fix them depending on my free time and skills.

USE AT YOUR OWN RISK. NO WARRANTY.

Enjoy


Changelog
v 20110425:
  • fixes to the installer automagic.
v 20110428:
  • BFS v0.401 + 1000Hz kernel timer resolution (BFS-version only) + rr_interval tuning.
  • i2c_msm HTC update
  • updated to 2.6.35.13
V 20110505:
  • revert kernel timer resolution to 100Hz
  • revert rr_interval tuning (BFS version)
  • update android gadget to gingerbread version.
V 20110518:
  • BFS v0.404 in the BFS versions
V 20110612
  • Compensate for rounding on odd-frequency clocksources
  • zImage fixes
  • Enable Memory Compaction
  • wifi - Don't make disabled irqs wake the device
  • cache-l2x0: Correct l2x0 initialization
  • autogroup patches
V 20110802
  • update to 2.6.35.14 (autogroup version only)
The Following 40 Users Say Thank You to farmatito For This Useful Post: [ Click to Expand ]
 
Jurai
Old
#2  
Senior Member
Thanks Meter 16
Posts: 200
Join Date: May 2010
I'm glad to see someone working to fix the USB bug, I hope it will be squashed in pershoots official builds eventually as well
 
pardus
Old
#3  
Senior Member
Thanks Meter 29
Posts: 338
Join Date: Apr 2007
Location: Johannesburg
Good work! Will try it out.

A while back everything on my screen froze (time and battery level not updated) but otherwise the phone worked 100%, however the battery lasted 2 days and 20 hours (68hrs with wifi on, 3G on, 614 overclock, browsing and gmail, etc). Weird

New: Samsung Galaxy Note - was Slim Bean 7.2, was Ezaechiel v2.1.2, now SlimSaber
Sold: Samsung Galaxy SII - Dual-booting Slim Bean & ...
Sold: HTC Desire - last on EuroSkank CM7
Old: HTC Dream (The Legend - still prefer a hard keyboard!) currently being used as HSDPA modem running:... Lazlo's
-----
My Android Apps, (Play Store links>): CG Calculator and RC E-Calc and now also RC E-Calc Pro


"It's not in the interest of any electronic device manufacturer to make the PERFECT device!"
 
dilwaladoctor
Old
(Last edited by dilwaladoctor; 28th March 2011 at 05:06 PM.)
#4  
dilwaladoctor's Avatar
Senior Member
Thanks Meter 20
Posts: 175
Join Date: Nov 2010
Location: Midwest
Forgive me if my question feels like a noob but exactly how should we apply this zip file.....should I flash it?.... OR....it has to be installed through adb (or terminal emulator?)
I read the OP but couldnt make about the methos of installing it....(kinda stupid of me I know...
Is it OK to use your kernel instead of this patch?....do they have same effect?
Phone: Galaxy Note AT&T SGHi717
Radio : Stock
Rom : Stock GB Rooted
 
farmatito
Old
(Last edited by farmatito; 28th March 2011 at 10:44 PM.)
#5  
Senior Member - OP
Thanks Meter 125
Posts: 544
Join Date: Apr 2009
Quote:
Originally Posted by dilwaladoctor View Post
Forgive me if my question feels like a noob but exactly how should we apply this zip file.....should I flash it?.... OR....it has to be installed through adb (or terminal emulator?)
I read the OP but couldnt make about the methos of installing it....(kinda stupid of me I know...
Is it OK to use your kernel instead of this patch?....do they have same effect?
The patches in the zip need to be applied to the kernel sources, built and then
a anykernel zip installer must be created. Then you can flash it.
You can try also a precompiled kernel if it is compatible with your rom.
So best is to take a nandroid backup in case things go bad.
I suggest you to wait that it is included by the devs of the rom you use
if they see it fit.
The Following User Says Thank You to farmatito For This Useful Post: [ Click to Expand ]
 
crypticc
Old
#6  
Senior Member
Thanks Meter 106
Posts: 1,057
Join Date: Aug 2009
Location: London
Well done for keeping at it
 
ezterry
Old
(Last edited by ezterry; 30th March 2011 at 03:15 PM.)
#7  
ezterry's Avatar
Retired Recognized Developer
Thanks Meter 999
Posts: 1,823
Join Date: Jan 2010
Location: Asheville, NC

 
DONATE TO ME
My testing is as follows

Using the ezGingerbread binary on a clean ezGingerbread install with gapps+facebook but no wifi or sim:

The USB connection in use is just a wire to my macbook.

0) battery validation: boot system from battery only and leave for extended time.. I was at 83% after 13h.. this indicates no particular extra drain thus this test passed

1) basic test: boot while phone charging on macbook, after system is fully loaded unplug from USB, replug, unplug again.. this case the phone was drained in under 13h thus indicates the USB drain is present test failed

2) adv. test: boot phone on batter such as test 0, after test 0 drained to say 79% charge with usb slightly, the unplug usb again and leave.. hours later indicated no significant drain test passed.

3) adv. test 2: now at 60% after test2 plug into usb reboot and unplug after fully loaded.. such as in test1 drain quickly continued test failed.

Thus we seem to have a form of USB drain that is not in the 2.6.34.* kernels, however it may be possible on this kernel to avoid it by booting the phone on its own power (I did not test booting the phone on the A/C adapter, least not yet and more testing is needed to be sure there is no other oddities)
Dream Sapphire:
> Radio 2708+ (+15MB kernels)
> MT3G ota froyo rom dream sapphire port
> ezGingerbread (rom/source): Dream/Sapphire
> DS JTAG: Soft load of SPL (to unbrick/re-root) / JTAG WIKI


Acer A500:
> ezT20 kernel A500 and A100
> A500 Public Recovery (Clockwork Mod based recovery + source for the A500)
> Acer A500 ICS Rooted w/ Busybox
> Acer_A500 OTA 7.014.14 --HC 3.2.1-- Rooted w/ Busybox


Donations for beer/rent are always appreciated.
Twitter: xdaterry -~- Google+: profile -~- GitHub: ezterry
The Following User Says Thank You to ezterry For This Useful Post: [ Click to Expand ]
 
farmatito
Old
(Last edited by farmatito; 31st March 2011 at 08:55 PM.)
#8  
Senior Member - OP
Thanks Meter 125
Posts: 544
Join Date: Apr 2009
@ezterry :

so if understand it correctly it is booting/rebooting with
usb plugged in that still fails?

Do you see the same stuck "android os" entry in battery stats?
If not, than maybe it is a different bug, so more patching is needed.

UPDATE:

test:

plug in usb
reboot
wait a little while phone is charging
unplug usb
go to battery stats:
there you'll see "android os" entry
hit a few times refresh
"android os" %value decreases and after a few more refresh hits it disappears.

I think that if there is battery drain in this case it is not the same bug.
Will check the phone later to see how it behaves:
  • 16.59 84%
  • 18.18 77%
  • 20.42 68%
16 % / 4hrs = 4% /1hrs (in idle state)

Looks not so bad to me... but definitely would not last
48+ hours as my battery usually lasts.
In my opinion this is not the same bug tough, because
what I and other users were experiencing was a very
fast battery drain after disconnecting from a adb
session. The latter bug is indeed fixed.
 
farmatito
Old
#9  
Senior Member - OP
Thanks Meter 125
Posts: 544
Join Date: Apr 2009
After more testing with this bug N 2 triggered the power
consumption with my extended battery is stable at about
4%/hr. I've looked at the most likely candidates

htc_battery.c
msm72k_udc.c

but I've not spotted differences between 2.6.34.8 and 2.6.35.11
that could explain the different behaviour.
Hints and help is welcome.
 
VAMCAVALO
Old
#10  
Member
Thanks Meter 0
Posts: 58
Join Date: Apr 2009
Can some one explain that USB drain problem?

I already had change my battery but it hasn't make any difference...
My G1 can only work for 4h and them the battery is over.

That patch can fix it?
How do I flash it?

Tags
usb battery drain bug
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes