cant shutdown A20 with LiPo battery on debian

Started by rickster, January 05, 2014, 07:27:47 PM

Previous topic - Next topic

rickster

Guys

I wonder if you can help.

I cannot shutdown the A20 with a battery connected. it just reboots. I am using the olimex debian image and have tried a different micro sd with a buildroot image

At the end of the shutdown I get the following:


[hotplug]: try to kill cpu:1 failed!
[ 1235.622695] [hotplug]: try to kill cpu:1 failed!
[axp] send power-off command!
[axp] set flag!
[axp] reboot!


then the board reboots. If I remove the battery it shuts down fine

Is there something im missing or is the design

Thanks

Ricky

woodward

Hi Ricky,

I don't know if this helps. I think it depends on where you are plugging in your battery. From my experience with several boards, power applied to OTG or the DC barrel Jack will cause the board to boot from off or reboot from shutdown. In my experience, the board will stay shut down if the only power is a LIPO battery plugged into the LIPO jack.

This is perfect for my use: I have a lipo and also DC power. If the dc power is lost, I can detect it, and since the lipo still powers the device, I can cleanly shut down the system. The system then stays shut down since the only power is the lipo battery. Then when dc power comes back on, the board boots again. This is the behavior one might want for a Car PC or similar applications.

JohnS

You might need to be sure you're not backfeeding power to the CPU/board.

Things like BAT54 devices can help in case you are.

John

rickster

Thank you for your replies

It seems it only happens if 1 of the 2 power supplies is connected.

If the battery is the only thing connected (using the onboard lipo connector), it shuts down. If the DC barrel is connected then it shuts down. If both are connected it reboots!

My aim is for a device that can be used with mains power or on battery but at the moment the only way to shutdown the unit is to remove the power before sending the poweroff/halt command



Many thanks

Rick

ikozic

I know it's an old thread, but I kept bumping back into it when searching for the solution for this problem. I've found a solution and decided to post it, as someone else is maybe experiencing the same issues.
So here we go...

If you want the system to shutdown instead of restart with both DC barrel and LiPo connected, you need to set power_start = 1 in your fex file. The relevant axp driver code is in sunxi_kernel/drivers/power/axp_power/axp-mfd.c:


printk("[axp] send power-off command!\n");
mdelay(20);
if(power_start != 1){
axp_read(&axp->dev, POWER20_STATUS, &val);
if(val & 0xF0){
    axp_read(&axp->dev, POWER20_MODE_CHGSTATUS, &val);
if(val & 0x20){
printk("[axp] set flag!\n");
        axp_write(&axp->dev, POWER20_DATA_BUFFERC, 0x0f);
                    mdelay(20);
    printk("[axp] reboot!\n");
machine_restart(NULL);
    printk("[axp] warning!!! arch can't ,reboot, maybe some error happend!\n");
}
}
}

martinayotte

Hi Ikozic,

I've started another thread on the subject : https://www.olimex.com/forum/index.php?topic=3057.0

I don't understand correctly the logic of the AXP driver. Could you explain ?
What the flag "power_start" is use for ? because on a reverse side, if there is a real power failure and the LiPo become discharge, I still wish that the board boot up after power is resumed ...

Thanks in advance,