A20 OLinuXIno Lime2 power on/off

Started by nickehallgren, February 26, 2015, 03:47:22 PM

Previous topic - Next topic

nickehallgren

Hi,

I have a Lime2 that I want to use headless (wireless intercom beltpack) and only on battery. The first problem I had was that when I plug in the 5V power to charge the battery the system boots. I just read that that can be fixed in the config.bin(fex) file (with power_start = 0) so when the power is applied it only charges the battery.

I was thinking about replacing the power button with another one with four pins (two buttons in one case). Two of the pins to replace the original power switch and the two other connected to a GPIO. The idea would be to use the same button for power on and off. Power on works as now and power off would be handled by a python script that I already has running.

The problem is that I want the user to press the power on/off button for lets say two seconds before the python script issues a poweroff, but if the user holds the button a little bit longer there is a risk that the Lime2 does a "hard" shutdown. My question is can I change the time required for a "hard" poweroff to for example 10 or 15 seconds?

Another idea would be to use a button with two positions click left for power on and right for poweroff or do you have any other suggestions?

And is it possible to change the charge current to more than 3-400mAh it now uses so that the battery could be charged faster?

Thanks in advance!

nickehallgren

#1
Ok, I have been reading alot and I think that I figured out everything I need based on the information here: http://linux-sunxi.org/Fex_Guide#pmu_configuration

Correct me if I'm wrong but this is how I understand it

pmu_pekoff_time = 6000 -> Hold Power button pressed for 6 seconds and it does a hard power off (changing this to 10000 -> press for 10 s)
pmu_resume_chgcur = 300 -> This is the normal charging current when system is running
pmu_shutdown_chgcur = 1000 -> 1000mAh charging current when system turned off

As I have this battery: https://www.olimex.com/Products/Power/BATTERY-LIPO6600mAh/ (Max charge current 3300mAh) does it mean that if I have a 2+A power supply I could change it to 1800 for faster charging? Is that bad for the battery in the long run? If so what is the max charge current I should use?

pmu_battery_cap = 2600
Should this value be equal to the battery capacity? If I have the 6600mAh battery, what happens if this is at 2600 and not 6600?

nickehallgren

What is the meaning of "power_start = 1" in config.bin?

I believed that by changing it to 0 the system would not start when DC is applied but that is not the case. If power_start = 0 the system reboots when I try to shutdown when both DC and battery are connected (and autostart when DC is applied).

Is it possible to disable autostart when DC is applied?

dave-at-axon

With the Android Kernel builds, this works as you mention. With 0 and apply DC with battery connected, nothing happens. Actually it boots but goes to sleep. With 1 it boots fully.

Others have commented on the fact that Linux seems to behave differently. Could it be the drivers are different?

auraltension

I've got the same issue where the system is booting as soon as power is plugged in, running Debian Linux with a battery connected.  I sorted out the reboot after shutdown issue, but I cannot get it to not boot when the power is first connected. 

Anyone come across a solution for this yet?

splite

@auraltension same issue for me, did you find out ?

Thanks !

splite

Hello,

I'm still running exactly in the same problem. When I plug in the AC power, the board start by itself...

I'm running on Debian A20-OlinuXino

I dug the web to find a solution but nothing so far.

@auraltension and @nickehallgren any clue ?

splite

Hey !

Sigint on the Linux-sunxi groups gave me the right answer, here is a copy of his answer :

QuoteMaybe this is a common behavior of battery enabled devices. When You connect
turned off phone to charger, it booted automatically, then show some screen
animation of charging status indicator and then probably shutdown, to
continue silent charging.
It can be implemented in u-boot\board\sunxi\board.c
You can determine if board was powered on by ACIN (not a PEK button) and
poweroff board immediately:
        if (axp209_poweron_by_dc()) {
                axp209_poweroff();
                return;//in a normal, return; is unreachable code, axp209 should cutoff
outputs already
        }

I'm placed this code to sunxi_board_init() before any DRAM\pll inits. Now My
board started only for one\half second, after AC plugged, then it calm. At
the same time, battery seems to continue charging, because it is PMU-driven
process.
This isn't direct answer to You question (reconfigure axp209 default
behavior), but it's one acceptable solution worked for Me.

p.s.
You can google for axp209_poweroff() if You u-boot sources miss this
routine. It should be extern declared in: u-boot\include\axp209.h,
u-boot\drivers\power\axp209.c, somewhere near by axp209_poweron_by_dc().

Fellow the instructions below to get it done !


  • Fellow this guide to install the right package : https://raymii.org/s/articles/Olimex_OlinuXino%20_10%20Lime_uBoot_Kernel.html
  • Fellow the bigining of the "Building UBoot" part until the git clonne
  • Edit the following file u-boot\board\sunxi\board.c
  • Add the fellowing code : if (axp209_poweron_by_dc()) {
                    axp209_poweroff();
                    return;//in a normal, return; is unreachable code, axp209 should cutoff
    outputs already
            }
  • Start the uboot building
  • Copy the new uboot on your SD card : dd if=u-boot-sunxi/u-boot-sunxi-with-spl.bin of=/dev/sdX bs=1024 seek=8