sicelo | here's an interesting 'bug' on my bq27200: voltage is higher than both EVD1 and EVDF, yet both are set | 13:07 |
---|---|---|
sicelo | i2cget -y -f 2 0x55 0x8 i 2 | 13:08 |
sicelo | 0xb2 0x0e | 13:08 |
sicelo | # i2cget -y -f 2 0x55 0xa | 13:08 |
sicelo | 0x13 | 13:09 |
sicelo | that translates to 3762mV as measured by bq27200, so it isn't expected that EDV1 and EDVF flags (in register 02) are set | 13:10 |
sicelo | background info: the usb port is broken on this device, so i charge battery externally and swap. | 13:11 |
sicelo | i'd guess that bq saw a low voltage in the past, set the flags, and supposedly i changed to a fresh battery, so bq retained its data, including the then incorrect flags | 13:13 |
sicelo | i find this really surprising, since i'd expect the value of these flags to always follow the voltage | 13:14 |
joerg | please use bq27k-detail / bq27200.sh | 15:13 |
joerg | the flags do _not_ "always strictly follow vltage", e.g. it needs a certain timespan of voltage < threshold until the flag gets set | 15:14 |
joerg | for more details I'd need to read the datasheet | 15:14 |
joerg | https://termbin.com/z9xz | 15:16 |
joerg | https://termbin.com/ui6j | 15:19 |
joerg | sicelo: on theory you also need to check bq27200 EEPROM for >>0x77: 119 SEDVF Scaled EDVF Threshold // 0x78: 150 SEDV1 Scaled EDV1 Threshold << | 15:39 |
sicelo | yes, that one's fixed, on all N900. it's 3248mV | 15:40 |
joerg | you *could* reprogram it ;-) | 15:40 |
sicelo | true :p | 15:40 |
joerg | well, probably you can't, but in theory... ;-D | 15:41 |
sicelo | but i think you'd have to remove the chip from device, since reprogramming happens at >5v iirc | 15:41 |
joerg | yep | 15:41 |
sicelo | anyway, i did a partial reset of the chip, so the flags are correct now | 15:42 |
joerg | per spec it requires some (iirc) 9 or 10V Vpp, but *moght* also result in messed up EEPROM data when not applying that higher programming supply | 15:42 |
sicelo | it was just a big surprise to see the flags could be messed up like that. | 15:43 |
sicelo | i had made some claims on a upower patch, based on the expectation that the flags were always 'true' | 15:43 |
sicelo | the driver uses EDV1 to set capacity_level = Low, and EVDF to Critical ... so userspace can actually trigger safe poweroff based on capacity_level as reported by kernel | 15:46 |
sicelo | but now with the state i was in, kernel always reported Critical, even though voltage was good | 15:46 |
joerg | they probably are always true to the datasheet. T&he datasheet specifies their meaning and operation not that trivial EDV1 = (Vbat < SEDV1), there are timers etc involved to deglitch the flags. Plus I don't 100% trust "manual" (i2cget) readout, no offense intended | 15:47 |
joerg | and I even less trust in 100% stability/reliability of kernel modules, particularly when battery gauge and charger is involved | 15:50 |
sicelo | you mean i2cget as a specific program, or you mean reading stuff over i2c bus? | 15:50 |
joerg | I mean the stuff you cited above | 15:50 |
joerg | i2cget -y -f 2 0x55 0x8 i 2 | 15:51 |
sicelo | ok ... but the kernel is not using i2cget. in this case, kernel state corresponded with what i was getting from i2cget | 15:51 |
joerg | O too often failed to correctly calculate and decode all the values with mental arithmetic | 15:52 |
joerg | I | 15:52 |
joerg | sometimes bq27200 may get stale, more often there are collisions or locks on I2C bus... | 15:53 |
joerg | Pali and me had a lot of "fun" to beat the kernel modules into shape so they don't lock out each other mutually, particularly with the BQxxxx chips (I2C battery stuff) | 15:55 |
sicelo | you guys did great work | 15:59 |
sicelo | i remember those days - back then i was new to linux itself | 15:59 |
joerg | when you have i2cget available then you also can use bq27k-detail2, possibly providing as command parameter $1 the correct way to read out the chip's registers on your target platform | 16:04 |
joerg | I mean, the script is from 2011, sysfs changed a bit since, I guess | 16:05 |
joerg | so not sure if ` dmppath=`find /sys/devices/ -path '*/hdq/*' -name dump` ` still applies on "modern kernels" | 16:06 |
joerg | neither ` dmpcmd="i2cdump -y 2 0x55 b|tail -n +2|cut -d ' ' -f 2-17" ` | 16:06 |
sicelo | works just fine (the latter) | 16:08 |
joerg | then it should work ootb on your target platform | 16:09 |
sicelo | i guess the former would work too, but n900's bq27k is on i2c | 16:09 |
joerg | the bq27k-detail2 that is | 16:09 |
sicelo | sure, | 16:10 |
joerg | btw, EDV1 EDVF are not always good and stable values for triggering system shutdown. they are pretty arbitrary and particularly on older batteries they might trigger just 10s before the system goes brownout | 16:16 |
joerg | first indication: I never seen those values getting reprogrammed by platform manufacturer, they always are at TI's chip fab defaults | 16:19 |
joerg | afaik | 16:19 |
sicelo | true | 16:22 |
sicelo | but they seem to be the next best option if you don't have a valid capacity value | 16:22 |
joerg | KDE(?) powerdevil etc have a user setting "xx % battery triggers shutdown" OWTTE | 16:23 |
sicelo | which is a situation that happens a lot when n900 usb port is borked | 16:23 |
sicelo | also, if you want to calibrate, then you absolutely must ensure you reach EVD1 and meet the other related conditions for calibration. | 16:24 |
joerg | https://i.imgur.com/1vcFFpG.jpg sorry, only desktop (mains powered) at hand, laptop offers more settings | 16:26 |
joerg | >>you absolutely must ensure...<< which is what calibrate-bq27k2.sh is all about ;-) | 16:28 |
joerg | http://maemo.cloud-7.de/maemo5/patches_n_tools/calibrate-bq27k.sh | 16:31 |
joerg | https://termbin.com/xd0l | 16:36 |
sicelo | another reason i find EVD* slightly better for N900 is that the reported percentage can be somewhat reliable, depending on how many calibration cycles you're at | 16:41 |
sicelo | e.g. on first calibration cycle, battery will report something like 1800mAh, then 1500mAh on next, etc. when perhaps your battery is really only 800mAh | 16:42 |
joerg | that's because it adjusts only xx% (12%?) of LMD per calibration cycle, assuming battery can't change that massively in available capacity during the "CYCL Cycle Count Since Learning Cycle High-Low Byte " until CI gets set | 16:47 |
joerg | and ILMD Initial Last Measured Discharge in EEPROM is usually at TI factory default 2062 mAh | 16:50 |
joerg | obviously bogus for both OM smartbat and N900 BL-5J | 16:50 |
joerg | EDV* btw, not EVD* | 16:55 |
joerg | 0 EDV1 First End-of-Discharge-Voltage flag. A 1 indicates that voltage < EDV1 | 16:56 |
joerg | 0 EDVF Final End-of-Discharge-Voltage flag. A 1 indicates that the battery has discharged to the empty capacity threshold. | 16:56 |
joerg | >> The bqJUNIOR EDV detection is designed to prevent premature detection of the EDV thresholds due to dynamic load variations. EDV detection has a dynamically adjusted delay of up to 21.5 s with RSOC ≥ 6% and down to 3 s when RSOC = 0%.<< https://www.ti.com/lit/gpn/bq27000 p.10 | 17:23 |
joerg | >>The bqJUNIOR stores all calculated information in RAM, which is backed up by the voltage on the RBI input.<< which may get corrupted in noisy RBI not triggering a proper reset | 17:29 |
joerg | so, for R&D always use a full bq27k-detail readout and cursory check all values for plausibility. Do not assume bq27xxx flags or any values *always* being correct | 17:30 |
joerg | for system shutdown you regularly want to use other (twl4030 PMIC VSYS?) source of voltage-good/low detection | 17:33 |
joerg | also note that in N900 the cellmo chipset seems to have a different Vlow cutout threshold than the OMAP | 17:34 |
joerg | different = higher | 17:34 |
joerg | bq27200 EEPROM has EDV1=3248 mV, I *think* the cell modem bails iut at some 3.3x or even 3.4xV | 17:39 |
joerg | out* | 17:39 |
Generated by irclog2html.py 2.17.0 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!