X728 is shutting off the power too quickly, before the RPi has properly shut down | Geekworm

X728 is shutting off the power too quickly, before the RPi has properly shut down


  • I have an X728 v1.2 with a Raspberry Pi 4B, and I'm trying to get the whole system (both UPS and RPi) to power down in a safe manner.

    I have a simple script of my own that is initiating an automatic shutdown of the UPS when it detects PLD for more than 20 seconds. It does this by setting GPIO 13 to high for four seconds to simulate a 4-second button press (just like x728softd. This causes the UPS MCU to instruct the RPi to commence shutdown, and then cuts the power.

    The problem is that the UPS cuts power to the RPi before it has finished the shutdown! By carefully watching the HDMI output from the RPi I can see that the RPi is still in the process of unmounting filesystems and bringing down network interfaces when the power is cut. A complete RPi shutdown takes at least another 5 seconds, but it doesn't get that chance.

    I understand that the MCU controls this wait time - can we have an update for the MCU that keeps power to the RPi for, say, a full 15 seconds after initiating shutdown? It seems too eager to cut the power.

    Alternatively, there's actually a way for the MCU to determine when the RPi has completed shutdown, by monitoring the UART TX pin (needs the UART enabled in /boot/config.txt) - when the RPi has completed shutdown this pin is held low, so the MCU could watch it for a few seconds to confirm it is held low, then cut the power then.

    Note: just shutting down the RPi on its own doesn't work for me, because the RPi is not powered off and therefore cannot power back up when the external power supply is restored. Also the batteries might end up over-discharged which is a fire hazard.



  • Hi,

    Hello, our shutdown logic is as follows: when the system is in normal use, gpio12 is 3.3V, if GPIO12 will becomes 0 after the system is shut down safely, once the MCU detects that GPIO12 is 0, it will cut off the power.

    Maybe you can modify your script by this rule?


  • That's useful info - are you relying on the kernel to hold GPIO12 high until the kernel is stopped? Otherwise how do you ensure that GPIO12 does not become 0 before the filesystems have been unmounted and the SD card shut down? I just need some confidence that this very quick power-off isn't going to destroy the SD card (I've already killed a lot of them before getting this UPS).

    Would it be possible to have a MCU firmware update that adds a time delay (say, 10 seconds?) after detecting GPIO12 going to 0? If not, is it possible for me to have access to the MCU firmware source please so that I can add a small time delay after detecting GPIO12 going to 0? Alternatively, can you give me tech details about the MCU so I can replace the firmware with my own?


  • I just found this kernel option for config.txt - should I be using this on GPIO12?

    Name:   gpio-poweroff
    Info:   Drives a GPIO high or low on poweroff (including halt). Enabling this
            overlay will prevent the ability to boot by driving GPIO3 low.
    Load:   dtoverlay=gpio-poweroff,<param>=<val>
    Params: gpiopin                 GPIO for signalling (default 26)
    
            active_low              Set if the power control device requires a
                                    high->low transition to trigger a power-down.
                                    Note that this will require the support of a
                                    custom dt-blob.bin to prevent a power-down
                                    during the boot process, and that a reboot
                                    will also cause the pin to go low.
            input                   Set if the gpio pin should be configured as
                                    an input.
            export                  Set to export the configured pin to sysfs

  • For some reason I can't edit my previous posts. Anyway, does the X728 rely on GPIO3 to wake the RPi? If I use this function will I have a problem with powering up the RPi?


Please login to reply this topic!
BACK TO TOP