libera/#maemo/ Friday, 2023-08-25

sicelohere's an interesting 'bug' on my bq27200: voltage is higher than both EVD1 and EVDF, yet both are set13:07
siceloi2cget -y -f 2 0x55 0x8 i 213:08
sicelo0xb2 0x0e13:08
sicelo# i2cget -y -f 2 0x55 0xa13:08
sicelo0x1313:09
sicelothat translates to 3762mV as measured by bq27200, so it isn't expected that EDV1 and EDVF flags (in register 02) are set13:10
sicelobackground info: the usb port is broken on this device, so i charge battery externally and swap.13:11
siceloi'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 flags13:13
siceloi find this really surprising, since i'd expect the value of these flags to always follow the voltage13:14
joergplease use bq27k-detail / bq27200.sh15:13
joergthe flags do _not_ "always strictly follow vltage", e.g. it needs a certain timespan of voltage < threshold until the flag gets set15:14
joergfor more details I'd need to read the datasheet15:14
joerghttps://termbin.com/z9xz15:16
joerghttps://termbin.com/ui6j15:19
joergsicelo: on theory you also need to check bq27200 EEPROM for >>0x77:       119 SEDVF Scaled EDVF Threshold //     0x78:       150 SEDV1 Scaled EDV1 Threshold <<15:39
siceloyes, that one's fixed, on all N900. it's 3248mV15:40
joergyou *could* reprogram it ;-)15:40
sicelotrue :p15:40
joergwell, probably you can't, but in theory... ;-D15:41
sicelobut i think you'd have to remove the chip from device, since reprogramming happens at >5v iirc15:41
joergyep15:41
siceloanyway, i did a partial reset of the chip, so the flags are correct now15:42
joergper spec it requires some (iirc) 9 or 10V Vpp, but *moght* also result in messed up EEPROM data when not applying that higher programming supply15:42
siceloit was just a big surprise to see the flags could be messed up like that.15:43
siceloi had made some claims on a upower patch, based on the expectation that the flags were always 'true'15:43
sicelothe 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 kernel15:46
sicelobut now with the state i was in, kernel always reported Critical, even though voltage was good15:46
joergthey 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 intended15:47
joergand I even less trust in 100% stability/reliability of kernel modules, particularly when battery gauge and charger is involved15:50
siceloyou mean i2cget as a specific program, or you mean reading stuff over i2c bus?15:50
joergI mean the stuff you cited above15:50
joerg i2cget -y -f 2 0x55 0x8 i 215:51
sicelook ... but the kernel is not using i2cget. in this case, kernel state corresponded with what i was getting from i2cget15:51
joergO too often failed to correctly calculate and decode all the values with mental arithmetic15:52
joergI15:52
joergsometimes bq27200 may get stale, more often there are collisions or locks on I2C bus...15:53
joergPali 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
siceloyou guys did great work15:59
siceloi remember those days - back then i was new to linux itself15:59
joergwhen 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 platform16:04
joergI mean, the script is from 2011, sysfs changed a bit since, I guess16:05
joergso not sure if ` dmppath=`find /sys/devices/ -path '*/hdq/*' -name dump` ` still applies on "modern kernels"16:06
joergneither ` dmpcmd="i2cdump -y 2 0x55 b|tail -n +2|cut -d ' ' -f 2-17" `16:06
siceloworks just fine (the latter)16:08
joergthen it should work ootb on your target platform16:09
siceloi guess the former would work too, but n900's bq27k is on i2c16:09
joergthe bq27k-detail2 that is16:09
sicelosure,16:10
joergbtw, 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 brownout16:16
joergfirst indication: I never seen those values getting reprogrammed by platform manufacturer, they always are at TI's chip fab defaults16:19
joergafaik16:19
sicelotrue16:22
sicelobut they seem to be the next best option if you don't have a valid capacity value16:22
joergKDE(?) powerdevil etc have a user setting "xx % battery triggers shutdown" OWTTE16:23
sicelowhich is a situation that happens a lot when n900 usb port is borked16:23
siceloalso, if you want to calibrate, then you absolutely must ensure you reach EVD1 and meet the other related conditions for calibration.16:24
joerghttps://i.imgur.com/1vcFFpG.jpg sorry, only desktop (mains powered) at hand, laptop offers more settings16:26
joerg>>you absolutely must ensure...<< which is what calibrate-bq27k2.sh is all about ;-)16:28
joerghttp://maemo.cloud-7.de/maemo5/patches_n_tools/calibrate-bq27k.sh16:31
joerghttps://termbin.com/xd0l16:36
siceloanother 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 at16:41
siceloe.g. on first calibration cycle, battery will report something like 1800mAh, then 1500mAh on next, etc. when perhaps your battery is really only 800mAh16:42
joergthat'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 set16:47
joergand ILMD Initial Last Measured Discharge   in EEPROM is usually at TI factory default 2062 mAh16:50
joergobviously bogus for both OM smartbat and N900 BL-5J16:50
joergEDV* btw, not EVD*16:55
joerg                 0 EDV1  First End-of-Discharge-Voltage flag. A 1 indicates that voltage < EDV116: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.1017: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 reset17:29
joergso, 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 correct17:30
joergfor system shutdown you regularly want to use other (twl4030 PMIC VSYS?) source of voltage-good/low detection17:33
joergalso note that in N900 the cellmo chipset seems to have a different Vlow cutout threshold than the OMAP17:34
joergdifferent = higher17:34
joergbq27200 EEPROM has EDV1=3248 mV, I *think* the cell modem bails iut at some 3.3x or even 3.4xV17:39
joergout*17:39

Generated by irclog2html.py 2.17.0 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!