Investigating the charging operations of the 5X - Nexus 5X Q&A, Help & Troubleshooting

Since the Google engineer Benson Leung is reviewing some USB Type-C to Type-A/B adapters and bringing the proper USB spec to our attention, I decided to investigate some of the things related to charging in the Nexus 5X.
Related posts:
http://forum.xda-developers.com/nexus-5x/accessories/google-engineer-reviewing-usb-type-c-t3241104
https://plus.google.com/+BensonLeung/posts/LH4PPgVrKVN
https://plus.google.com/+BensonLeung/posts/3Xf724K84HP
Here is the relevant dmesg of me plugging in an out-of-spec (10kΩ pullup) cable:
Code:
[59722.367419] __qpnpint_handle_irq: 1 triggered [0x2, 0x13,0x0] usbin-uv
[59722.542304] fusb301 5-0021: fusb301_work_handler: int_sts[0x05]
[59722.542899] fusb301 5-0021: sts[0x2f], type[0x08]
[59722.542909] fusb301 5-0021: fusb301_src_detected: FUSB_STATE_ATTACHED_SNK
[59723.370779] msm-dwc3 f9200000.ssusb: DWC3 exited from low power mode
[59723.513914] dwc3 f9200000.dwc3: Avail curr from USB = 3000
[59723.724676] android_work: android_work: sent uevent USB_STATE=CONNECTED
[59723.729421] android_work: android_work: sent uevent USB_STATE=DISCONNECTED
[59723.834497] android_work: android_work: sent uevent USB_STATE=CONNECTED
[59723.846230] android_usb gadget: high-speed config #1: fe80f0c8.android_usb
[59723.902145] android_work: android_work: sent uevent USB_STATE=CONFIGURED
Note the line that writes "Avail curr from USB = 3000". This line indicates that the USB controller detected the 10k pullup in the connector and configured the maximum available current is 3000mA (aka 3A).
On the lock screen, it says "charging rapidly".
In this case, `/sys/class/power_supply/usb/voltage_now` shows `4609780`, which indicates that the USB voltage detected on the device end is about 4.6V, which is 0.4V lower than 5V.. So, even though it is pulling 3A and luckily didn't fry the USB 3.0 port of my laptop, it probably won't charge as fast as the LG charger due to the huge voltage drop..
---
Here is the relevant dmesg of me plugging in another out-of-spec (10kΩ pullup) cable (which is noticeably thinner than the one before):
Code:
[59656.433560] __qpnpint_handle_irq: 1 triggered [0x2, 0x13,0x0] usbin-uv
[59656.644386] fusb301 5-0021: fusb301_work_handler: int_sts[0x05]
[59656.645294] fusb301 5-0021: sts[0x1f], type[0x08]
[59656.645313] fusb301 5-0021: fusb301_src_detected: FUSB_STATE_ATTACHED_SNK
[59657.426205] msm-dwc3 f9200000.ssusb: DWC3 exited from low power mode
[59657.573627] dwc3 f9200000.dwc3: Avail curr from USB = 3000
[59657.784381] android_work: android_work: sent uevent USB_STATE=CONNECTED
[59657.788909] android_work: android_work: sent uevent USB_STATE=DISCONNECTED
[59657.853872] SMBCHG: smbchg_update_input_max: update iusb = 500
[59657.895507] android_work: android_work: sent uevent USB_STATE=CONNECTED
[59657.907950] android_usb gadget: high-speed config #1: fe80f0c8.android_usb
[59657.962062] android_work: android_work: sent uevent USB_STATE=CONFIGURED
Now, this might seem similar to the previous one.
But notice the additional line "SMBCHG: smbchg_update_input_max: update iusb = 500". What does it mean? The lock screen also shows "charging slowly" at the same time.
Searching `smbchg_update_input_max` didn't yield any results.
Looking at the sysfs, I found this interesting entry `/sys/module/qpnp_smbcharger/parameters/smbchg_ibat_ocp_threshold_ua` which has the value `4500000`.
It appears to me that the driver `qpnp-smbcharger` is detecting the USB voltage, and if the voltage is below 4.5V it automatically changes the maximum USB input current to 500mA in order to keep the USB voltage within range. This slows down the charging by quite a lot, but at the same time it prevents the USB port/charger/battery pack from becoming a flaming toaster.
Relevant kernel source code: https://android.googlesource.com/ke...allow-dr/drivers/power/qpnp-smbcharger.c#3093
I am thinking that it may be possible to limit the USB input current (to 0.5 or 1.5A) by software, so that even if the USB cable is out of spec and doesn't follow the correct pullup arrangement, it can be used to charge the phone safely without exceeding the safe current limits.
How do you think?

Your theory sounds promising... I wonder if there is already code on the phone to do something similar? DO we have a documented case of a Nexus frying a charger yet? I know all of Benson's work to date has been with a Pixel which has a much higher demand for power as well as more restrictive requirements allowing a charge. Benson mentioned that he will soon be getting a Nexus to test with.

I know this is a total n00b question but I leave my phone plugged in most of the time when I'm at home--is this in any way bad for the battery?

Hey does anyone know why when I select charging sound on in the settings, there is no sound when charging the phone?

minnemike said:
Your theory sounds promising... I wonder if there is already code on the phone to do something similar? DO we have a documented case of a Nexus frying a charger yet? I know all of Benson's work to date has been with a Pixel which has a much higher demand for power as well as more restrictive requirements allowing a charge. Benson mentioned that he will soon be getting a Nexus to test with.
Click to expand...
Click to collapse
I think I've seen a few post about it frying car chargers before. I am not really bothered enough to look it up though.
In theory it can absolutely happen for chargers of low quality or those lacking protection circuits (read: cheap Chinese ones). In reality though, the voltage drop may already be enough to cause the phone to switch to 500mA max. charging current.
Regarding the code, I am not sure if there are any exposed sysfs interfaces or ioctl's that would allow setting the charging current directly. But it is pretty obvious that there is already code inside the kernel that can set it, just perhaps not controllable within userspace. It wouldn't be really difficult for someone to add a sysfs interface in custom kernels though.

Does anyone know if we're safe with any cable when N5X shows only charging slowly?
I would think N5X shows charging slowly when it requests current of 500mA so it shouldn't damage the charger no matter how old it is.
Is my assumption correct?

LR07 said:
Hey does anyone know why when I select charging sound on in the settings, there is no sound when charging the phone?
Click to expand...
Click to collapse
I have this setting configured as well and it does nothing, but this is perhaps better suited for another thread.

BinkXDA said:
I have this setting configured as well and it does nothing, but this is perhaps better suited for another thread.
Click to expand...
Click to collapse
I actually think that the sound is to notify you when your phone is low on battery. You know when your phone is a 15% it alerts you?

LR07 said:
I actually think that the sound is to notify you when your phone is low on battery. You know when your phone is a 15% it alerts you?
Click to expand...
Click to collapse
I turned off the setting and when my phone got to 15% it still made the alert sound. So maybe there should be a sound when charging your phone

Related

[Q] Charging Range

What's the charging range for the Xperia Arc?
The outlet wall plug output is 5V DC 850mA
I'm thinking about getting a external battery, though it's output is 1A-2A.
(TeckNet iEP390 Power Station)
Will this harm my phone, or will it charge my phone faster than the wall outlet?
May caused a very large heat due to ammount of power which not used, where it can go, then in HEAT...
Use max 1A or anything belove it.
Above 1A can be risky and critical for phone, chargher, cabel or anything else.
Sent from my LT15i using XDA Premium
Any chance you know the charging range when connected to a pc?
PC gives to you 5V.
At what ampere?
that depends on charger and wire resistant.
I - Electric
U - 5v
R - resistor
I= U/R
I= 5:1 = 5A
I= 5/2 = 2.5A
I= 5/3 = 1.66A
I= 5/4 = 1.25A
I= 5/5 = 1A
ETC
The normal limit for a USB port on a computer is 500mA.
USB "chargers" can provide more (typically 850mA) and will charge the phone faster. However, as someone else pointed out, a proper USB PC port and/or charger will regulate the voltage to no more than 5.25V, which given the laws of electricity limits the current that can be drawn for charging. It is actually the phone that controls the charging, assuming a properly regulated input power. An unregulated battery would not be a good charging source.
The micro-USB connector is itself rated to a maximum of 1.5A.

[Q] Charging Input Voltage Range?

Does anyone know the range of acceptable voltages to charge the Nitro?
I know it's USB so 5v DC but I'm creating an integrated charge for my bike which has a 7.4v power supply for the electronic shifting which I could tap into. I know many other phones have an acceptable range of around 4v - 9v but not sure on this one. I could reduce the voltage easily enough but if I don't have to I would like to avoid it.
Thanks,
Matt
The USB spec is 4.75 to 5.25 V, I would not put anything much higher than that on the input. You could use a simple 3 pin LDO regulator to trim your voltage from 7V to 5V. Something like this can be picked up at a radio shack (Click Here).
I have made several phone chargers and usb charged battery packs and from my experience, these voltage ranges are pretty strict due to the input protection diodes used on the devices.

Ampere APP and "max. possible USB current"

Hello N5X users. As far as you probably know, Ampere has now functionality for measuring maximum possible USB current.
I've noticed one interrested thing when charging (during testing some C2C cables). When I'm repeatedly connecting my original Google's A/C typeC chager, readings give always different values - very often less than 3000mA (meanwhile other apps show value 3000 which is the teoretical maximum). With some crappy C2C cables even less. I dont understand what it does mean and how do they compute the maximu possible USB current. Can you give me a clue? Do you have similar experience?
I'm wondering whether my USB charger is working correctly. I.e. my PCI-E ASUS extension card gives max. possible USB current 3000mA (reported by Ampere) at every attempt.
Thank you for sharing your experiences.
To work out the current we need to know the resistance of the cable (including the resistor). So the way we do this is by taking the voltage and sharing it by the resistance to give us current.
We can work out the resistance in a cable though by taking the voltage and sharing it by the current.
The USB c to a cable that I have draws 600mA so the resistance in the cable (this includes the resistor) is: 3100mV shared with 600mA which is 5100mOhm or 5.1 ohm
The question is why my phone with the same cable and charger often reports different maximum possible current (3000mA, 2100mA, 1900mA, ...).
It will depending on the charge of the battery and the temp of the phone. The charging circuit will pull only what it needs or what is safe.
Sent from my Nexus 5X using Tapatalk
Of course it depends on temp and level of charge. But I'm talking about situation which is happening almost at the same moment. I was trying to plug and unplug it over and over again (with the same level of charge and temperature) and the maximum possible USB current was often different - 3000mA then 2300mA ater that 2100mA and then again 3A. I still don't know the way they compute this max. possible value (because the resistor in the cable should tell what is the maximum current - 3000mA, 1500mA or standard USB port).
This happens with the original Google charger but not with ASUS PCI-E card in my computer (it alwas reports 3000mA) using the same cable.
Is there anybody who could try to measure max. possible current using Ampere app and A/C charger? A few attempts of plugging and unplugging would be enough.
Thanks!
I don't know if you found out what was going on... Did you? I'm observing exactly the same in my N5X
Desde el móvil...
I also see different max USB current settings each time I plug a USB charger in then unplug and plug back in again
Sent from my Nexus 5X using XDA-Developers mobile app
Additionally, I would like to ask you all if it's normal that Ampere reports positive mA (so charging), but the % si descending... ¿¿¿???
My phone is a Nexus 5X, with Mashmallow. No other method of obtaining charge in basic options.
marshall.cze said:
Hello N5X users. As far as you probably know, Ampere has now functionality for measuring maximum possible USB current.
I've noticed one interrested thing when charging (during testing some C2C cables). When I'm repeatedly connecting my original Google's A/C typeC chager, readings give always different values - very often less than 3000mA (meanwhile other apps show value 3000 which is the teoretical maximum). With some crappy C2C cables even less. I dont understand what it does mean and how do they compute the maximu possible USB current. Can you give me a clue? Do you have similar experience?
I'm wondering whether my USB charger is working correctly. I.e. my PCI-E ASUS extension card gives max. possible USB current 3000mA (reported by Ampere) at every attempt.
Thank you for sharing your experiences.
Click to expand...
Click to collapse
The answer is simple. AMPERE does not work in the Nexus 5X under Marshmallow. I tested with a variety of cables and chargers, all passing the current through an inline USB Volt/Amp meter. The amps reading on the meter bore no relationship to the indicated value from AMPERE. Nor did the app give a sensible value when plugged into the Nexus-supplied charger.

Limit Charging Current? Slow/Trickle Charging

Hey guys, wondering if anyone has found a way to limit the charging current or voltage. I'm looking to slow charge my pixel overnight with the stock charger, thinking it would be better to keep the heat down to preserve battery health.
Reading the thread linked below gave me some hints so I have been messing with the parameter /sys/class/power_supply/battery/constant_charge_current_max but it does not permanently change the charging current, there seems to be some other program modifying the value as the phone charges. I've seen it as high as 3000000 (3A) and as low as 700000 (700mA). It seems to reduce current as the phone heats up.
Is there any way to lock this parameter at a constant value? Any other ideas on how to get slow charging? Do I need a custom kernel?
https://forum.xda-developers.com/pixel-xl/how-to/guide-limit-battery-charge-level-tasker-t3668059
bchaney16 said:
Hey guys, wondering if anyone has found a way to limit the charging current or voltage. I'm looking to slow charge my pixel overnight with the stock charger, thinking it would be better to keep the heat down to preserve battery health.
Reading the thread linked below gave me some hints so I have been messing with the parameter /sys/class/power_supply/battery/constant_charge_current_max but it does not permanently change the charging current, there seems to be some other program modifying the value as the phone charges. I've seen it as high as 3000000 (3A) and as low as 700000 (700mA). It seems to reduce current as the phone heats up.
Is there any way to lock this parameter at a constant value? Any other ideas on how to get slow charging? Do I need a custom kernel?
https://forum.xda-developers.com/pixel-xl/how-to/guide-limit-battery-charge-level-tasker-t3668059
Click to expand...
Click to collapse
Easier - but perhaps less technically elegant solution that I use...use the old school Micro USB charger from prior generation phones with a Micro USB to Type C converter. I use the below from Anker...2 for $7.99 on Amazon. Works great for slow charging overnight - that's the exact use case I use it for. And I use the stock charger for rapid charging as needed throughout the day, before going out for the evening, etc...
[2 in 1 Pack] Anker USB-C to Micro USB Adapter, Converts USB Type-C input to Micro USB, Uses 56K Resistor, Works with MacBook, ChromeBook Pixel, Nexus 5X, Nexus 6P, OnePlus 2 and More
by Anker
Link: http://a.co/8m05Jnc
Good point, using a different charger is an option. I would prefer to control charging via software so that I can use the stock charger (I'm crazy and always buy/use the stock charger for my phones) and I don't have to carry multiple chargers when I travel. It would be great to have complete control over the charging levels and do a super slow trickle charge at a lower level than even an old micro USB charger outputs. Plus having a switch in Tasker to enable/disable quick charging would just be cool.
bchaney16 said:
Good point, using a different charger is an option. I would prefer to control charging via software so that I can use the stock charger (I'm crazy and always buy/use the stock charger for my phones) and I don't have to carry multiple chargers when I travel. It would be great to have complete control over the charging levels and do a super slow trickle charge at a lower level than even an old micro USB charger outputs. Plus having a switch in Tasker to enable/disable quick charging would just be cool.
Click to expand...
Click to collapse
Completely agree and if you find a solution please post it back here. Would allow me to control charging better overnight when traveling. I also only travel with the stock charger - so I just use that and it rapid charges my phone overnight (assume once full or close to full it reverts to "trickle-charging" to keep at 100%). Having the ability to control via software would be more convenient, may prolong battery life, and allow me to ditch an extra cord on the bedside table at home.
Just thought I'd mention an interim alternative while you search for the ideal solution - which I hope you find.
Also - not sure if you have checked out / tested the following Magisk modules(there may be others - these are the ones I found in a quick scan of the XDA listing of modules)...they both seem like they may help address your situation - if not totally, but perhaps partially.....
MC's Charging Controller: Control when to enable / disable charging on your device
https://forum.xda-developers.com/apps/magisk/mcs-charging-controller-t3739371
Magic Charging Switch: Automatically pause/resume charging at set % levels to extend battery lifespan.
https://forum.xda-developers.com/apps/magisk/module-magic-charging-switch-cs-v2017-9-t3668427
any software solution found ? i want to lock the max charging current
nassim20 said:
any software solution found ? i want to lock the max charging current
Click to expand...
Click to collapse
You probably need a custom kernel with current_max entries rw support.
Find your charging source in /sys/class/power_supply/. In my case, it is USB - when charging from micro USB and qpnp-dc - when charging from doc connector.
Make sure current_xxx_max is writable (qpnp-dc/current_max or usb/current_system_max has rw-r-r permissions).
And just run echo 500000 > /sys/class/power_supply/usb/current_xxx_max to limit charging current to 500 mA.
if your current_max is r-r-r (read only) - you need another kernel.
sb1893 said:
Completely agree and if you find a solution please post it back here.
Click to expand...
Click to collapse
kucher5 said:
You probably need a custom kernel with current_max entries rw support.
Find your charging source in /sys/class/power_supply/. In my case, it is USB - when charging from micro USB and qpnp-dc - when charging from doc connector.
Make sure current_xxx_max is writable (qpnp-dc/current_max or usb/current_system_max has rw-r-r permissions).
And just run echo 500000 > /sys/class/power_supply/usb/current_xxx_max to limit charging current to 500 mA.
if your current_max is r-r-r (read only) - you need another kernel.
Click to expand...
Click to collapse
thnx for the reply
i actually haaad this problem with a redmi, and i found a magisk module for it on telegram

Question P6P not charging on PC USB port (random)

I do now own a dedicated P6 charger and usually end up charging my phone on the USB port of my PC during my workday.
I've noticed that occasionally the phone is simply not charging when connected to PC USB. Easy to verify with: 'adb shell dumpsys battery', e.g.:
Code:
Current Battery Service state:
AC powered: true
USB powered: false
Wireless powered: false
Max charging current: 1500000
Max charging voltage: 5000000
Charge counter: 2774000
status: 2
health: 2
present: true
level: 54
scale: 100
voltage: 3958
temperature: 238
technology: Li-ion
Then, after rebooting the phone, unplugging the USB cable, replugging it again, it starts charging again.
I have not found a way to reliably replicate the problem so I don't really know exactly when or why it happens.
I know that the USB port itself is fine. It works and my wife's phone consistenty charges fine on that port.
Anybody else having the same issue? I'll report it to Google ...
Did you try changing the PC USB port? And are you using a USB-C port?
A Pixel 6 Pro phone wants USB PD 3.0 PPS for charging, anything less than that and chances are that the phone will automatically shut down charging (on it's own) - Google says to prevent damage, I say to sell chargers. But the baseline is the same, it won't work reliably, or not at all.
On top of that comes the problem that Windows/ USB ports just suck. I have 4 front panel USB ports... and three of them don't like ADB, if I try to flash firmware from them on my phone, it will stuck/create bugs. If I use the fourth (middle right)... it will work without problems. Of course there is no other scenario on planet earth where the other USB ports ever caused me issues. That's tech just being non-compatible cr*p for no reason.
Morgrain said:
Did you try changing the PC USB port? And are you using a USB-C port?
A Pixel 6 Pro phone wants USB PD 3.0 PPS for charging, anything less than that and chances are that the phone will automatically shut down charging (on it's own) - Google says to prevent damage, I say to sell chargers. But the baseline is the same, it won't work reliably, or not at all.
On top of that comes the problem that Windows/ USB ports just suck. I have 4 front panel USB ports... and three of them don't like ADB, if I try to flash firmware from them on my phone, it will stuck/create bugs. If I use the fourth (middle right)... it will work without problems. Of course there is no other scenario on planet earth where the other USB ports ever caused me issues. That's tech just being non-compatible cr*p for no reason.
Click to expand...
Click to collapse
I don't think its really a matter of USB PD/PPS. I think your second part, how much USB ports (and cables) can vary, is more likely. On new(ish) PCs or Laptops, USB ports are much better than they were 10-15 years ago. I can charge my Pro using many types of USB 2.0/3.0 Ports - PCs from 2009, laptops from 2010/2019, recent or older adapters (not PD/PPS etc). (repair laptops on the side so I have a stack of them). So the capability is there on the phone, so I'm leaning towards a USB Cable/USB port issue. And yes, the amperage the phone takes in can vary but if your cable, port and phone are working fine, the power should be consistent (always best to take in at least 700 mAh so the phone can charge, albeit at a slow and decent rate). just make sure you're using a quality usb cable ( I didn't believe in this much until I had an issue with fastboot/adb not working, new cable fixed it).
And for sure, USB ports on the front of PC's are notoriously horrible. So many different hardware, firmware, OS drivers (Linux can be problematic sometimes unfortunately) these types that vary so much (especially for USB-A - power, motherboard etc). Best to use the rear ports for consistency or a good powered USB hub plugged into the back.
The main benefit to PPS is the way it "steps" the voltage up or down, which is a benefit for fast chargers - but not really much benefit for charging using a USB port or adapters with lower amperage. But that's not to say that everything is all good, maybe because PPS is so new it might be causing issues on some Pixels, and the bugs need to be ironed out, I can't say for sure.
OP, are you using the original cable that came with your phone (usb-c port?)
- edit-- ok I see your comment, let us know
Morgrain said:
Did you try changing the PC USB port? And are you using a USB-C port?
A Pixel 6 Pro phone wants USB PD 3.0 PPS for charging, anything less than that and chances are that the phone will automatically shut down charging (on it's own) - Google says to prevent damage, I say to sell chargers. But the baseline is the same, it won't work reliably, or not at all.
On top of that comes the problem that Windows/ USB ports just suck. I have 4 front panel USB ports... and three of them don't like ADB, if I try to flash firmware from them on my phone, it will stuck/create bugs. If I use the fourth (middle right)... it will work without problems. Of course there is no other scenario on planet earth where the other USB ports ever caused me issues. That's tech just being non-compatible cr*p for no reason.
Click to expand...
Click to collapse
I don't use Windows at home but Linux.
The port works very fine with ADB (never had any issues with it).
It is a USB-A port.
It actually does charge (slowly) but then - sometimes - when I connect my phone it does not charge any more (reboot then makes it work again).
But it might be indeed as you say that the phone shuts down the charging under certain conditons.
Hmm ... interesting ... I connected just now on a USB-C port of my PC ... and: 'adb shell dumpsys battery' gives:
Code:
Current Battery Service state:
AC powered: false
USB powered: true
Wireless powered: false
Max charging current: 3000000
Max charging voltage: 5000000
Charge counter: 3032000
status: 2
health: 2
present: true
level: 59
scale: 100
voltage: 4049
temperature: 268
technology: Li-ion
The max charging current is now 2x the value as for the USB-A port ...
I will use that port over the next couple of days to see how it goes.
Alekos said:
OP, are you using the original cable that came with your phone (usb-c port?)
Click to expand...
Click to collapse
Trying this now as we speak ;-)
Thanks for the tip.
See my previous reply to @Morgrain, getting a higher charging current on USB-C port and phone is indeed charging faster than on the USB-A port.
I built a new PC a year ago and it has to USB-C ports (one on the back, one via adapter cable to the motherboard - both I made easy access on the front of the computer case). I, too, have noticed that USB-C charges great (either OEM or an off-brand freebie but quality USB-C cable) through either USB-C port. Technically it's fast charging but it's nowhere near modern fast charging, so I'm not too worried about it.
I did try a USB-A port once and found it was charging too slowly to make sense, so I quickly abandoned it and have only used the USB-C ports and cables since when I'm working on the computer.
When I'm charging from my couch's or my bedroom surge protector's USB-A ports, the phone charges normally.

Categories

Resources