[Buildroot] /etc//init.d init scripts in buildroot
Peter Korsgaard
peter at korsgaard.com
Fri Jul 14 12:38:18 UTC 2017
>>>>> "Oscar" == Oscar Gomez Fuente <oscargomezf at gmail.com> writes:
> Hi everyone,
> I'm trying to use init scripts from /etc/init.d to activate one gpio just
> before to halt my HW platform (a raspberry Pi): S00gpioff
> I've created a script like this:
> #!/bin/sh
> #
> # S00gpioff
> #
> GPIO_CMD_OFF=13
> case "$1" in
> start)
> echo $GPIO_CMD_OFF > /sys/class/gpio/export
> ;;
> stop)
> echo "Activated CMD OFF output"
> echo 1 > /sys/class/gpio$GPIO_CMD_OFF/value
> ;;
> *)
> exit 1
> ;;
> esac
> The problem is I need to activate the gpio just before halt:
How late does this need to happen? You cannot do much later than this in
user space. E.G. the default inittab is:
# Stuff to do before rebooting
::shutdown:/etc/init.d/rcK
::shutdown:/sbin/swapoff -a
::shutdown:/bin/umount -a -r
rcK calls you init script (as the very last one because of S00), and
then only swapoff + umount gets executed before the kernel is asked to
power down.
If this is not good enough then you need to handle the gpio in a kernel
driver instead by registering a reboot notifier.
--
Bye, Peter Korsgaard
More information about the buildroot
mailing list