A20 power-up with Battery attached

Started by nickvanalst, January 06, 2015, 10:49:51 AM

Previous topic - Next topic

nickvanalst

Hi guys,

we are getting the Olimex boards ready for production use in our products.
We love the idea, and het low costs of the board, but we did encounter a downside.

We are getting some problems with the SD cards on power failure, as the product is an consumer device we get a lot of power failures because customers simply pull the plug. (product does not have a interface)

So this was our idea:

Attach a battery, on AC loss shutdown nicly on Battery power.
And boot up again when AC is present again.

Now step 1 is working, shutting down on AC loss. But i cant get the board to power up again.

after a good shutdown (shutdown -Ph now) there are 2 ways of booting:

1)
Unplug battery
Unplug AC
Plug AC/Battery

2)
press the reset button

Both options can not work in our environment. (as the battery and the reset button are internal.

i've already set the power_start to 1 in the fex file to check if this resolves the issue.

No effect at all. (also not sure what the option does, no documentation of it on: http://linux-sunxi.org/Fex_Guide)

I've also found this topic which is a bit related: https://www.olimex.com/forum/index.php?topic=2377.0

Does anyone know how to get the A20 to boot on AC power restore? even if there is a Battery attached at the same time?

dave-at-axon

The power_start=1 should be all you need.

I've been running for months with an A20 and Android and battery connected. If powered off on battery or external dc power, then remove the external DC and then the system re-starts on applying DC power. Same with connecting the USB if in the off state.

If only battery then pressing the power button causes it to boot up as expected. Same if the dc power is left connected.

Did you bring the power button external? I had to solder a wire to the button and connect this to my carrier board so that I could have an external power button.

nickvanalst

#2
Somehow this does not work for me.

Also, i'm not using Android, but Debian.
perhaps that is the problem?

I did not bring the power button external. it is a device that only has a power port, USB and Ethernet.
Rest of the device is controlled through the internet.

Also, if i press the power button it does not boot.

i also tried this when only the battery was attached. Still nothing.
It seems that the only way to boot it again is pressing reset.

Or completely pull the power.
Perhaps it does not shutdown correctly?

LubOlimex

Hello Nick,

This is interesting. I performed several tests and I have the exact opposite behavior.

I tested A20-SOM attached to A20-SOM-EVB (I used several hardware revisions of both). I also had a charged battery connected and an external power supply. I used the last two revisions of the official Debian image. I had a serial cable connected also. I kept the "power_start = 1" (as per default of the latest image). To be honest, power_start doesn't play any role in our case – it affect the scenario in which you try to perform a software shutdown when both battery and external power supply are present (which is not the case here – we have only battery powering the board when the shutdown is performed). The whole setup behaved exactly like you expected, e.g.:

1. I insert MicroSD card with the latest image and connect battery – the board stays off.
2. I insert the external power supply – at this point the board boots. I wait for the command prompt.
3. I remove only the external power supply – nothing changes. The board is now powered solely from the battery.
4. I write "shutdown –P –h now" – the boards starts shut down procedure. I wait for it to finish.
5. I connect the external power supply and the board starts automatically. The battery is properly charged and stays connected from point 1.

What I recommend you to do:

- Test with A20-SOM and A20-SOM-EVB – in case you used another peripheral board try with the default hardware
- Test with the latest official Debian image – in case you used a heavily modified version of the official image at least compare the fex files. The latest Debian images might be found at the wiki article here: https://www.olimex.com/wiki/A20-SOM – IMPORTANT: Please note that the image you have to download would depend on the board revision of the boards you have! Check the board revision that is printed on the board iteself and download the image suitable for that board revision. There are two images – one for boards revision A and B and another for boards revision C and D.

Best regards,
Lub/OLIMEX
Technical support and documentation manager at Olimex

nickvanalst

Hi Lub,

Thank you for your response!

i will test with the SOM now. i first wanted to test with the normal dev board.

Also i think i might have a older image then, because my fex had power_start = 0 instead of 1.

i will post results later!

dave-at-axon

I am not sure about the Debian image but Android will not boot on power applied is the power_start=0 and even if you extract the FEX, convert, edit and reapply it, it still won't boot as there seems to be a version packed with the boot.

If in your case you are changing the FEX in an image and not actually building the complete image and the power_start=0 then this would be why it is failing to do what you want it to. There is talk about this issue on this forum months ago. I gave up and eventually built a custom Android to get around the issue.

nickvanalst

Great!

with my SOM image it all worked fine!

i guess the image i used for the dev board was older.

As for the FEX file dave-at-axon: i can't imagine that the FEX file's are not working, these are config file's.
only thing i can think of that there was a bug in the image that one of the settings were not used.

All other settings i set in my custom FEX file, are working fine. (GPIO/uart)

dave-at-axon

As I said, not sure how Debian handles the FEX but under Android making changes to the FEX in the boot area did not work. The file was changed but something in the BOOT did not detect the changes. We assumed there was a cached version somewhere. :(

Gerrit

Quote from: dave-at-axon on January 06, 2015, 03:46:29 PM
As I said, not sure how Debian handles the FEX but under Android making changes to the FEX in the boot area did not work. The file was changed but something in the BOOT did not detect the changes. We assumed there was a cached version somewhere. :(

Only changing the script.fex file does do anything, you have to convert it to the script.bin file first.

http://linux-sunxi.org/Sunxi-tools

dave-at-axon

We tried that with Android. We used a decrypt tool to get back the original FEX, made the changes and then created the BIN from it. The Android image still did not pick up the changes. We think that there is a copy within the BOOT sector that does not change.

As I said, a custom build of Android solved the problem and we were also able to rebuild the RIL and add PPP and SMS support etc. In fact, I just rebuilt the RIL to support the popular SIM900 modules. :)

rafaelpgw

Hi!

I am also developing a baseboard for A20-SOM for a consumer product and I am worried about the integrity of SD/NAND images.

In order to do a smooth system shut down after external power loss I need to detect the power loss and then sync and shut down the system. I also need it to power up when the external power is restored.

I understand that after a power down, AXP209 will power the A20 and restart Linux after the external DC power is restored.

How can I detect an external power loss? Does AXP209 signalize it through IRQ-NMI (Pin 48 on AXP209 and F5 on A20)? If yes, is there any FEX configuration to ensure that signal?

And how can you shut-down the system after that external power loss detection? Does AXP209 do that?

I was thinking of an user space application monitoring a GPIO connected through a comparator to the external DC power (9-24VDC). But would be great if AXP209 did that trick alone.

Thanks in advance.

bachmic

Quote from: nickvanalst on January 06, 2015, 10:49:51 AM

Attach a battery, on AC loss shutdown nicly on Battery power.
And boot up again when AC is present again.


Hi guys,

nickvanalst seems to be a lucky guy - trying over and over again I could not manage to shutdown A20-SOM with Linux after external power loss an power supply changes to LiPo.

Is the a step-by-step tutorial somewhere how to make this part work?

Thanks in advance!