yashsingh1/xdaforums huggingface dataset:
[Nexus One Android Development] Dankenstein:
Annoyed. aLogcat logs are good, but keep stopping and erasing the old logs for some reason. And I can't find any setting that looks like it will make it continue logging, or keep a longer log.

Glad I found that widget.
[Nexus One Android Development] Dankenstein:
Just threw in a fresh battery at 100% (charged amply on a wall battery charger) -- battery info from settings says 4178mV.

edit: Hilarious. So, I wait about 1/2 hour after reboot (when I swapped the batteries), and the phone (mostly on standby) still says 100% charged. I thought this a bit strange (optimistic) and plugged it into a USB charger. dropped to 97% charge instantly, but jumped to 4236 mV.

I won't even pretend to understand what's going on. But the good news is that I might succeed into getting my old man, a retired and very nerdy EE, to join xda and contribute, at least to this thread. The man is a Tesla groupie.
[Nexus One Android Development] RogerPodacter:
I'm not quite following, but it seems like you would be helped to find how to filter your dmesg or logcat log in OS monitor as well to find batt info. I've no idea what those errors mean. It at least is worth a shot at helping you. Check the last few pages of this thread for ways to try, and also maybe how to find out what battery your phone's using. Good luck.
[Nexus One Android Development] Dankenstein:
Cheers, RP. Will keep reading and searching.
[Nexus One Android Development] GldRush98:
My phone has just started shutting down at 10%. Pretty frustrating as it used to go down to 1%. Even more frustrating because I get the warning popup, then a few minutes later, it just shuts down. I don't even get the blinking red charge light any more.

There is definitely something wrong with the way Android or the Nexus One calculates battery levels.
[Nexus One Android Development] RogerPodacter:
Well we have a fix for that but we're still working out all the details. You need to perform a learn cycle but to do that its a little tricky at the moment. I've done a bunch of learn cycles at this point but its hard to do. If you sit tight a working fix will be around soon, we're working fast as we can!
[Nexus One Android Development] chowlala:
For the time being, keep an eye on the phone around 11-12%.

The minute you see the phone "powering off"... plug in the charger, let it power down, and then just let it charge, don't turn it on. Wait a couple of hours, 3-4 would be good. Then boot up, and the battery should be calibrated accordingly.

Weird fix.

But like Roger said, they're working on a better solution.

Time being, hopefully this will deal with it.
[Nexus One Android Development] RogerPodacter:
yes Chow basically has it down. your best shot right now is to do exactly what he said, the instant you see shutdown message plug in the charger and leave the phone off for the entire charge till full. basically inside all our batteries is a memory chip which stores all the parameters such as voltage, current, etc. and one of these is "age scalar" which is the age of the battery. all nexus ones are set to 94% for some reason. but when you perform a learn cycle, the memory chip charges a complete full charge, and whatever the new "full point" turns out to be, the chip re-calculates your age scalar and updates accordingly. my learn cycle determined 80% for my old battery, which isnt bad.

if you can watch closely in the dmesg log, at 3.4 volt is right around when shut down will happen.

so i guess i could give a little update. we managed to finally be able to read and write to the battery memory, but for now you need a custom mod to do it. i've experimented with setting my age scalar to 100% and other values. at 100 my full charge hits 1440 mAh.

I'm able to hit learn mode now close to every time and without the phone shutting off. and if i miss it i can just re-try after a few minutes of charging. performing learn mode will set your age to the exact value of your true capacity of your individual battery.

last week i tested setting the charge current to <=20mA which gives us a nice little bump at the top end. it basically gives us a "bump" charge as you would see with the device turned off during charging, except the device stays on. it adds about 50-75 of extra capacity to the battery at the top end (maybe a little less than that), and the voltage ends up being around 4.187 volts at full charge using this setting change. it does give a nice little bump of extra usable capacity. It adds about 30 extra minutes of charge time though, but It's worth it. I can now surf for about 45 minutes straight and still be at 95% or better.

we've also experimented with setting AE volt to different values other than stock 3.416 to practice hitting learn mode. its easier to hit learn mode with that value set much higher, but then you lose some capacity during the learn cycle. with it set to 3.416 you dont get as much warning time but you get the full range of capacity during the learn cycle.

next i may use my crap battery to test lowering the volt to maybe 3.3 volts and see if that can still power the device. if so then that gives us some extra capacity, but honestly since the voltage starts to drop very fast below 3.4 volts, i'm not sure how feasible that will really be in the long run.

quite a bit of progress has been made, but its still all custom but i think hopefully something can soon come out as soon as we work the details.
[Nexus One Android Development] chowlala:
Sounds great Roger! This will be great if we can hook it up to CM6! Will it work?
[Nexus One Android Development] RogerPodacter:
Yes I think the end result at some point could be to get it into cyanogen. Let's hope! :-)
[Nexus One Android Development] GldRush98:
Awesomeness. Subscribed to this thread. I wiped my batter stats from recovery last night hoping it would help something. Good luck and hope you can get something working well :)
[Nexus One Android Development] chowlala:
Hehe. Wiping battery stats doesn't help at all from what we've discovered. The battery stats are just history usages of the battery from apps, system, etc.
[Nexus One Android Development] theloginwithnoname:
Hi folks, sorry for prolonged absence from this thread - real life stuck its oar in big time!

Whilst I've been away, RP has been further writing/refining code to dump all registers, so one can look at a single grid of values and determine what a particular register is set to - as per Pre tools. dvgrhl's also been working on a GUI for the results. I'll update the other thread accordingly.

To paraphrase Ivana Trump "it is what it is" - lol. Referring back quite a few pages, I did some calculations on what we could expect for battery "age" as each month passes, assuming the battery ticked down as per the manufacturers specs.

From memory, the earliest N1 adopters should be about ~17% (down from 100% new) at the end of this month - i.e. 83% (1.67%/month I think). The battery manufacturer ships batteries with age set at 95% (presumably on the assumption a learn charge will be hit fairly regularly throughout the battery's life). Unfortunately, as RP states, the N1s have stayed around 94-95%

or if capacity gets below 80mAh twice. Mine seems to crap out with voltage, RPs more often goes on capacity.

and this alone is useful, because should battery age/capacity get re-set (i.e. through an off-charge when I tested a while back), you can simply manually set the previous age without having to do a learn mode again.

that's nice, I wasn't aware of that!

I ran it at/down to 3,280 but didn't get any more capacity out of it due to mAh determining cut-off - I think there's some sliding scales involved here, probably to protect the battery.

Yep, agreed. Unfortunately the guts of it are in the kernel so we need to work out the best way of distributing it...

more news as we get it, folks.
[Nexus One Android Development] Mactagonist:
Cant wait! :cool:
[Nexus One Android Development] RogerPodacter:
i should have mentioned this to you before but i forgot. to do all this i am writing the ACR register to hit learn mode, which lets you get right down to 3.416 volts. what happens is, if you only have like 50 mAh left, if that gets down to zero (or really AE mAh point) then that also will trigger the phone to shut off, even if your voltage is much higher.

so when i get down low, i just write ACR register. just echo the MSB with a 0x04 and that will bump you right up to around 400 mAh so your phone will suddenly jump to around 25% or so. but ignore that and keep watching the voltage and look for the status register to indicate learn mode is active.

there's more to it than that, but i cant get into it. but basically when the phone dies from low battery, the ACR starts back at zero for the charge to full.
[Nexus One Android Development] Dankenstein:
You guys are doing fantastic work.

The other day I flashed the reoriented I9000 kernel on top of my old JH7+SRE1.2.1a+OCLFv2+ just for the thrill. Shot in the dark trying to improve data speed and battery life in one stroke. Sound quality was awful -- assuming that it was less than perfect compatibility with the classic SRE version (which I still think is about as awesome as Eclaire gets, with OCLF).

IMMEDIATELY notice the battery charging all the way through the 80's and 90's to 100% totally normally, and with a seemingly regular curve. And it lasted about 50% to 75% longer. But, the sound sucked, and it is a phone, after all.

Anyway, there was a glitch at around 4%, when the circle battery jumped to zero and started flashing, while Quick Battery and, surprisingly, GPS Status app both had the "true" charge at 4% and both discharged through all values down to zero, to shutdown.

Something weird is going on, since some software can clearly read the battery charge properly, and I doubt either app is actually generating the information through direct battery sampling.

I had also flashed several of Fightspit's battery mods. By since I have the version A Black Bar running now on Cog 2.1.7, and it's draining fairly fast, though seemingly without any jumps . . . it looks like it was the kernel.

Will keep experimenting while I wait for a better solution from the xda b-boys.

Cheers for all the effort.
[Nexus One Android Development] RogerPodacter:
i have not seen the samsung batt driver so i dont know what's possible. but one thing we know is most drivers will spit out voltage, current, percent, etc files for other apps to use the batt info. the nexus spits these out once per minute, i bet the samsung and others are similar.

technically the same mods could be done to other phones, but so far we've only got this going for the nexus one. i think it would depend on which battery is used in your phone. i did dig into the HTC EVO driver weeks ago, but it was hard to do the same mods because it seems like HTC is hiding some things that are open in the nexus. i'm really not sure but it wasnt too clear where the batt info was coming from.

i guess if you see anymore weird behavior then post it.
[Nexus One Android Development] computerjunkie:
Hey Roger

I'm back from my training and will start up work on the Evo again. I'm still trying to catch up from all the missed work that I actually get paid for. Hope to contribute more to this effort.
[Nexus One Android Development] ksc6000:
Hi fellas,

I have absolutely no programming skills at all, so most of this thread is unintelligible for me.

But this post I'm quoting, isn't it bad for the battery to let the phone die?

-Kaser
[Nexus One Android Development] gravufo:
Technically, you're not letting it die, you're just letting it get til' 10% which is very fine and does not matter as to the battery life.

Then you plug it back in and charge it for a few hours and boot it back, it should then be calibrated...
[Nexus One Android Development] ksc6000:
Thanks.

How often can this and should this be done?
[Nexus One Android Development] GldRush98:
Hey guys, just wanted to report back that I believe I successfully performed a "learn mode" last night.

I followed your directions and plugged in the power the instant the powering off message popped up.

Yesterday morning, before the learn mode, when I unplugged I had 13xx mAh.

This morning, after the learn mode, OS Monitor is showing me 1257 mAh as soon as I unplugged!

So from what I have read, that indicates a successful learn mode with the "re-calibrated" battery info.

We'll see today/tonight how long the battery lasts, but I think this worked. I will post tonight or tomorrow if I can go below the 10% line now.

Thanks for the help and work you've do so far guys :)
[Nexus One Android Development] RogerPodacter:
letting the battery die a few times is not going to hurt anything. when they say its bad to let it die, they mean if you drain it fully week after week, then it weakens the battery life.
[Nexus One Android Development] RogerPodacter:
really you would only have to perform a learn mode once every few months. according to the data sheet and what nonamelogin posted earlier, we all probably lose something like 1.7% a month. so after a few months that is already probably 10% which is where people see the batt die early.
[Nexus One Android Development] RogerPodacter:
yeah that sounds like you re-calibrated for sure. did OS monitor show that charging had completed? the only thing that sucks is sometimes the learn mode gets reset. but its easy to set back hopefully soon...
[Nexus One Android Development] GldRush98:
I unplugged before booting up, but the green light was on, and it had been plugged in over night.

Right now I am posting from my phone, 8% showing on the ole battery meter. That did the trick for sure. :)
[Nexus One Android Development] chowlala:
Congrats dudes!!!

Saw the merge with pershoot's latest kernel!!!

-merged in RogerPodactor’s/loginwithnoname’s latest additions to the ds2784 battery driver – http://xdaforums.com/showthread.php?t=702167
[Nexus One Android Development] RogerPodacter:
You got it man, all our hard work paid off. We are working on an app to go with the changes, but till that is ready, those of you who want to correct anything manually I can help with that. Maybe we should setup a new thread for that...
[Nexus One Android Development] Markdental:
what exactly did pershoot include based on you guys? What does the driver do?
[Nexus One Android Development] RogerPodacter:
basically you now have access to the battery's internal EEPROM chip and can read/write to the registers in the battery. if you guys flash his kernel, check under sys/devices/platform/ds2784-battery/ and you will see a few new files which lets you do all this.

so related to this thread, you can set your battery's age, or try to hit learn mode which will stop your battery from turning of early like 10%.

you can also set your charge current like we did a while back. now you can just set it the proper way in the register.

all of it means you can tweak your battery, squeeze more capacity out of the top end and stuff like that.

so check in the battery folder, you will see:

setreg

dumpreg

statusreg

setage

setAEvolt

etc

i'll make a post soon of some common commands you guys might wanna do, like set your age to 100%. just open setreg file and type "0x14 80" and save the file. that will set your age and bump you up to 1440mAh at full charge.

you could also do the same thing in terminal. just navigate to the battery folder, and type:

echo 0x14 80 > setreg

and that will do the same exact thing. i find root explorer easier.

i'll help out more soon with some other userful tweaks/commands that you guys may want.
[Nexus One Android Development] Markdental:
Great post. How do you use root explorer to run that command?
[Nexus One Android Development] apratomo:
do we need to reboot after applied that setreg value?

edit: I did 'echo 0x14 80 > setreg' but nothing happened, I can't cat setreg
[Nexus One Android Development] instigator008:
os monitor does not seem to be giving out all the info with pershoot's kernel, even with the "batt" dmesg filter. Am I missing a setting?
[Nexus One Android Development] instigator008:
Worked using root explorer for me.
[Nexus One Android Development] Markdental:
Can you describe what you did exactly?
[Nexus One Android Development] instigator008:
No need to reboot.
[Nexus One Android Development] Markdental:
What about the setage command. Mine says 94 when I open it. What should I set it too?
[Nexus One Android Development] RogerPodacter:
right you just use root explorer, long press the setreg file, open in text editor. then just type "0x14 80" and then press menu, save.

to check your value, in the dumpreg file you will see all register addresses. row 10, the 5th value is the age register. its address 0x14 starting from 10, 11, etc.

all the registers are in hex format, and each register has a conversion equation. so for the age reg it is:

(X/128)*100 = age scalar.

that must be converted to hex to be entered into the register. so if you want 100% we have:

100% = (X/128)*100, so X = 128.

convert 128 to hex, and you get 0x80.
[Nexus One Android Development] RogerPodacter:
do you mean all the extra parameters we added to the dmesg log a while back? yeah we took that out but i guess we could have left that in. to see any register value you can now just open the dumpreg file, and that gives a list of every register value. but they are all hex numbers, need to be converted. so i can type up a list of some of the useful ones.

each row is a group of memory address. so row 60 is

60: 60, 61, 62, ... 69, 6a, 6b, 6c, 6d, 6e, etc

so the age register is 0x14, so

10: 08 1f 8e a0

80

80 xx xx xx xx etc

that is your age. all nexus one batteries are set to 94% out of the box for some reason. for now you can change it to 100%. but eventually you want to perform a learn cycle which will update your age value to the proper capacity of your battery.
[Nexus One Android Development] Markdental:
So running the setreg changed the setage to 100. Interesting. How do you run a learn cycle?
[Nexus One Android Development] RogerPodacter:
well its explained earlier in this thread when we first discovered it. but to do a learn cycle, you have to read the status register, and when bit 4 changes from a 0 to 1, that means the battery has entered learn mode and you must plug in immediately to start the cycle.

you then leave the phone fully charge, the learn flag, bit 4, will change back to 0, and you completed a learn cycle. and the battery will update your age with a new value from the learn cycle.

the status register is:

0001 0000

so its difficult to do but we are working on an app to assist. if you want to try manually, the learn flag gets set at exactly 3.416 volts. so you have to drain down to that. and its hard because shut down will happen very soon after, sometimes only a few seconds, so you have to be quick!
[Nexus One Android Development] ellesshoo:
awesome work fellas. I'm obsessed with battery life for whatever reason and I'm impressed with all the work you guys put in and the perseverance!

I flashed pershoot's kernel with the merge and did the thing to setreg that you instructed, Roger. I think it worked.

I charged up my oem battery and according to OS monitor it fully charged to 1480 mAh. Does that sound right? Before I was only able to get to 137XmAh.

Now I have one question. Why would the chip normally age the battery and prevent charging to this level when it's physically possible? If months from now I set the age back to 100% will it charge back up to this level? Is it dangerous to do so or will the physics of the cell simply prevent it? I was under the impression that the controller chip was kind of the last line of defense preventing the cells from being damaged etc so now that we're messing with it are we just asking for the oft heard of exploding Li battery issue?

Also, any idea what would happen if I did this to a 1600mAh and 3200mAh Seidio battery?
[Nexus One Android Development] ellesshoo:
Also, if my batteries have always gone down to 1% before dying is there any reason for me to bother with this "learning mode"? I don't really understand the learning mode vs the battery stats the phone keeps anyway to determine the % left.
[Nexus One Android Development] RogerPodacter:
OK i should explain to you and the other guys who are setting your age value to 100%. you are not getting more usable capacity at the moment by changing your age value. yes there ARE registers we can change to get more capacity, but we still need to test those more and i'm not gonna post them just yet. the age is a rather harmless thing to change.

the equation used to determin your percentage meter is:

(current - Empty*Full40) / AGE*(Full - Empty*Full40)

so the age value is used in there. so when you adjust your age value, you are adjusting the percentage meter as reported. but you are not actually changing capacity per se, unless you happen to have a really new and good battery. basically setting age to 100% is the theoretical maximum you could have gotten with your battery. its likely much lower as its gotten older. but as a fun to do type thing some people set to 100% for now.

NOTE: those who set your age to 100%, you may have the battery die a little early now, like 10% or so. it all depends on the true age of your battery. the whole point really is to do the learn cycle and correct your age value. since nexus one batteries are defaulted to 94% for age, its just a nice to do to set it to 100% FOR NOW. but really you will want to perform a learn cycle and that will update your age to the correct value for your batt.

soon we can maybe set some more register values that will make more of a difference.

ellesshoo, can you open up your dumpreg file, and post what you see on row 60? or easier, just open up the getfull40 file and post your number. this is for your aftermarket batteries. this will tell you if they are correct or not.
[Nexus One Android Development] RogerPodacter:
no you really dont need to do a learn cycle if you have no problems. the learn cycle fixes people where it dies early. but changing your age to 100% could make it die early, depending on if your battery is really strong and new, or older and has lost some capacity.

anyone who wants to set their age back to stock value of 94%, here is the command:

echo 0x14 79 > setreg

or just type in root explorer 0x14 79 and save it. that sets you right back to stock value.

Take a look at your percentage meter as you adjust age and you will see the percent adjust itself accordingly.
[Nexus One Android Development] ellesshoo:
ahh man, and here I thought I just increased my battery capacity with a simple text string :) At work now so I won't be able to check the aftermarket battery things until I get home.