busybox: add suspend-actions script for the ccimx8x and ccimx6ul
This script behaves the same way as our custom standby script, with a few modifications, for example: * instead of using initscripts to stop/start daemons, it uses systemctl calls * save variables that are needed when resuming in /tmp, because the script is executed twice instead of once (when suspending and when resuming) * remove the locking/unlocking of the critical section and the actual state change, since that is handled by systemd-suspend now Also, add a different standby script for when systemd is enabled. Said script acts as a wrapper for systemd's suspend mechanism. https://jira.digi.com/browse/DEL-6415 Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
This commit is contained in:
parent
2d2f9fcbb0
commit
803dde16b0
|
|
@ -0,0 +1,63 @@
|
|||
#!/bin/sh
|
||||
#===============================================================================
|
||||
#
|
||||
# standby-actions
|
||||
#
|
||||
# Copyright (C) 2019 by Digi International Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 as published by
|
||||
# the Free Software Foundation.
|
||||
#
|
||||
#
|
||||
# !Description: manage interfaces before suspending and after resuming from
|
||||
# suspend
|
||||
#
|
||||
#===============================================================================
|
||||
|
||||
if [ "${1}" == "pre" ]; then
|
||||
# Stop NetworkManager before suspend
|
||||
systemctl stop NetworkManager
|
||||
|
||||
# Suspend wireless interfaces
|
||||
if [ -d "/proc/device-tree/wireless" ]; then
|
||||
for i in $(sed -ne 's,^\(wlan[0-9]\)=.*,\1,g;T;p' /var/run/ifstate | sort -r); do
|
||||
ifdown "${i}" && RESUME_IFACES="${RESUME_IFACES:+${RESUME_IFACES} }${i}"
|
||||
done
|
||||
|
||||
echo ${RESUME_IFACES} > /tmp/suspend_wlan_ifaces
|
||||
grep -qs '^wlan' /proc/modules && rmmod wlan
|
||||
fi
|
||||
|
||||
# Suspend bluetooth interface
|
||||
if [ -d "/proc/device-tree/bluetooth" ]; then
|
||||
hciconfig hci0 2>&1 | grep -qs UP && touch /tmp/up_bt_on_resume
|
||||
systemctl stop bluetooth
|
||||
systemctl stop bluetooth-init
|
||||
fi
|
||||
elif [ "${1}" == "post" ]; then
|
||||
# Resume wireless interfaces
|
||||
if [ -d "/proc/device-tree/wireless" ]; then
|
||||
# Trigger wireless module loading event, and wait until the interface exists
|
||||
udevadm trigger --action=add --attr-match="modalias=sdio:c00v0271d050A"
|
||||
timeout -t 5 sh -c "while [ ! -d /sys/class/net/wlan0 ]; do sleep .2; done" 2>/dev/null
|
||||
|
||||
# Bring up the interfaces that were brought down on suspend
|
||||
for i in $(cat /tmp/suspend_wlan_ifaces | tr ' ' '\n' | sort); do
|
||||
grep -qs "^${i}" /var/run/ifstate || ifup "${i}"
|
||||
done
|
||||
rm -f /tmp/suspend_wlan_ifaces
|
||||
fi
|
||||
|
||||
# Resume NetworkManager after suspend
|
||||
systemctl start NetworkManager
|
||||
|
||||
# Resume bluetooth interface
|
||||
if [ -d "/proc/device-tree/bluetooth" ]; then
|
||||
if [ -e "/tmp/up_bt_on_resume" ]; then
|
||||
systemctl start bluetooth
|
||||
rm -f /tmp/up_bt_on_resume
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
#!/bin/sh
|
||||
#===============================================================================
|
||||
#
|
||||
# standby-actions
|
||||
#
|
||||
# Copyright (C) 2019 by Digi International Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 as published by
|
||||
# the Free Software Foundation.
|
||||
#
|
||||
#
|
||||
# !Description: manage interfaces before suspending and after resuming from
|
||||
# suspend
|
||||
#
|
||||
#===============================================================================
|
||||
|
||||
if [ "${1}" == "pre" ]; then
|
||||
# Stop NetworkManager before suspend
|
||||
systemctl stop NetworkManager
|
||||
|
||||
# Suspend wireless interfaces
|
||||
if [ -d "/proc/device-tree/wireless" ]; then
|
||||
for i in $(sed -ne 's,^\(wlan[0-9]\)=.*,\1,g;T;p' /var/run/ifstate | sort -r); do
|
||||
ifdown "${i}" && RESUME_IFACES="${RESUME_IFACES:+${RESUME_IFACES} }${i}"
|
||||
done
|
||||
|
||||
echo ${RESUME_IFACES} > /tmp/suspend_wlan_ifaces
|
||||
grep -qs '^wlan' /proc/modules && rmmod wlan
|
||||
fi
|
||||
|
||||
# Suspend bluetooth interface
|
||||
if [ -d "/proc/device-tree/bluetooth" ]; then
|
||||
hciconfig hci0 2>&1 | grep -qs UP && touch /tmp/up_bt_on_resume
|
||||
systemctl stop bluetooth
|
||||
systemctl stop bluetooth-init
|
||||
fi
|
||||
elif [ "${1}" == "post" ]; then
|
||||
# Resume wireless interfaces
|
||||
if [ -d "/proc/device-tree/wireless" ]; then
|
||||
# Trigger wireless module loading event, and wait until the interface exists
|
||||
udevadm trigger --action=add --attr-match="modalias=pci:v0000168Cd0000003Esv*sd*bc*sc*i*"
|
||||
timeout -t 5 sh -c "while [ ! -d /sys/class/net/wlan0 ]; do sleep .2; done" 2>/dev/null
|
||||
|
||||
# Bring up the interfaces that were brought down on suspend
|
||||
for i in $(cat /tmp/suspend_wlan_ifaces | tr ' ' '\n' | sort); do
|
||||
grep -qs "^${i}" /var/run/ifstate || ifup "${i}"
|
||||
done
|
||||
rm -f /tmp/suspend_wlan_ifaces
|
||||
fi
|
||||
|
||||
# Resume NetworkManager after suspend
|
||||
systemctl start NetworkManager
|
||||
|
||||
# Resume bluetooth interface
|
||||
if [ -d "/proc/device-tree/bluetooth" ]; then
|
||||
if [ -e "/tmp/up_bt_on_resume" ]; then
|
||||
systemctl start bluetooth
|
||||
rm -f /tmp/up_bt_on_resume
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
#!/bin/sh
|
||||
#===============================================================================
|
||||
#
|
||||
# standby
|
||||
#
|
||||
# Copyright (C) 2019 by Digi International Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 as published by
|
||||
# the Free Software Foundation.
|
||||
#
|
||||
#
|
||||
# !Description: suspend system to RAM
|
||||
#
|
||||
#===============================================================================
|
||||
|
||||
# Go to suspend using systemd's default suspend method
|
||||
systemctl suspend
|
||||
|
|
@ -3,6 +3,8 @@
|
|||
FILESEXTRAPATHS_prepend := "${THISDIR}/${BP}:"
|
||||
|
||||
SRC_URI += "file://standby \
|
||||
file://standby-actions \
|
||||
file://standby-systemd \
|
||||
file://busybox-ntpd \
|
||||
file://index.html \
|
||||
file://digi-logo.png \
|
||||
|
|
@ -13,9 +15,13 @@ SRC_URI += "file://standby \
|
|||
file://bridgeifupdown \
|
||||
"
|
||||
|
||||
HAS_SYSTEMD = "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}"
|
||||
|
||||
# hwclock bootscript init parameters
|
||||
INITSCRIPT_PARAMS_${PN}-hwclock = "start 20 S . stop 20 0 6 ."
|
||||
|
||||
FILES_${PN}_append = " ${systemd_unitdir}/system-sleep/"
|
||||
|
||||
# NTPD package
|
||||
PACKAGES =+ "${PN}-ntpd"
|
||||
FILES_${PN}-ntpd = "${sysconfdir}/init.d/busybox-ntpd"
|
||||
|
|
@ -43,8 +49,17 @@ do_install_append() {
|
|||
install -m 0644 ${WORKDIR}/index.html ${D}/srv/www/
|
||||
install -m 0644 ${WORKDIR}/digi-logo.png ${D}/srv/www/
|
||||
fi
|
||||
# Install 'standby' script
|
||||
install -m 0755 ${WORKDIR}/standby ${D}${base_bindir}
|
||||
# Install one standby script or another depending on having systemd or not
|
||||
if ${HAS_SYSTEMD}; then
|
||||
# Install systemd version of 'standby' script
|
||||
install -m 0755 ${WORKDIR}/standby-systemd ${D}${base_bindir}/standby
|
||||
# Install systemd 'standby-actions' hook
|
||||
install -d ${D}${systemd_unitdir}/system-sleep/
|
||||
install -m 0755 ${WORKDIR}/standby-actions ${D}${systemd_unitdir}/system-sleep/
|
||||
else
|
||||
# Install 'standby' script
|
||||
install -m 0755 ${WORKDIR}/standby ${D}${base_bindir}
|
||||
fi
|
||||
# Create a symlink called suspend to maintain backward compatibility
|
||||
ln -s standby ${D}${base_bindir}/suspend
|
||||
if grep "CONFIG_ACPID=y" ${WORKDIR}/defconfig; then
|
||||
|
|
|
|||
Loading…
Reference in New Issue