I'm looking for help managing the timing of GPIO pin states on a Raspberry Pi Zero W running OpenWRT 23.05.0.
My current situation is:
GPIO 26 correctly goes to logical HIGH (1) on boot.
However, upon issuing the poweroff command, GPIO 26 transitions to logical LOW (0) too early, while the green SD activity LED is still blinking—indicating that filesystem writes are ongoing and the filesystem is not yet safely unmounted.
What I'm trying to achieve:
Ensure GPIO 26 remains HIGH until after the filesystem is safely unmounted, and only then switches to LOW.
I would appreciate guidance on:
Why GPIO transitions LOW prematurely, and how to delay this event properly.
Best practices for executing GPIO actions specifically after filesystem unmount.
Recommended GPIO control methods for OpenWRT 23.05.0
That's not what it means during shutdown. It only has that meaning when the Linux kernel is running and has control over that LED. The "blink 10 times" behavior at shutdown is instead controlled by the Raspberry Pi firmware, after which the Linux kernel has stopped running. At that point the filesystem has long been unmounted. You can prove this to yourself by monitoring the Raspberry Pi's serial console with a USB serial adapter (or another Raspberry Pi) during shutdown.
GPIO behavior is unspecified unless you explicitly turn it off or on at the exact times you want.
Do you actually care about a specific filesystem being unmounted, or do you actually care about the entire system shutting down? I ask because it sounds like you're using GPIO 26 to control power to the Raspberry Pi. In this case, the filesystem is irrelevant because it will have already been unmounted before the kernel shuts down.
The recommended interface under Linux is the GPIO character device. A command line interface is available in the gpiod-tools package.