April 04, 2020, 10:47:39 pm

News:

Have you visited the Allwinner Chipset wiki? - http://linux-sunxi.org/


Cubietruck battery issue

Started by guai888, March 24, 2015, 11:07:31 am

Previous topic - Next topic

guai888

If I add battery to cubietruck and plug in the power adapter, I can not use "shutdown -h now" to turn off the machine. Dose anyone has a solution?

phelum

Quote from: guai888 on March 24, 2015, 11:07:31 am
If I add battery to cubietruck and plug in the power adapter, I can not use "shutdown -h now" to turn off the machine. Dose anyone has a solution?

Not an easy solution but you can get the AXP209 datasheet from http://linux-sunxi.org/File:AXP209_Datasheet_v1.0en.pdf and then change the values in some of the registers to see if that helps.

One great thing about the AXP209 driver is that you can read any register by writing the address to /sys/class/i2c-dev/i2c-0/device/0-0034/axp20_reg and then reading the same register.  e.g.
echo -n 0x35 > /sys/class/i2c-dev/i2c-0/device/0-0034/axp20_reg
cat /sys/class/i2c-dev/i2c-0/device/0-0034/axp20_reg

To write a register put both the address and value in the echo. e.g.
echo -n 0x35a2 > /sys/class/i2c-dev/i2c-0/device/0-0034/axp20_reg

The driver doesn't load some of the registers and just relies on the defaults.  The chip uses the RTC battery to supply power to maintain the registers.  So if you change something it should stay changed.

Cheers,
Steven

alodos


I have the same issue on my Cubieboard4 and Cubietruck Plus (Cubieboard5).
Try find and replace value of power_start parameter in FEX file (and update bin file).
This parameter can be located in section [target] or [pmu1_para], relates on your board/FEX version.

For power off with AC+BAT connected try set to:
power_start = 1

Power start can be ==1 and <>1 only.

You should look at kernel sources for using this parameter (example for cb4 cc-80 kernel sources).
https://github.com/cubieboard/CC-A80-kernel-source/search?q=power_start

There are some rows with power_start condition (related to AXP chip):
https://github.com/cubieboard/CC-A80-kernel-source/blob/master/drivers/power/axp_power/axp-mfd.c#L94

#if defined (CONFIG_AW_AXP22)
...
if(power_start != 1){
...
if(val & 0xF0){
...
    if(val & 0x20){
    ...
machine_restart(NULL);
    ...
    }
}
}
...
#endif


The same code for AXP81X (Cubietruck Plus).
https://github.com/cubieboard/Cubietruck_Plus-kernel-source/blob/master/drivers/power/axp_power/axp81x/axp81x-init.c#L48