Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor I
1,121 Views

Power down sequence with external power supply + GPIO

Jump to solution

Hello everybody,

I am powering my Edison board with a custom power supply (two LiPo cells) / battery charger. The Edison always starts fine when I power it up. However, I am trying to get the edison signal the external power supply logic with gpio49 when it shuts down. The goal is to have gpio49 go high to switch the power supply completely off when shutdown is completed. I tried to modify /lib/systemd/system/systemd-poweroff.service with no success.

Here is my modified /lib/systemd/system/systemd-poweroff.service file :

# This file is part of systemd.

#

# systemd is free software; you can redistribute it and/or modify it

# under the terms of the GNU Lesser General Public License as published by

# the Free Software Foundation; either version 2.1 of the License, or

# (at your option) any later version.

[Unit]

Description=Power-Off

Documentation=man:systemd-halt.service(8)

DefaultDependencies=no

Requires=shutdown.target umount.target final.target

After=shutdown.target umount.target final.target

[Service]

Type=oneshot

ExecStart=/bin/systemctl --force poweroff

ExecStartPre=/bin/echo -n "49" > /sys/class/gpio/export

ExecStartPre=/bin/echo -n "out" > /sys/class/gpio/gpio49/direction

ExecStartPre=/bin/echo -n "1" > /sys/class/gpio/gpio49/value

I am not a systemd expert, so this can be wrong. It seems the ExecStartPre commands have no effect. I suspect I can't write anymore to files system (sysfs??) at this time.

Do you have any idea how this can be done?

Thanks

Dominic


Accepted Solutions
Highlighted
Employee
22 Views

Hi Dominic,

The problem with the script you are using is that you are powering off the board and then you are going to configure the pin but the Module will be already off for configuring the pins. If the poweroff process is running in parallel to the configuration of the pins, as you can see in the Terminal Console after running the command poweroff the board partially boots in this process there could be changes in the pins so if the pin is high after this it could be low again.

My suggestions will be using the same idea but with inverted logic, I mean:

You can create a startup script to set the gpio49 as high and have external circuitry with an inversor + capacitor + ... This will allow you to have a trigger when the poweroff process finishes.

Kind regards,

Charlie

View solution in original post

4 Replies
Highlighted
Employee
23 Views

Hi Dominic,

The problem with the script you are using is that you are powering off the board and then you are going to configure the pin but the Module will be already off for configuring the pins. If the poweroff process is running in parallel to the configuration of the pins, as you can see in the Terminal Console after running the command poweroff the board partially boots in this process there could be changes in the pins so if the pin is high after this it could be low again.

My suggestions will be using the same idea but with inverted logic, I mean:

You can create a startup script to set the gpio49 as high and have external circuitry with an inversor + capacitor + ... This will allow you to have a trigger when the poweroff process finishes.

Kind regards,

Charlie

View solution in original post

Highlighted
New Contributor I
22 Views

Hello Charlie,

I will investigate this solution. Thanks for the idea!

I am also considering detecting the presence/transition of the 1V8 supply from the Edison's PMIC to turn off the external power supply. This way, I would not need any gpio to make this work.

Regards,

Dominic

Highlighted
Employee
22 Views

Hi Dominic,

If the module is being powered you will have the 1.8V "on", no matter if you run the poweroff command the pin will be still powered because it's taking energy from the supply.

Regards,

Charlie

0 Kudos
Highlighted
New Contributor I
22 Views

I finally done the trick with the 3V3 detection. It works perfectly well.

Dominic

0 Kudos