Hi, I just installed postmarketOS on my Nexus5 (lg-hammerhead) with plasma-mobile.
When I booting into the system, after the plasma-mobile is loading I can see the battery is on 0% and the device shut down immediately. Even if the device plugged in. But the Fastboot mode works, so there is a power.
I think it's hard for me to investigate because the device went off immediately, and the computer no longer recognizes it in the fastboot mode, and this is my first time on the system.
Edited
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items 0
Show closed items
No child items are currently assigned. Use child items to break down this issue into smaller parts.
Linked items 0
Link issues together to show that they're related.
Learn more.
I think it's hard for me to investigate because the device went off immediately, and the computer no longer recognizes it in the fastboot mode, and this is my first time on the system.
The fastboot mode should not be affected by flashing postmarketOS to your device. Maybe the power is so empty, that it does not boot into that fastboot mode anymore? I also have a Nexus 5, and whenever the power is that low, there is just a red LED flashing when I try to turn it on. Then I put it on a wall-charger, until it tried to boot up.
Charging might be broken right now with postmarketOS for the Nexus 5. Looking at @masneyb's patches (which we are using), it should work with the kernel. Maybe we need to tweak the kernel config to make it work though.
The phone contains a micro USB port that can be used for charging the battery or in USB OTG mode so that other USB devices can be connected to the phone. The USB support requires the charger and gpio hogging patches listed on this page.
I suggest to charge the device up to 100% and then try again. If it does not work any other way, then use a wall charger, boot into fastboot, flash TWRP to the recovery partition, then boot into TWRP. At least there it should charge properly.
The upstream kernel has support for the charger (for USB), however the battery is not supported upstream yet to the best of my knowledge. I see this patch of opendata's however I am not sure if other pieces are needed on top of that: https://lore.kernel.org/patchwork/patch/950301/
I noticed a problem here as well. When I turn the device off and plug it in (or use Qi charger) I get what I think is the charging-sdl "app" (from serial adapater logs) running but I see console logs instead (probably my configuration). Regardless /sys/class/power_supply doesn't seem to have anything to indicate capacity percentage so maybe that patch @masneyb mentioned should be pulled in. I might try that.
I just flashed pmos with phosh five minutes ago, booting into recovery says my battery is at 89% but the phone kills itself if I try to boot, and it wakes up and tries to boot if I try to charge it powered off.
I just started to play pmos with my Nexus 5 a few weeks ago. I noticed that there is no battery support (MAX17048) in current kernels:
phone:~$ uname -aLinux phone 5.2.0 #2-postmarketos-qcom-msm8974 SMP PREEMPT Sat Nov 9 13:40:20 UTC armv7l Linuxphone:~$ batterycat: can't open '/capacity': No such file or directoryphone:~$ ls /sys/class/power_supply/bq24190-charger smbb-bif smbb-dcin smbb-usbinphone:~$ ls /sys/class/power_supply/smbb-bifcharge_type device power status technology uevent voltage_min_designcurrent_max health present subsystem type voltage_maxphone:~$ cat /sys/class/power_supply/smbb-bif/ueventPOWER_SUPPLY_NAME=smbb-bifPOWER_SUPPLY_STATUS=DischargingPOWER_SUPPLY_HEALTH=GoodPOWER_SUPPLY_PRESENT=1POWER_SUPPLY_CHARGE_TYPE=N/APOWER_SUPPLY_CURRENT_MAX=1000000POWER_SUPPLY_VOLTAGE_MAX=4200000POWER_SUPPLY_VOLTAGE_MIN_DESIGN=3000000POWER_SUPPLY_TECHNOLOGY=Li-ion
I will try to find a working patch for our battery.
@bakonyi.ferenc : I believe that this is the battery driver that's need for the Nexus 5: https://lore.kernel.org/patchwork/patch/437579/. It would be great if someone could clean up that driver and get it upstream.
I think the battery driver made by Vladimir Barinov was never included in the kernel in the past 7 years therefore it was not tested. What about using https://github.com/AICP/kernel_lge_hammerhead/blob/n7.1/drivers/power/max17048_battery.c which was used in kernels 3.4.x?
I started to play with it and I was able to compile it with some promising results.
/ # uname -aLinux (none) 5.5.0-rc1 #8 SMP PREEMPT Mon Jan 20 19:32:03 UTC 2020 armv7l Linux/ # ls -l /sys/class/power_supply/total 0lrwxrwxrwx 1 0 0 0 Jan 5 16:09 bq24190-charger -> ../../devices/platform/soc/f9923000.i2c/i2c-0/0-006b/power_supply/bq24190-chargerlrwxrwxrwx 1 0 0 0 Jan 5 16:09 max17048_battery -> ../../devices/platform/soc/f9923000.i2c/i2c-0/0-0036/power_supply/max17048_batterylrwxrwxrwx 1 0 0 0 Jan 5 16:09 smbb-bif -> ../../devices/platform/soc/fc4cf000.spmi/spmi-0/0-00/fc4cf000.spmi:pm8941@0:charger@1000/power_supply/smbb-biflrwxrwxrwx 1 0 0 0 Jan 5 16:09 smbb-dcin -> ../../devices/platform/soc/fc4cf000.spmi/spmi-0/0-00/fc4cf000.spmi:pm8941@0:charger@1000/power_supply/smbb-dcinlrwxrwxrwx 1 0 0 0 Jan 5 16:09 smbb-usbin -> ../../devices/platform/soc/fc4cf000.spmi/spmi-0/0-00/fc4cf000.spmi:pm8941@0:charger@1000/power_supply/smbb-usbin/ # ls -l /sys/class/power_supply/max17048_battery/total 0-r--r--r-- 1 0 0 4096 Jan 5 16:09 capacity-r--r--r-- 1 0 0 4096 Jan 5 16:09 charge_full_design-r--r--r-- 1 0 0 4096 Jan 5 16:09 current_nowlrwxrwxrwx 1 0 0 0 Jan 5 16:09 device -> ../../../0-0036-r--r--r-- 1 0 0 4096 Jan 5 16:09 healthdrwxr-xr-x 3 0 0 0 Jan 5 16:09 hwmon1drwxr-xr-x 2 0 0 0 Jan 5 16:09 power-r--r--r-- 1 0 0 4096 Jan 5 16:09 present-r--r--r-- 1 0 0 4096 Jan 5 16:09 statuslrwxrwxrwx 1 0 0 0 Jan 5 16:09 subsystem -> ../../../../../../../../class/power_supply-r--r--r-- 1 0 0 4096 Jan 5 16:09 technology-r--r--r-- 1 0 0 4096 Jan 5 16:09 temp-r--r--r-- 1 0 0 4096 Jan 5 16:09 type-rw-r--r-- 1 0 0 4096 Jan 5 16:09 uevent-r--r--r-- 1 0 0 4096 Jan 5 16:09 voltage_max_design-r--r--r-- 1 0 0 4096 Jan 5 16:09 voltage_min_design-r--r--r-- 1 0 0 4096 Jan 5 16:09 voltage_nowdrwxr-xr-x 2 0 0 0 Jan 5 16:09 wakeup2/ # cat /sys/class/power_supply/max17048_battery/ueventPOWER_SUPPLY_NAME=max17048_batteryPOWER_SUPPLY_STATUS=UnknownPOWER_SUPPLY_HEALTH=UnknownPOWER_SUPPLY_PRESENT=1POWER_SUPPLY_TECHNOLOGY=Li-ionPOWER_SUPPLY_VOLTAGE_MAX_DESIGN=4350000POWER_SUPPLY_VOLTAGE_MIN_DESIGN=3200000POWER_SUPPLY_VOLTAGE_NOW=4183000POWER_SUPPLY_TEMP=250POWER_SUPPLY_CAPACITY=89POWER_SUPPLY_CURRENT_NOW=0POWER_SUPPLY_CHARGE_FULL_DESIGN=2300/ # dmesg... snip ...[ 2.109104] max17048_probe: start[ 2.114940] ac supply not found deferring probe[ 2.118217] max17048_parse_dt: rcomp = 77 rcomp_co_hot = 700 rcomp_co_cold = 5225[ 2.118223] max17048_parse_dt: alert_thres = 2 full_soc = 970 empty_soc = 10 uvlo=3050[ 2.130697] max17048 0-0036: MAX17048 Fuel-Gauge Ver 0x12[ 2.138738] ------------[ cut here ]------------[ 2.143434] WARNING: CPU: 0 PID: 1 at drivers/base/core.c:1850 device_create_file+0xb8/0xbc[ 2.148143] Attribute fuelrst: read permission without 'show'[ 2.156175] Modules linked in:[ 2.162125] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.5.0-rc1 #5[ 2.165030] Hardware name: Generic DT based system[ 2.171213] [<c0312dc8>] (unwind_backtrace) from [<c030d6e4>] (show_stack+0x10/0x14)[ 2.175987] [<c030d6e4>] (show_stack) from [<c0c47be0>] (dump_stack+0x84/0x98)[ 2.183887] [<c0c47be0>] (dump_stack) from [<c032250c>] (__warn+0xd0/0xf8)[ 2.190910] [<c032250c>] (__warn) from [<c03228e8>] (warn_slowpath_fmt+0x98/0xc4)[ 2.197775] [<c03228e8>] (warn_slowpath_fmt) from [<c0855e2c>] (device_create_file+0xb8/0xbc)[ 2.205332] [<c0855e2c>] (device_create_file) from [<c0a00844>] (max17048_probe+0x5c8/0x86c)[ 2.213837] [<c0a00844>] (max17048_probe) from [<c09d4aec>] (i2c_device_probe+0x280/0x2b0)[ 2.222343] [<c09d4aec>] (i2c_device_probe) from [<c085c434>] (really_probe+0x24c/0x488)[ 2.230412] [<c085c434>] (really_probe) from [<c085c83c>] (driver_probe_device+0x78/0x1c4)[ 2.238657] [<c085c83c>] (driver_probe_device) from [<c085cbe8>] (device_driver_attach+0x58/0x60)[ 2.246731] [<c085cbe8>] (device_driver_attach) from [<c085cca4>] (__driver_attach+0xb4/0x154)[ 2.255671] [<c085cca4>] (__driver_attach) from [<c085a420>] (bus_for_each_dev+0x78/0xc0)[ 2.264177] [<c085a420>] (bus_for_each_dev) from [<c085b588>] (bus_add_driver+0x170/0x20c)[ 2.272425] [<c085b588>] (bus_add_driver) from [<c085d880>] (driver_register+0x7c/0x114)[ 2.280586] [<c085d880>] (driver_register) from [<c09d526c>] (i2c_register_driver+0x3c/0xac)[ 2.288835] [<c09d526c>] (i2c_register_driver) from [<c0302f70>] (do_one_initcall+0x58/0x2b0)[ 2.297257] [<c0302f70>] (do_one_initcall) from [<c1201074>] (kernel_init_freeable+0x150/0x1e8)[ 2.305674] [<c1201074>] (kernel_init_freeable) from [<c0c5fd1c>] (kernel_init+0x8/0x110)[ 2.314176] [<c0c5fd1c>] (kernel_init) from [<c03010e8>] (ret_from_fork+0x14/0x2c)[ 2.322503] Exception stack(0xee89bfb0 to 0xee89bff8)[ 2.329968] bfa0: 00000000 00000000 00000000 00000000[ 2.335106] bfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000[ 2.343262] bfe0: 00000000 00000000 00000000 00000000 00000013 00000000[ 2.351472] ---[ end trace f81f997b52958bef ]---[ 2.359633] max17048_probe: done[ 2.362721] max17048_get_prop_temp: batt temp is not supported![ 2.365898] max17048_get_prop_current: batt current is not supported![ 2.372156] qcom-smbb fc4cf000.spmi:pm8941@0:charger@1000: Initializing SMBB rev 3[ 2.374640] max17048_get_prop_temp: batt temp is not supported![ 2.383494] otg-vbus: supplied by 5vs1[ 2.385666] max17048_get_prop_current: batt current is not supported![ 2.396320] max17048_work: rsoc=0xAC57 rvcell=0x0D13 soc=88 v_mv=4183 i_ua=0 t=250[ 2.402322] max17048_get_prop_temp: batt temp is not supported![ 2.409258] max17048_get_prop_current: batt current is not supported!... snip ...
@bakonyi.ferenc : Thanks for starting to port that downstream driver. I am using the upstream qcom_defconfig, which doesn't have debugfs support, and causes this driver to fail loading. I believe they are working upstream to remove the return values from all of the debugfs functions since that should never cause a driver to fail. I applied this patch to my local tree: 0001-battery-wip.patch
When I boot into the text console, I see the nodes in /sys/class/power_supply/max17048_battery/. I noticed that when I unplug my charger (connection to my computer) that it takes a minute or so for it to go from the charging to discharging state. When I start X11 with XFCE4, it's very sluggish and I see timeout errors appear and the top menu bar never appears, but my terminal does. I don't have any more time this morning to look into this.
The device tree bindings in Documentation/devicetree/bindings/power/supply/bq24190.txt specifies a monitored-battery node that should be added to the charger node but I doubt that's the issue.
MAX17048 can measure the approximate charge or discharge rate (%/hours) of the battery but it updates very slowly with a noticable lag. Alternatively the fuel gauge driver can ask the charger about the charging status and relay that information. But there could be specific cases when the charger provides not enough current: the battery will discharge while the charger tries to charge it. I need advice how to handle this.
MAX17048_BATTERY driver is now able to report charge and follows discharge/recharge.
QCOM_BMS driver is able to report the charge at startup but fails after.
@symmetrist: qcom_bms is able to read battery temperature and I think it is used by more devices than max17048.
@baruchiro: I would suggest using max17048_battery by compiling a custom kernel using the git repo above. It works quite well for me. Feel free to contact me via matrix (@bakonyiferenc) if you need assistance.