yashsingh1/xdaforums huggingface dataset:
[Nexus One Android Development] dvgrhl:
Yeah, that's a much better way of accomplishing it. I think that's really worth testing. If you want to compile it, I'll test it out all day tomorrow. I am sure Roger will too. :)
[Nexus One Android Development] chowlala:
I've been testing the last kernel Pershoot posted. I can tell from a full overnight charge, I still get 1361 mAh. So guess we gotta continue working away. Haven't been following the past few pages (haven't read 'em either), so I'm probably saying something redundant now by saying we need a work around, which is already probably en route reading the past few posts on this page. Haha.
[Nexus One Android Development] RogerPodacter:
Yeah I like that logic. I'll test that one for sure.
[Nexus One Android Development] RogerPodacter:
You should read the last few pages. I think we got it. The one your testing did the same thing for me too. Try the new one, I got to 1433mAh:-)
[Nexus One Android Development] dvgrhl:
Nah, you should wait and try the next one pershoot posts. I think that one will have the best chance of being included in a final kernel. And it will be good to have several of us testing it.
[Nexus One Android Development] pershoot:
http://droidbasement.com/nexus/kern...-cm_2635.3-oc-uv-xtra-btn-aud-ram-neon_fp.zip

Flash at your own risk!

.........

/* shut off charger when full:
* - CHGTF flag is set
*/
/* We don't move from full to not-full until
* we drop below 95%, to avoid confusing the
* user while we're maintaining a full charge
* (slowly draining to 95 and charging back
* to 100)
* Oddly, only Passion is for 99% cycles, HTC
* set the Bravo to 95%.
* -od of xbravoteam
*
* Set 99 for Passion and add current_uA > 80 - pershoot
*/

if ((di->status.percentage < 99) ||
((di->status.current_uA/1000) > 80)) {
di->status.battery_full = 0;
}

/* Modified check function, based on original HTC Source.
* Added current_uA check (relates to 1400mAh capacity check)
* -od of xbravoteam
*
* replace current_uA <= 80 with current_avg_uA <= 40
* - pershoot,dvgrhl,rogerpodacter
*/

if ((di->status.status_reg & 0x80) &&
((di->status.current_avg_uA/1000) <= 40) &&
(di->status.percentage == 100)) {
di->status.battery_full = 1;
charge_mode = CHARGE_BATT_DISABLE;
}

......

if (di->status.battery_full == 1)
di->last_charge_seen = di->last_poll;

.....
[Nexus One Android Development] dvgrhl:
Thanks pershoot. I'll let my battery drain down some with this new kernel overnight, and tomorrow I'll charge it and watch the logs and report back.
[Nexus One Android Development] RogerPodacter:
I'll do the same. I'm right half way thru my full discharge tonight. First thing in morning I'll give this one a full charge and post the logs. Thanks pershoot:-)
[Nexus One Android Development] RogerPodacter:
i just wanted to give a quick example for the justification of 20 mA vs 80 mA or any other value. check lines 224-225 out from this driver ds2760 (click me):

tatic void ds2760_battery_update_status(struct ds2760_device_info *di)
203 {
204 int old_charge_status = di->charge_status;
205
206 ds2760_battery_read_status(di);
207
208 if (di->charge_status == POWER_SUPPLY_STATUS_UNKNOWN)
209 di->full_counter = 0;
210
211 if (power_supply_am_i_supplied(&di->bat)) {
212 if (di->current_uA > 10000) {
213 di->charge_status = POWER_SUPPLY_STATUS_CHARGING;
214 di->full_counter = 0;
215 } else if (di->current_uA < -5000) {
216 if (di->charge_status != POWER_SUPPLY_STATUS_NOT_CHARGING)
217 dev_notice(di->dev, "not enough power to "
218 "charge\n");
219 di->charge_status = POWER_SUPPLY_STATUS_NOT_CHARGING;
220 di->full_counter = 0;
221 } else if (di->current_uA < 10000 &&
222 di->charge_status != POWER_SUPPLY_STATUS_FULL) {
223
224 /* Don't consider the battery to be full unless
225 * we've seen the current < 10 mA at least two
226 * consecutive times. */
227

i think 40 mA is a fine buffer. but the above shows example that a li-ion battery is considered full when it stops drawing current on its own, or in the case above, < 10ma which is very close to that.

battery will only pull what it needs till its full, which it will stop itself. however i think we should keep out safety buffer we're using and see how it goes.

did we ever figure out why AOSP is different?

Current AOSP

448 if (di->status.status_reg & 0x80) {
449 di->status.battery_full = 1;
450 charge_mode = CHARGE_BATT_DISABLE;

Old Method

if ((di->status.status_reg & 0x80) &&
((di->status.current_uA/1000) <= 80) &&
(di->status.percentage == 100)) {
di->status.battery_full = 1;
charge_mode = CHARGE_BATT_DISABLE;

what happens if we try the first one? what mA will the charging stop? (I'm curious...)

I think its related to this

if (di->status.battery_full == 1)

being changed to this

if (di->status.current_uA > 1024)
[Nexus One Android Development] chowlala:
Downloaded and testing now. Will report back findings by tomorrow since I'm working like a maniac now. Haha.
[Nexus One Android Development] theloginwithnoname:
Doesn't that need to be "percentage <= 99"?

Also, if we're saying the battery is "full" when current_uA is < 40, the first block of code should be ">= 40" (not > 80) and the second block should be "< 40" (not <= 40)?

After reading the tech sheets for the battery, I'm with Roger that the battery will look after itself so we can reduce the "buffer" value of 40 down to 20. After all, it is a test kernel that only a few of us are running and we'll be watching the logs when it gets to that point, so we can stop the charge if it's been on 100% for (say) 10 mins and < 20 is never hit.

I'm going to give the 20 kernel a go now - just gotta let phone discharge a bit. I did an overnight off-charge and a subsequent bump when I got up, so the phone is currently on 1398mAh ;)

Roger - re you wanting to just try < 20 and not check status_reg, if I'm reading the code right, it's actually more likely to remain on charge with the three conditions rather than just one, because you've seen the odd lines where it's dipped to 9mAh and removing the status_reg check would have resulted in charge stopping!
[Nexus One Android Development] theloginwithnoname:
100% -> 99 -> 100 -> 99?!

Check this log out that I saw whilst waiting for it to go down to 98%:

timestamp mV mA avg mA uAh dC % src mode reg full
8 4123 -287 -131 1360000 273 100 none off 0x87 1
58 4114 -243 -229 1356800 273 100 none off 0x87 1
108 4118 -212 -223 1353600 273 100 none off 0x87 1
174 4114 -209 -284 1348800 277 100 none off 0x87 1
227 4138 -4 -121 1347200 278 100 none off 0x87 1
285 4143 -6 -31 1347200 278 100 none off 0x87 1
349 4143 -9 -23 1345600 276 99 none off 0x87 1
402 4143 -6 -17 1345600 276 99 none off 0x87 1
454 4143 -5 -5 1345600 273 99 none off 0x87 1
506 4148 -4 -4 1345600 273 99 none off 0x87 1
556 4148 -4 -4 1345600 271 99 none off 0x87 1
617 4143 -5 -6 1345600 270 99 none off 0x87 1
[I] 677 4148 -5 -5 1344000 268 100 none off 0x87 1
[/I] 737 4133 -103 -51 1342400 267 99 none off 0x87 1
797 4109 -197 -103 1342400 266 99 none off 0x87 1
857 4123 -125 -124 1340800 271 99 none off 0x87 1
917 4123 -134 -203 1337600 276 99 none off 0x87 1
969 4133 -6 -78 1336000 275 99 none off 0x87 1
1037 4133 -9 -7 1336000 273 99 none off 0x87 1
1097 4133 -7 -5 1336000 271 98 none off 0x87 0

weird.

Also, notice when it hits 98 (i.e. < 99) it sets full = 0. Definately need <= 99 for condition "full = 0".

About to charge!
[Nexus One Android Development] RogerPodacter:
Good catch, those values do look wrong.

With the 20 mA kernel, try with screen both on And off. My current dipped and tripped the condition cause it fluctuates at small values under load. With screen off its very consistent.

It worked for me surprisingly well, so good luck. We just need to reset our capacity register now. Learn mode.
[Nexus One Android Development] RogerPodacter:
Weird, never seen that before.

Oh, what is the command line to enter in terminal to export that quickly? I'm tired of using OS monitor to export, even though it allows naming each export so you can keep track of your tests.
[Nexus One Android Development] theloginwithnoname:
bottom of post 300 ;)

the bit after the > can be any location you can write to - change the filename to record separate.

alternatively, instead of > use >> to add to end of file ;)
[Nexus One Android Development] RogerPodacter:
Excellent, you rock. Much easier time now getting the log:-).

Edit. Actually I don't know how to use paste buffer with the stock cyan terminal bps.
[Nexus One Android Development] theloginwithnoname:
A bit of command-line hackery goes a long way ;)

You can also email the file off the phone without having to connect the cable - useful if you're trying to drain / watch battery etc...

I'm not far off posting logs from the 20mAh test kernel btw. 99% and 1344mAh at present
[Nexus One Android Development] RogerPodacter:
How exactly can I paste in the terminal app? Noob:-)
[Nexus One Android Development] theloginwithnoname:
My bad. Original edited. :o
[Nexus One Android Development] RogerPodacter:
damn that's too bad. Actually Google brings up some results on this. There may be a way to do it with an additional app. Web OS users discussed exact issue with their terminal.
[Nexus One Android Development] theloginwithnoname:
It's not too bad typing the command, and once you have it there just press trackball up to recall it.

About to post logs...
[Nexus One Android Development] theloginwithnoname:
Here's logs of the test kernel pershoot posted - initially I thought it was <20 but it seems from logs its <40. I then realised it's the same URL so clicking the first post won't download anything different to the second :-/

1037 4133 -9 -7 1336000 273 99 none off 0x87 1
1097 4133 -7 -5 1336000 271 98 none off 0x87 0
1157 4123 -96 -139 1334400 276 98 none off 0x87 0
1217 4123 -97 -112 1332800 281 98 none off 0x87 0
1277 4123 -95 -122 1332800 281 98 none off 0x87 0
1337 4114 -124 -138 1329600 281 98 none off 0x87 0
1397 4114 -182 -145 1328000 288 98 none off 0x87 0
1457 4123 -10 -122 1324800 287 98 none off 0x87 0
1517 4128 -8 -5 1324800 283 98 none off 0x87 0
1577 4109 -188 -5 1324800 283 98 none off 0x87 0
1637 4157 152 138 1326400 282 98 ac fast 0x87 0
1693 4162 156 143 1328000 281 98 ac fast 0x87 0
1757 4162 147 149 1331200 281 98 ac fast 0x87 0
1817 4162 121 120 1334400 281 98 ac fast 0x87 0
1876 4162 134 137 1336000 283 98 ac fast 0x87 0
1937 4162 112 114 1337600 286 98 ac fast 0x87 0
1997 4162 100 103 1339200 286 99 ac fast 0x87 0
2057 4162 103 105 1340800 283 99 ac fast 0x87 0
2117 4167 116 117 1344000 283 99 ac fast 0x87 0
2177 4167 94 106 1345600 283 99 ac fast 0x87 0
2228 4167 91 92 1345600 286 99 ac fast 0x87 0
2297 4167 89 86 1347200 283 99 ac fast 0x87 0
2357 4167 84 87 1348800 286 100 ac fast 0x87 0
2417 4167 82 82 1350400 286 100 ac fast 0x87 0
2477 4167 80 81 1352000 285 100 ac fast 0x87 0
2537 4167 72 71 1353600 286 100 ac fast 0x87 0
2597 4167 69 69 1355200 288 100 ac fast 0x87 0
2657 4172 43 68 1356800 291 100 ac fast 0x87 0
2718 4172 69 70 1356800 288 100 ac fast 0x87 0
2778 4172 82 84 1358400 288 100 ac fast 0x87 0
2838 4172 54 74 1360000 288 100 ac fast 0x87 0
2898 4172 60 62 1360000 288 100 ac fast 0x87 0
2956 4172 56 54 1361600 286 100 ac fast 0x87 0
3018 4167 46 41 1363200 293 100 ac fast 0x87 0
3077 4162 22 37 1363200 298 100 ac full 0x87 1
[battery_charge_off]
3138 4162 0 0 1364800 303 100 ac full 0x87 1
3194 4162 0 0 1364800 303 100 ac full 0x87 1
3258 4162 0 0 1364800 303 100 ac full 0x87 1
[unplugged_charger]

It's still on charge so we'll see where it ends up. edit: 1363200 - and discharging.

What I do think the logs show, is that even if we go to < 2 mAh, it still won't get us 1400mAh so there is still something flawed in the on-charge code!

In the next test kernel I'd vote for < 10 as a trigger to stop. Any chance of getting another test kernel over shortly?
[Nexus One Android Development] chowlala:
So let's have someone make an app that will let us delete the .bin file and if they want, read the file at the same time and give em some tools that'll help with analyzing the data into something understandable if people bother to take a few mins to read through?

That was kinda what I meant... I think. Hahaha. =)
[Nexus One Android Development] stuff:
I just dont understand those folk with the battery issue. I've always drained mine to around 20% then recharged back to 100%, and then did it again.

I let my phone die about once so far, and it died at 1% life. It even sat at 1% for 10 mins of me still using it before cutting off.

I just think you guys aren't charging it properly and the way it records is getting confused or something. I don't know much about batteries, but I know that mine does as someone said earlier. It takes a long time to charge from 90-100%, and drains normally.

Maybe you just have a crappy kernel loaded
[Nexus One Android Development] chowlala:
I'm using pershoots kernel. :P

Yeah, it might be bad battery charging happening, but that's the also the point of this thread, to help others like myself who might have these bad chargings get it corrected. And at the same time, see if there's a way from the coding point of view to help out others.

My phone takes ages to charge as well from 90-100. It's just that it turns off at the 10% mark rather than below it on a usual basis. And there are many other here as well who have the same issue.

Why?

Most likely because we have different batteries and humidity, etc. But that doesn't change the way the OS works in identifying the stats and managing it.
[Nexus One Android Development] simms22:
Thats a wonderful idea!

Ill be the first to admit that i have bad charging habits. At work i periodically charge my phone through out the day. To be honest, it rarely falls bellow 65%. Then at home its usb tethered to my laptoo(for my home data connection). So it charges to 100 then discharges to 89, automatically it starts charging and repeats the cycle all night.
[Nexus One Android Development] Marine6680:
You don't want to delete the battery stats too often; like I said before, android uses the file to help get the best charge when charging with the device on. With the file deleted, the system must be conservative; if you delete the file it would be best to charge with the device off for the first time.
[Nexus One Android Development] dogiedogie:
I guess I am not one with great charging habits either. Come home, whatever its at slap it in charger, usually leave it till I go have a bath (....how can you have a bath without a phone, its integral). Also drain it to 5-8% a few times playing games when its been on in my bed for like 2 days till it dies (time to get up xD [/route charger through the slats of my bed xD])
[Nexus One Android Development] RogerPodacter:
for those talking about "when the light turns green" and then continue charging it. remember, the nexus turns on the green light at 90%!! so when charging your nexus, it hits 90% and turns green making you think its full if you arent paying attention. you still have another 10% to go until you hit 100%.

it seems HTC/google just decided to make the top 90-100% as the "green" full battery zone.

also, my phone always dies at 8%, so i have to delete my battery file.
[Nexus One Android Development] overground:
I researched this a little when I had my G1. According to T-mobile the battery is not what needs the calibration, it's the phone to your battery. Read this thread until the battery discussion stops. May find some info there.

EDIT: I'm running Rodriguez' Froyo and wildmonk's 925CFS06-13 kernel with Juice Defender, Power Manager and Screeble. I took my phone off charge yesterday @ 6pm it's 3:30pm the following day and I still have 36% left. Call usage during the period has been heavier than normal for me, sms average and browsing below average usage. Also using static, darker colored walpaper.
[Nexus One Android Development] chowlala:
Hmm, again, if it's phone to battery, how does the phone read the battery state? I'm sure there must be some way we could possibly make it more accurate than it currently is... though it sounds pretty dangerous at the same time... heh.

Any of the devs reading this got any input?

PS EDIT: There's a link on T-Mobile bout battery calibration as well. Not sure if it'll help us... but wth. =)

http://forums.t-mobile.com/t5/Frequently-Asked-Questions-FAQs/Known-Issues-T-Mobile-G1/m-p/50508#M42
[Nexus One Android Development] RogerPodacter:
ok so i said before my battery has ALWAYS died at 8%. well today i deleted my battery file. i wiped from the recovery menu (hold trackball while power on).

what i did was before i wiped the stats, i charged to 100% and left it plugged into the usb charger. the battery voltage said 4.172 volts. totally normal for a full charge for me. i then turned off the phone with 100%, booted into recovery, and wiped the battery stats, and then used the phone all the way down to 10% where it died.

so i assume this is normal? so now i should charge up to 100% again and it should now have a correct upper and lower limit? because honestly i did not expect it to die at 10%, especially because the voltage was still 3.599 volts. but in the past it has ALWAYS gone down to 4.48 volts before then shutting off at 8%. now this time its shutting off at 10% but still showing close to 3.6 volts, which is plenty of juice left in it considering previously before my wipe it has gone down to 3.4 volts.

hope i'm doing this right.

EDIT: ok i just turned it back on, went into the info menu, and battery showing 3.488 volts. so at least it seems to have gone down all the way. but it still died kinda early. maybe that's just part of the initial calibration, since it had no previous average to go off because it was just wiped.

EDIT 2: nope, not even 30 seconds later and now its showing 3.776 volts at 2% charge so far. jumped up quickly, which is not necessarily a bad thing. but i would like for the meter to memorize that 3.48 volts is an acceptable lower limit. lets hope it does!
[Nexus One Android Development] theloginwithnoname:
Good post Marine.
[Nexus One Android Development] theloginwithnoname:
Given what I've read over the past few months, I try to do the following:

once a month - "comprehensive" recalibration

every couple of weeks - "normal" recalibration

rest of the time - normal charge (e.g. let battery die then to 100%, X% left of battery to 100%, X% to when-you-can't-leave-it-any-later-to-leave-the-house!) - preferably always whilst phone is off

comprehensive recalibration

allow battery to drain til phone turns off

switch phone back on until it doesn't boot past initial X/padlock screen (normally only once or twice after initial power off)

pull battery

replace battery after X seconds (? 20, 30 seconds)

plug in wall charger

charge device powered-off, either:

overnight

until light goes green, then for an additional 30-60 mins

boot into recovery

wipe battery stats (same as deleting .bin file I believe)

restart

use device normally

repeat steps 1, 5, and 6

boot as normal

repeat steps 1, 5, and 6

boot as normal

full/partial/top-up charge as you wish

i.e. full charge, wipe previous learnings, allow android to learn what full battery is, confirm what full battery is.

normal recalibration

as above but emit steps 7 to 13 inclusive

i.e. full 0-100% charge powered off - reconfirm lower and upper limits

The steps above assume the device is regularly having software updates, new software, tweaks to settings etc.

For devices where the software and ROM is generally static, comprehensive could be done every 2 months and the normal every 1 month.

After a new ROM or kernel is flashed, or for a new battery, a comprehensive recal should be done.
[Nexus One Android Development] chowlala:
I seem to be having more accurate battery readings by simply charging with the phone off the past few days.

If you charge the phone while it's on, it'll only hit up to the 4.17x mark if i'm not mistaken.

Charging with the phone off allows it to go up till 4.19x or so. Haven't seen higher, but I haven't charged longer than 30 mins with the phone off yet though.

Again - what are the chances of us developing something to monitor the battery stats and allow us to mess around with it? After all, we wipe the stats anyhow. Lol.
[Nexus One Android Development] RogerPodacter:
Ok I have interesting news. My battery still dies at 8% even though I just wiped my battery stats last night. The final voltage was 3.444 volts. I can only conclude that the OS has built-in non changeable battery info given by the manufacturer, and that each battery just has minor variations in manufacturing specs, so that my battery must just be slightly lower capacity than the average nexus battery. That's the only thing I can think of. After the battery file wipe the full charge was still 4.172 volts, so thats still normal. But it still shut off at 8%after a wipe from recovery.

Is it possible that deleting with root explorer could somehow access different battery files?
[Nexus One Android Development] chowlala:
This raises an interesting thought... is it possible for us then to share our batterystats with each other?
[Nexus One Android Development] RogerPodacter:
What info are you looking for? I'm curious what my battery's actual mAh is rated. With my past Nokia phones, they would come with a 1200 mAh battery. But when you check the actual specific battery, it would show 1145 mAh in the menu. Each phone battery had variations in production.

I'm curious what my nexus really is. If the OS is expecting 1400 but the battery is really 1350, that could account for an 8% difference my phone is seeing. I'd love to buy a second stock battery to compare.
[Nexus One Android Development] chowlala:
Oh, actually, I meant pulling your battery stats and putting em into mine kinda thing. Not sure what that would actually mean though. But i'm sure it's a possible thing to do...
[Nexus One Android Development] RogerPodacter:
man, the other thing my battery does is when i'm charging it to 100%, it goes up to 95% and gets slower and slower. then it goes from 95% instantly to 100%. so it skips that last 5%, even though i'm sure it's fully charged. why does it "think" its not when its showing 95% already? something is just off with this whole thing.
[Nexus One Android Development] theloginwithnoname:
Yep, I've seen mine do that several times. Sometimes its 95, sometimes 96, sometimes 97. Another reason for charging whilst the device is off, I guess.
[Nexus One Android Development] theloginwithnoname:
Probably worth monitoring this thread re battery life/stats (poll optional):

http://xdaforums.com/showthread.php?t=658145

Here's what I think would really help:
[Nexus One Android Development] RogerPodacter:
That's just as good, pressing up. And I just gotta switch off my T9 keyboard to make this easier...
[Nexus One Android Development] RogerPodacter:
Deleted. Tap a talk mess up.
[Nexus One Android Development] RogerPodacter:
I think you will get up there. Did you get the charge off message yet? My logs were pretty clear for that test anyway.

I'm with you, I wouldn't mind a < 10 ma kernel. Just give it some time and see what happens...
[Nexus One Android Development] RogerPodacter:
Wait I just looked your log, your current is approaching zero much earlier than mine. Meaning yes you'll never get that high. How was I able to do it? Weird. Also you say your bump charge doesn't always get you high numbers. For me it works every time. That's strange too. Maybe your battery is older, reduced capacity?
[Nexus One Android Development] theloginwithnoname:
sorry, pulled that info from battery file not OSmonitor - here's subset of OSmon:

3018 4167 46 41 1363200 293 100 ac fast 0x87 0
3077 4162 22 37 1363200 298 100 ac full 0x87 1
[battery_charge_off]
3138 4162 0 0 1364800 303 100 ac full 0x87 1
3194 4162 0 0 1364800 303 100 ac full 0x87 1
3258 4162 0 0 1364800 303 100 ac full 0x87 1
[unplugged_charger]
[Nexus One Android Development] RogerPodacter:
Hmmm oh well, so much for that. Wonder why mine got so much higher? My current was still much higher at 1363. Older battery reduced capacity?

Have you used the power draw widget? It's funny what they are doing very similar to us right now.

http://xdaforums.com/showthread.php?t=723217&goto=newpost