Extremely Slow Battery Charging

Currently using the CM4 version of DevTerm and it looks like by default the battery charge current is set at 300mA, this can be confirmed using these commands:

cat /sys/class/power_supply/axp20x-battery/constant_charge_current_max
cat /sys/class/power_supply/axp20x-battery/constant_charge_current

I used a USB power meter and changed the values in these files to “1800000” which should correspond to 1800 mA and noticed that the DevTerm started drawing a lot more power immediately (About 8.7W). I also noticed that the battery charge percentage started increasing more rapidly, before the change it barely moved.

The problem I have is two-fold:

  1. After a reboot the default charging parameters are restored and the DevTerm starts charging extremely slowly. I would rather not add a startup script to overwrite them every time, since there has to be a better way to set this, which brings me to the next question…

  2. Is this the best way to set the charging options? Also I haven’t found a way to set the actual battery capacity unless the AXP228 does a calibration to figure out the capacity. Currently it’s showing 8 Wh, which is incorrect. Using 2x3000mAh batteries should provide a full capacity of about 22Wh.

I’m checking battery charging parameters and status using these commands:

upower -i /org/freedesktop/UPower/devices/battery_axp20x_battery
cat /sys/class/power_supply/axp20x-battery/uevent

Hi Yoonoo, welcome to the community!

You’ve done a great job identifying the problem and finding a temporary solution. To address your concerns, let’s tackle them one by one.

  1. Persisting changes after a reboot: You can modify the /etc/rc.local file to include your changes so that they’re executed during boot, right before the login prompt is displayed. To do this, open the file with a text editor (e.g., sudo nano /etc/rc.local) and add the following lines before the exit 0 line:
echo "1800000" > /sys/class/power_supply/axp20x-battery/constant_charge_current_max
echo "1800000" > /sys/class/power_supply/axp20x-battery/constant_charge_current

Save the file and exit the text editor. This will ensure that your changes persist after a reboot.

  1. Better ways to set charging options: The method you’ve used to change the charging options is quite common and should be adequate for your purpose. However, a more elegant solution might be to create a udev rule that sets these values automatically whenever the device is connected. To do this, create a new file /etc/udev/rules.d/99-devterm-charging.rules with the following content:
ACTION=="add", SUBSYSTEM=="power_supply", ATTRS{name}=="axp20x-battery", RUN+="/bin/sh -c 'echo 1800000 > /sys/class/power_supply/axp20x-battery/constant_charge_current_max; echo 1800000 > /sys/class/power_supply/axp20x-battery/constant_charge_current'"

After creating the file, run sudo udevadm control --reload-rules to reload the udev rules.

Regarding setting the actual battery capacity, you can’t directly set the capacity on the AXP228, as it’s determined by the battery’s characteristics during the calibration process. If you suspect the calibration is off, you can try recalibrating the battery by fully charging it, then discharging it completely, and charging it again. This might give the AXP228 a more accurate measurement of the battery capacity.

I hope this gives you some ideas at least, keep posting if you find a solution. We try to be as helpful as possible, but we definitely don’t know everything.

1 Like

Sounds great. Thank you so much for the detailed instructions!

1 Like