Introduction
A while ago I wrote a little shell script that reads data from the AXP202 power management chip used in the Aurora 2, Elf 2, Fire/Flame and Crystal tablets.
I wanted to obtain some information from the chip that isn't available through other means, such as the internal temperature and battery discharge power, and perhaps discover what causes the stuck battery meter bug (no luck with that so far, but it doesn't occur in some newer firmwares anymore anyway).
The script has grown quite a bit and now I've finally cleaned it up a for a public release.
You can download it from the attachment below.
I've also included a second script that can change certain parameters of the AXP202, such as battery charging current and voltage, and USB current limit.
How to use
Download the zip file, extract one or both scripts and move them to your tablet, e.g. to /sdcard/.
Then start a shell on your tablet. There are two common ways to do that.
1. Use a terminal app or
2. Run an SSH server (alternative) on your tablet and use an SSH client on another computer (e.g. PuTTY for Windows) to remotely log in.
If you're new to this, start with method 1, it's simpler.
Finally, in the shell, type this:
The "su" command gives you super user / root privileges. You only need to run it once per session, or maybe not at all if you already are root (try the command "whoami" to find out, it should return "root" or "unknown uid 0").
Both scripts will output a help text when run without arguments. The available arguments are listed there.
Notes:
The axp20info.sh script merely reads data from the AXP202, it doesn't change any settings at all. Nevertheless I can't and won't guarantee that it's 100% safe, so use at your own risk!
The axp20set.sh script writes data to the AXP202, so use it carefully, even though all changes it can make should be uncritical and most of them are reset after the next reboot of the tablet anyway.
Example
Here's some sample output from running "sh axp20info.sh a":
If you have questions about the meaning of certain values, check the datasheet or ask.
Some settings of interest:
Temperature: "chip" is the on-die temperature sensor of the AXP202. It can get quite hot during charging, depending on the charging current (I_charge) and ambient temperature. The external sensor (TS) is not connected, hence the ridiculous low value of -144.7°C.
Battery: the actual voltage (V), current (I) and power consumption of the battery. The example above was recorded while the tablet was idle with screen at lowest brightness.
Fuel Gauge: the current battery level as reported by the chip and by the driver. What you see in the Android GUI is the driver's value, the chip's own internal gauge isn't used, as far as I know.
Coulomb Counters: keep track of how much energy goes into the battery while charging, and how much goes out while discharging. Hence these values can be used to calculate the battery level or the capacity. Whether the chip or the driver actually do make use of these counters to calculate their levels, I'm not sure. Anyway, the current "battery fix", namely the "B820" command, resets these counters to 0, but also disables them. I guess the driver immediately enables them again, or maybe after a reboot.
You can use "sh axp20set.sh C_clear" to reset the Coulomb counters!
Other intersting values are:
I_limit (VBUS settings): the current limit for the USB connection. I assumed this only applied to OTG connections (that is, the tablet powering an external USB device). But I've noticed that it also (or only?) applies to incoming USB, i.e. the tablet being charged via USB. My tablet boots up with "unlimited", but changes to "900mA" after the first USB connection. In the latter case, charging over USB will be severely slowed down, because even if you have a 2A USB charger, only 900mA will actually be used. And that's for the entire system. The battery charging current will be 900mA minus whatever is required to run the system.
You can use "sh axp20set.sh I_limit unlimited" for faster USB loading!
I_charge (charging control): the desired current used for charging the battery. Possible values are 300mA-1800mA, current firmwares use 1000mA or 1200mA. If you're using a weak charger or run into the mentioned VBUS current limit, the actual battery charging current will be lower and the "chargeCurrentLow" (power input status) flag might be triggered.
You can use "sh axp20set.sh I_charge 1400" or other values to change this! However, many firmwares will overwrite your custom value with the default one as soon as the tablet's screen turns on or off next time.
Troubleshooting
If you run the script and get an error that looks similar to this
then that means the line endings in the file are incorrect. They are expected to be in Unix / Linux style, not in DOS / Windows style. You can easily fix that with the "dos2unix" command, e.g.:
Depending on the location of the script file, you'll need su / root again so that dos2unix is allowed to access it.
If you get random "ERROR: invalid register number" messages, then you're probably using a Jelly Bean based firmware and an outdated version of BusyBox.
The cause seems to be a bug in printf / busybox. Occasionally, it has a non-zero return code (signalling an error) even though it shouldn't.
You can see the version of busybox you're using by running "/system/xbin/busybox". I've confirmed that 1.16.2 has the bug.
Just use an app such as this one or this one to update your busybox installation. The current version is 1.20.2 and works fine.
If you find any bugs or have suggestions, please let me know.
A while ago I wrote a little shell script that reads data from the AXP202 power management chip used in the Aurora 2, Elf 2, Fire/Flame and Crystal tablets.
I wanted to obtain some information from the chip that isn't available through other means, such as the internal temperature and battery discharge power, and perhaps discover what causes the stuck battery meter bug (no luck with that so far, but it doesn't occur in some newer firmwares anymore anyway).
The script has grown quite a bit and now I've finally cleaned it up a for a public release.
You can download it from the attachment below.
I've also included a second script that can change certain parameters of the AXP202, such as battery charging current and voltage, and USB current limit.
How to use
Download the zip file, extract one or both scripts and move them to your tablet, e.g. to /sdcard/.
Then start a shell on your tablet. There are two common ways to do that.
1. Use a terminal app or
2. Run an SSH server (alternative) on your tablet and use an SSH client on another computer (e.g. PuTTY for Windows) to remotely log in.
If you're new to this, start with method 1, it's simpler.
Finally, in the shell, type this:
Code:
su<br />
sh /sdcard/axp20info.sh
Both scripts will output a help text when run without arguments. The available arguments are listed there.
Notes:
The axp20info.sh script merely reads data from the AXP202, it doesn't change any settings at all. Nevertheless I can't and won't guarantee that it's 100% safe, so use at your own risk!
The axp20set.sh script writes data to the AXP202, so use it carefully, even though all changes it can make should be uncritical and most of them are reset after the next reboot of the tablet anyway.
Example
Here's some sample output from running "sh axp20info.sh a":
Code:
-------------------------------------------------------------------------------<br />
| ADC DATA & COUNTERS:<br />
-------------------------------------------------------------------------------<br />
ACIN: V=0.0mV, I=0.0mA<br />
VBUS: V=0.0mV, I=0.0mA<br />
Temperature: chip=22.3°C, external=-144.7°C<br />
GPIO: GPIO0=0.0mV, GPIO1=0.0mV<br />
Battery: V=3743.3mV, I_charge=0.0mA, I_discharge=529.0mA, P_discharge=2040mW<br />
System IPSOUT: V=3704.4mV<br />
Coulomb Counters: enabled=yes, charge=78 (7mAh), discharge=18291 (1664mAh)<br />
Fuel Gauge: suspended=no, chip=47%, driver=49%<br />
Some settings of interest:
Temperature: "chip" is the on-die temperature sensor of the AXP202. It can get quite hot during charging, depending on the charging current (I_charge) and ambient temperature. The external sensor (TS) is not connected, hence the ridiculous low value of -144.7°C.
Battery: the actual voltage (V), current (I) and power consumption of the battery. The example above was recorded while the tablet was idle with screen at lowest brightness.
Fuel Gauge: the current battery level as reported by the chip and by the driver. What you see in the Android GUI is the driver's value, the chip's own internal gauge isn't used, as far as I know.
Coulomb Counters: keep track of how much energy goes into the battery while charging, and how much goes out while discharging. Hence these values can be used to calculate the battery level or the capacity. Whether the chip or the driver actually do make use of these counters to calculate their levels, I'm not sure. Anyway, the current "battery fix", namely the "B820" command, resets these counters to 0, but also disables them. I guess the driver immediately enables them again, or maybe after a reboot.
You can use "sh axp20set.sh C_clear" to reset the Coulomb counters!
Other intersting values are:
I_limit (VBUS settings): the current limit for the USB connection. I assumed this only applied to OTG connections (that is, the tablet powering an external USB device). But I've noticed that it also (or only?) applies to incoming USB, i.e. the tablet being charged via USB. My tablet boots up with "unlimited", but changes to "900mA" after the first USB connection. In the latter case, charging over USB will be severely slowed down, because even if you have a 2A USB charger, only 900mA will actually be used. And that's for the entire system. The battery charging current will be 900mA minus whatever is required to run the system.
You can use "sh axp20set.sh I_limit unlimited" for faster USB loading!
I_charge (charging control): the desired current used for charging the battery. Possible values are 300mA-1800mA, current firmwares use 1000mA or 1200mA. If you're using a weak charger or run into the mentioned VBUS current limit, the actual battery charging current will be lower and the "chargeCurrentLow" (power input status) flag might be triggered.
You can use "sh axp20set.sh I_charge 1400" or other values to change this! However, many firmwares will overwrite your custom value with the default one as soon as the tablet's screen turns on or off next time.
Troubleshooting
If you run the script and get an error that looks similar to this
Code:
<br />
: not foundnload/axp20info.sh[22]:<br />
: not foundnload/axp20info.sh[23]:<br />
: not foundnload/axp20info.sh[32]:<br />
: not foundnload/axp20info.sh[33]:<br />
: not foundnload/axp20info.sh[35]: {<br />
/sdcard/download/axp20info.sh[43]: syntax error: 'do^M' unexpected 1|
Code:
dos2unix /sdcard/axp20info.sh
If you get random "ERROR: invalid register number" messages, then you're probably using a Jelly Bean based firmware and an outdated version of BusyBox.
The cause seems to be a bug in printf / busybox. Occasionally, it has a non-zero return code (signalling an error) even though it shouldn't.
You can see the version of busybox you're using by running "/system/xbin/busybox". I've confirmed that 1.16.2 has the bug.
Just use an app such as this one or this one to update your busybox installation. The current version is 1.20.2 and works fine.
If you find any bugs or have suggestions, please let me know.