4 Replies Latest reply on Oct 20, 2015 6:33 AM by doumdi

    Power down sequence with external power supply + GPIO

    doumdi

      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