Debian power managment

Started by codifies, February 26, 2014, 08:45:16 AM

Previous topic - Next topic

codifies

I'm using my own kernel so my current experiences might be different to yours, also I want to double check someone hasn't tackled this before and that this isn't just a problem between the chair and workbench!

In debian as soon as DC power is applied when off (with LiPo) the board comes up, this is exactly the behaviour you'd want normally if the board was left in some unattended project, however this is less useful if putting together a "normal" device like a tablet / laptop as when you try to shutdown it just power cycles unless you disconnect DC first...

It would be nice if a persistent setting could choose one behaviour or the other ...

Additionally I do not see any "fuel gauge" type percentage only gross status like AC power on/off charging/charged/discharged

I'm currently enjoying the light reading that is the data sheet for the power management data sheet and have done kernel hacking before on a similar platform to implement wake on alarm, so I should be able to manage this if its possible! (Android shows %age at least) but I would appreciate any input/experiences with this particular platform that people can share...

dave-at-axon

Hi there,

As Debian and Android seem to share the same boot up, I would assume you have a script.bin file too?

If this is the case, there is a setting in there that we have identified that appears to control this power up behavour. In the [target] entry there is a power_start= line.

With this at 1, it boots on applying power, even if you have a battery connected and it was powered down. If this is 0, it powers up, does a quick check of some sort and then goes to sleep. It does not seem to boot up the kernel if this is 0.

On my Android setup, the 5V and 3.3V do seem to be powered up, but it just doesn't initialise the kernel or switch the video fully on.

codifies

I'll look into this, that's a great help!

Assuming that works I just need to figure out the fuel gauge!
Thanks!

dave-at-axon

Have a look in /sys/class/power_supply/battery/status

On Android this shows Full then my battery is charged and Charging when the battery is charging :)

Also, /sys/class/power_supply/battery/present shows 1 when DC power is applied and 0 when not.

current_now shows the charging and I would assume, discharging current. It seems to show 0 when charging from the USB port though.

Have a poke around these files as they might be what you're looking for.

codifies

am I showing my age by poking around in /proc still ;)

chris@A20:~/bootstuff$ cat /sys/class/power_supply/battery/voltage_*
4200000
3300
4138000
chris@A20:~/bootstuff$ cat /sys/class/power_supply/battery/capacity
99
chris@A20:~/bootstuff$ cat ./script.bin.fex | grep power_start
power_start = 0

the good news it looks like its just a case of xfce4-power-manager looking in the wrong place !
the bad news is power_start is already set to zero :(

this is from the script.bin on mmcblk0p1, can this be overriden by being on some other device like nand ?


codifies

well this is odd....

if I set

power_start = 1

then halt, well actually halts! even with LiPo and DC power in the barrel connector...
(this is opposite to what you described, and what I remembered reading somewhere else (I think))

indeed looking at axp-mfd.c (in the kernel driver)

if(power_start != 1){

inside this if block is where it checks to see if it needs to reboot....



by adding apm emulation and apm power class emulation in the kernel config, you can use apm tools for the battery level as well as /sys/class...

none of the XFCE4 widgets seem to use apm or /sys/class
I'm guessing they use acpi which is platform specific (x86)

I'll look at lxde as I see to remember you can put in your own path for the capacity "file"

does anyone happen to have a favourite method to run a script on DC (barrel connector) power failure ?