maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Nokia N900 (https://talk.maemo.org/forumdisplay.php?f=44)
-   -   RX-51 BME Replacement (https://talk.maemo.org/showthread.php?t=93183)

pali 2014-05-14 09:12

RX-51 BME Replacement
 
After long time I'm announcing BME Replacement project for testing.

This project aims to replace Nokia proprietary closed source software BME which is used for Battery Management on Nokia N900 in Maemo 5 system. It is responsible for charging battery, broadcasting battery status to maemo applications, reporting battery health status, capacity, temperature, charge time, ...

Project is divided into 4 parts:

1. kernel drivers: isp1704_charger, bq2415x_charger, bq27x00_battery, rx51_battery

2. userspace daemon hald-addon-bme which exporting battery and charger information to HAL, checking health status and setting correct LED charging patterns

3. usbmode script & GUI for switching between USB peripheral & host mode

4. maemo compatiblity scripts & libraries:

* fake libbmeipc library which has same interface as closed Nokia library but implemented functions use above new kernel drivers (instead direct RAW i2c access)

* dsme-thermalobject-surface plugin which reading battery temperature from new kernel drivers

* bme-rx-51 upstart script for loading kernel drivers


Kernel drivers are included in upstream linux kernel (version 3.14) and also backported to maemo kernel-power (v52).

Package usbmode for switching between peripheral & host mode is in Maemo Extras repository and thread for discussion here.

Userspace daemons, libraries and scripts are in packages in new bme-replacement repository:

deb http://maemo.merlin1991.at/cssu/bme-replacement/ fremantle free

If you want to test new bme replacement project on top of Maemo 5, you can do it at your own risk. You must have installed kernel-power v52 and after that you can add above apt repository to system. Basic apt-get upgrade should update all packages.

Please note that packages from bme-replacement repository replacing system Maemo packages! And this can cause breaking Maemo system or make it unbootable.

Also using bme replacement kernel or userspace packages could damage battery or phone. Battery Management is critical part of SW and HW! You are using it at your own risk!

Source code is on gitorious: https://gitorious.org/rx51-bme-replacement

Just to note: I'm using it for more than year and I have no problem.

biketool 2014-05-14 13:03

Re: RX-51 BME Replacement
 
This is great, good work Pali for building OSS BME replacement and for USB mode.

Since you are intimate with the system I wonder if the following are possible in software.

One improvement in the charging system itself would be to have a timed reset or renegotiate of the charging every few minutes for the users who use bicycle dynamos, solar chargers, maybe even home mains chargers when they experience a brownout.
When there is an interruption in charging the N900 will dial back the amps(charging rate) to keep voltage from dropping and even when power is restored like the sun comes out of the clouds or a cyclist hits a downhill the low charge rate is maintained. Cases like this where there might only be one or two sun breaks in an afternoon or ten minutes of downhill for every hour of mountain climb in a long bike tour mean that the N900 user has to remember to unplug and replug when incoming power will be high, otherwise they miss out on that vital charging opportunity. If not standard perhaps having an "unreliable power" option in USB mode which resets charging every few minutes if below a determined charge rate.

Another improvement is if possible to free the charging from requiring the shorted data leads, this might not be ideal for a smart charging system, if so requiring a change in config file would be reasonable. Users who for example have ripped out their USB port or installed an inductive charging system need to also install a battery charge manager board and solder directly to battery connectors rather that using the very nice charge management system internal to the N900,fitting the Li-po manager is tricky with a regular cover and even with a double battery/mugen cover. It would be great to run one wire to a ground and the other to the positive USB pad and actually see my charging, one hack used was to actually solder a switch across the secondary data pads int he battery area, this is a crude hack since it requires removing the battery to switch to normal USB operation.

Kossuth 2014-05-15 16:32

Re: RX-51 BME Replacement
 
It seems that the behavior with the new BME is still the same as reported in the old BME replacement thread http://talk.maemo.org/showpost.php?p...2&postcount=17. Is there something I can check where the problem migt lie in my system.

So basically my phone shows three levels for battery: full, 50% or low. And basically they fluctuate between the half and low depending on how much current I draw from the battery. Also when charging, the applet shows no data or battery not calibrated.

pali 2014-05-15 17:53

Re: RX-51 BME Replacement
 
@Kossuth: this means your battery is not caliberated. Fully discharge it, then it charge to full and discharge again.

Kossuth 2014-05-15 18:46

Re: RX-51 BME Replacement
 
I will do the full calibration routine when I have spare time in my hands for it. Is it really neccessary to have calibrated battery to use the new BME, because I frequently change batteries (3 separate), and the Nokia BME worked reasonable (not perfectly) with the info it got from the batterys capacity resistor? It also showed the battery status when charging.

pali 2014-05-15 18:56

Re: RX-51 BME Replacement
 
yes it is needed. bme replacement reading all values from hw chips registers and you need to "calibrate" chip to work...

handaxe 2014-05-15 23:26

Re: RX-51 BME Replacement
 
Quote:

Originally Posted by pali (Post 1425503)
@Kossuth: this means your battery is not caliberated. Fully discharge it, then it charge to full and discharge again.

I recall somewhere you wrote that one should wait a few hours between a discharge and the recharge. You don't mention that here. Am I mistaken, and if not, what was the rationale?

Also, do you recommend leaving then phone unused towards the end of battery life for a gentle full-discharge, or a normal-type use until lights-out?

Are the bme replacement files you put in the "merlin" repo any different to those you had on your own server?

Kossuth 2014-05-16 04:23

Re: RX-51 BME Replacement
 
What comes to light use towards the end of the battery, at least in my case it is required, because if I load the phone too much when the battery is almost empty (over 200mA current, WLAN, GPS, Screen up, etc.) the device shuts down before the bq27200.sh 5 reports the EDV1 bit changing from 0 to 1, which is required for calibration.

The battery voltage has to remain between 3248mV and 3198mV for 15secs for the EDV1 bit change to 1, and if it drops below 3198mV too quickly, the device shuts down before correct calibration. This info from Estels guide.

Edit: It's around 3300mV that the drop becomes fast, so at that point I shut down the gps and screen. Wlan was changed to GPRS at 3350mV, because GPRS connection at start draws a lot (600mA) so it could empty the battery too quickly if done too late. Of course change to offline mode could be done later.

nokiabot 2014-05-16 05:15

Re: RX-51 BME Replacement
 
Can bme help on something here ??? http://talk.maemo.org/showthread.php...0&goto=newpost

Kossuth 2014-05-16 05:46

Re: RX-51 BME Replacement
 
So far I've only charged to full and discharged once, but already I'm seeing info while charging. I'll charge the battery to full and see how the gauge works now.

It is strange that the Applet informed me about the missing calibration only when charging, and not during normal usage. I thought I've done calibration with this phone, but it might have been my previous machine that suffered the fate of the dreaded usb port coming loose.

handaxe 2014-05-16 15:41

Re: RX-51 BME Replacement
 
Quote:

Originally Posted by Kossuth (Post 1425561)
This info from Estels guide.

Thanks. That's the procedure I follow since I used that thread from when that illustrious work was done. I wondered whether the requirement remained under the new bme; I think it will.

chill 2014-05-27 19:20

Re: RX-51 BME Replacement
 
Perhaps it would be beneficial to make the first post a bit more verbose, as it's the intro to the software. More specifically, why would one want to install the BME replacement, other than to help test it? What's the value of it being open source to a non-power user? Is it possible to remove it and how? What about the wiki page? Thanks.

biketool 2014-07-03 17:49

Re: RX-51 BME Replacement
 
Probably did something wrong, I installed the repo and did apt-get upgrade, now the power monitor applet shows starting APMD without changing.
(edit, dont have time now to play with this so ran a backup)

Raimu 2014-07-09 12:34

Re: RX-51 BME Replacement
 
After I moved to BMEreplacement, sometimes when I charge the battery full nowadays, the green "full" led light gets stuck somehow so that even after I remove the charger cord, if I set the screen off the green led returns. Is it something others experience and if so. is there a quick fix for this?

pali 2014-07-09 12:35

Re: RX-51 BME Replacement
 
I know about this bug and I did not fix it yet

biketool 2014-07-09 13:51

Re: RX-51 BME Replacement
 
To clarify just install the repos form first post and apt-get upgrade?
anything else?

pali 2014-07-09 14:05

Re: RX-51 BME Replacement
 
@biketool: install and boot needed kernel, add repository and do apt-get update, upgrade...

Estel 2014-07-09 20:31

Re: RX-51 BME Replacement
 
I have noticed that with latest version of battery applet from cssu-devel, the problem with gibberish being reported as battery's max capacity is gone *if* one perform full battery charge cycle *after* reinstalling all bme-replacement stuff. This si the case even *if* you had chip calibrated properly before and "need calibration" flag is *not* set.

I don't know why it's like that, but, anyway, it mean that there doesn't seem to be any reason to use old kerio-forked version anymore. Even the gconf setting for ignoring "design capacity" seems to work now.

/Estel

// Edit

I tried to comment about it in appropriate bug on bugs.maemo.org, but it seems to be falling apart just like rest of Maemo's infra (aka it's completely not working).

Raimu 2014-07-09 20:46

Re: RX-51 BME Replacement
 
Estel, I noticed this too!

Estel 2014-07-11 07:27

Re: RX-51 BME Replacement
 
Well, it seems that I was too optimistic about announcing that latest battery applet works well, and can, finally, replace custom modified 1.03 version :(

While it indeed does report battery current and maximum capacity, it doesn't update battery level graphical indication in status area or status menu - at all. Everything presented via text (percentage, charge, time left) is OK, but battery icon is always full.

What's worse, there is NO indication of low batter either, which means that, upon reaching shutdown level, you have full battery icon in one second, and "charge your battery" notification on next one, followed by device shutting down, abruptly.

If it's of any importance, I'm using the ignore design capacity gconf setting. /Edit - tested with gconf value set to 1 (use design capacity when uncalibrated) and 2 (always use design), and it's the same.

/Estel

Estel 2014-07-11 22:40

Re: RX-51 BME Replacement
 
I think I know whats the problem is about. Battery icon *does* starts upgrading, but only after capacity drops below "design", and only in relation to that "design" capacity.

So, for example, if one have 1700 mAh relative capacity, and design is reported (via resistor) as 1000 mAh, battery icon will show full all the time until capacity drops below 1000 mAh, even if rest of the applet report everything (percentage, charge, capacity current and max) correctly. Then, at 500/1700 mAh, battery icon will show half the battery full (500/1000 mAh, took from design), etc.

Everything written above is unrelated to gconf entry about using design capacity - it seems that bug about using design as max capacity for calculating what icon to show is hardcoded somewhere else in the applet.

/Estel

impeham 2014-08-16 20:24

Re: RX-51 BME Replacement
 
i've noticed that "i2cget" util does not seem to work anymore. i get this error message:

"Could not set address to 0x55: Device or resource busy"

for "/usr/bin/i2cget -y 2 0x55 0x06 w" for example.

Is this related to calibration?

pali 2014-08-16 20:33

Re: RX-51 BME Replacement
 
Use i2cget -f. It is safe for bq chips when using bq linux kernel drivers.

It is because kernel drivers bind to bq i2c chips.

Estel 2014-08-16 22:31

Re: RX-51 BME Replacement
 
pali, any progress on:
http://talk.maemo.org/showpost.php?p...0&postcount=21

...? It seems that issue is quite clearly manifested, and it's quite irritating bug, to say at least. No pressure, all understanding - just wondering, how things are looking.

/Estel

pali 2014-08-17 07:26

Re: RX-51 BME Replacement
 
Estel, sorry but I did not have time yet... If somebody else have some free time try to hack...

biketool 2014-08-17 08:54

Re: RX-51 BME Replacement
 
I will have time to do this again and deal with any possible negative consequences in a few days, just to be sure though...
1-install(or have) up to date Kernel Power
2-add repo
3-apt-get update and upgrade
4-profit
Missing anything?

Estel 2014-08-19 22:42

Re: RX-51 BME Replacement
 
4. Be sure, that you have cssu-testing installed - or at least new battery applet and it's dependencies from cssu-testing repo.

5.
Code:

gconftool-2 -s -t int /apps/osso/status-area-applet-battery/use_design_capacity 0
Saves lot of frustration with getting completely BS values posing as correct, when battery gauge is not calibrated (at all 0 like, lost calibration data due to battery out of device for too long and dead bupbat).

6. Reboot :D

7. profit

/Estel

biketool 2014-08-20 10:18

Re: RX-51 BME Replacement
 
Quote:

Originally Posted by Estel (Post 1436323)
4. Be sure, that you have cssu-testing installed - or at least new battery applet and it's dependencies from cssu-testing repo.

I assume that thumb unstable will have everything I need. About CSSU=testing
I bet scrip will really help with double-scud.
edit...
Cool, it installed good this time, works. Is there a man page for the new features?

biketool 2014-08-23 18:06

Re: RX-51 BME Replacement
 
I will put the instructions to install BME replacement in the Qi how-to just need the command to enable both temporary and permanent to use unshorted data lines USB for charging.

Estel 2014-08-23 21:40

Re: RX-51 BME Replacement
 
Code:

echo dedicated /sys/class/power_supply/bq24150a-0/mode
Not sure what you mean by "temporary and permanent". This one sticks until reboot (to be precise, until module's load/unload, I think). If you want it permanent, you can put a script doing it in /etc/event.d/, but you wouldn't be able to connect to PC (or hostmode, or USB Networking, or...).

/Estel

biketool 2014-08-24 07:45

Re: RX-51 BME Replacement
 
Quote:

Originally Posted by Estel (Post 1436696)
Code:

echo dedicated /sys/class/power_supply/bq24150a-0/mode
Not swure what you mean by "temporary and permanent". This one sticks until reboot (to be precise, until module's load/unload, I think). If you want it permanent, you can put a script doing it in /etc/event.d/, but you wouldn't be able to connect to PC (or hostmode, or USB Networking, or...).

/Estel

OK, I see what you mean, I have some toggle scripts up over on the Qi thread.

Kossuth 2014-10-03 07:49

Re: RX-51 BME Replacement
 
Strange thing happened for my N900 few days ago. Somehow my batterys calibration info was lost and now the battery status show only 100% when on idle, 50% with normal usage and red 0% when under heavy use. This is exactly same behavior as when I started to use the BME Replacement and it was corrected after I calibrated my battery as Pali suggested in this thread.

Now it seems that my system lost the calibration info and treats my battery as uncalibrated. Ofcourse the fix for this would be to calibrate the battery again, but it requires some work to ensure that the battery drains slowly enough at the end and only then it is connected back to charger.

I would like to know is the any mechanism in the BME replacement that caused the calibration to be erased, so I could avoid it in the future. I'd like to know if it is possible to save calibrations and possibly overwrite them manually (I have couple of spare batteries, that I could calibrate and switch to the phone and update the calibration info manually, without doing the calibration routine).

handaxe 2014-10-03 13:44

Re: RX-51 BME Replacement
 
Quote:

Originally Posted by Kossuth (Post 1441678)
I would like to know is the any mechanism in the BME replacement that caused the calibration to be erased, so I could avoid it in the future. I'd like to know if it is possible to save calibrations and possibly overwrite them manually (I have couple of spare batteries, that I could calibrate and switch to the phone and update the calibration info manually, without doing the calibration routine).

I write only to confirm that this has happened to me. I am still trying to see if it is some or other sequence ... annoying.

Estel 2014-10-03 23:24

Re: RX-51 BME Replacement
 
Quote:

Originally Posted by Kossuth (Post 1441678)
but it requires some work to ensure that the battery drains slowly enough at the end and only then it is connected back to charger.

Or just charge it to full, disconnect (VDC 1, check with BNF when in doubt), then just use it normally, and let it turn itself off due to low power. It will shutdown safely, and get calibrated just before.

Quote:

Originally Posted by Kossuth (Post 1441678)
I would like to know is the any mechanism in the BME replacement that caused the calibration to be erased

BME replacement or not, the chip mark itself as "uncalibrated" after 32 charging cycles without calibration. Again, you can check that with BNF ("Calibration required" flag).

/Estel

Kossuth 2014-10-04 06:28

Re: RX-51 BME Replacement
 
The problem is, if I let the phone just run out of juice, it happens most likely in the middle of the night, so I wont be getting wakeup alarm in the morning and have completely dead battery to start the day with. And if it happens during work day, I'd have to leave my phone charging at my desk an therefor be out of reach some part of my day.

It is curious that the battery calibration flag gets reset after 32 cycles (indeed I now have 33 cycles, so thet is what killed the info), because i've been using the same calibration data for 5 months, and I charge my phone every night, so it should have 150 cycles. Does anyone know what these full cycles consist of, so I can try to avoid them, I'm sure the battery has not reached EDV0 33 times in 5 months.

foobar 2014-10-04 11:46

Re: RX-51 BME Replacement
 
I have finally found the 'courage' to install the BME replacement.

I haven't tested it much at all, but the first thing that I noticed after installation was this:

My current N900 has recently shown signs of USB dysfunction. That is, it wouldn't charge nor let me establish a USB data connection.
It did, however, charge when using one of the various 'charge21' scripts floating around here on TMO.

Now, with the BME replacement installed, it charges again without such script, even from a battery bank, which previously didn't work out of the box either (only with a charge script).

Thanks pali!

malfunctioning 2014-10-13 18:27

Re: RX-51 BME Replacement
 
I know I'm obsessed with this question, so bear with me.

Since my battery charges in 3 hours or less and I can't deplete the battery in less than 4 hours even if I try, it would seem that it should be possible to run the N900 on AC power alone without battery.

Could this be possible in a future version of your bme, pali? In the case of the Zaurus SL-C1000 (a Linux PDA from a few years ago), you could do this as long as the distro allowed it and you didn't overcharge the system by mounting the CF slot.

Maybe enable this functionality by limiting screen brightness and locking CPU to 600Mhz maximum?

The N900 deserves to be future proof in this regard.

Estel 2014-10-13 19:51

Re: RX-51 BME Replacement
 
Quote:

Originally Posted by Kossuth (Post 1441808)
The problem is, if I let the phone just run out of juice, it happens most likely in the middle of the night, so I wont be getting wakeup alarm in the morning

I know it might not be for everyone, but getting dual-cell battery is easy way to solve it. I charge my device once few days (3 or more) thanks to 3Ah behemot. The difference from 1,3 Ah is astonishing, in practice.

Quote:

Originally Posted by foobar (Post 1441826)
It did, however, charge when using one of the various 'charge21' scripts floating around here on TMO.

It's because BME replacement does the same thing as those scripts did, just implement it in kernel module level instead of userspace scripts and adds things like shutting down just after edv ;) Not to mention battery applet, that takes information from sysfs nodes created by said modules.

As for charging method from charging chip's point of view, it's exactly the same thing, though.

Quote:

Originally Posted by malfunctioning (Post 1442828)
it should be possible to run the N900 on AC power alone without battery.

Could this be possible in a future version of your bme, pali?

Not possible hardware wise. The only thing you could achieve it, is to get a power source giving stabilized voltage in between 3.3V-4.2V range, and hook it up to battery pads.

The only way you can achieve it without such mods, is by shutting down all radios, turning brightness to minimum, etc. Basically, you can't use more than ~ 50 mA, and was usable only in battery hotswap proof-of-concept (which was just that - PoF - as it was more convenient to shut device down for swapping, anyway).

/Estel

alexporta 2014-10-13 20:00

Re: RX-51 BME Replacement
 
I try also here, sorry for the cross posting

hi to all
I'm testing the BME replacing from Pali. Great work!
But I have a BIG problem. I use a wall charger with 4 batteries. So when I change a battery the one I insert is not calibrated and I have 0/0.
Can I revert to original or old or CSSU BME? If I try to use the stok one (the link given above) it says is not existing

Thanks in advance

malfunctioning 2014-10-13 23:00

Re: RX-51 BME Replacement
 
Quote:

Originally Posted by Estel (Post 1442838)
Not possible hardware wise. The only thing you could achieve it, is to get a power source giving stabilized voltage in between 3.3V-4.2V range, and hook it up to battery pads.

The only way you can achieve it without such mods, is by shutting down all radios, turning brightness to minimum, etc. Basically, you can't use more than ~ 50 mA, and was usable only in battery hotswap proof-of-concept (which was just that - PoF - as it was more convenient to shut device down for swapping, anyway).

/Estel

Thank you, Estel. I think we had this conversation before but I had forgotten there was a definite restriction due to hardware. Being naturally stubborn, I thought it would be possible due to the fact I wish it were. I will stop now though. :o

Hopefully the supply of batteries won't dry out! :)

For some reason I like running my hardware without batteries, including IBM/Lenovo Thinkpads and Zaurus SL-C1000.


All times are GMT. The time now is 01:30.

vBulletin® Version 3.8.8