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:
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:
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…
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:
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.
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:
Save the file and exit the text editor. This will ensure that your changes persist after a reboot.
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:
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.
I tried your udev rule (and many variations), but I can’t get it to work. With udev debug logging turned on, I can tell that udev knows about the rule, but it never fires. I guess the filters are wrong so it doesn’t match the device. My udev debugging skills aren’t strong enough to know why at the moment.
I’ll report back if I learn anything.
Update:
Here’s how to see what attributes you can use in filters:
I noticed while looking through the udev debug logs that there are no add events for axp20x-battery, only change events. There’s an add event for apx20x-battery-power-supply, but that device doesn’t have the attributes we need to set. I changed the action filter and device name filter and got it working. I also used a built in udev rule feature to set attributes instead of using a shell command, though I think both ways would work. Here’s my working rule: