From 8143f6f638c2e5b1d485353a259f3330808c5669 Mon Sep 17 00:00:00 2001 From: Isaac Hermida Date: Fri, 15 Jul 2016 14:29:21 +0200 Subject: [PATCH] meta-digi-dey: add suspend script support to ccimx6ul https://jira.digi.com/browse/DEL-2773 Signed-off-by: Isaac Hermida --- .../busybox/busybox-1.23.2/ccimx6ul/suspend | 58 +++++++++++++++++++ .../busybox/busybox_1.23.2.bbappend | 2 + 2 files changed, 60 insertions(+) create mode 100755 meta-digi-dey/recipes-core/busybox/busybox-1.23.2/ccimx6ul/suspend diff --git a/meta-digi-dey/recipes-core/busybox/busybox-1.23.2/ccimx6ul/suspend b/meta-digi-dey/recipes-core/busybox/busybox-1.23.2/ccimx6ul/suspend new file mode 100755 index 000000000..d597339b6 --- /dev/null +++ b/meta-digi-dey/recipes-core/busybox/busybox-1.23.2/ccimx6ul/suspend @@ -0,0 +1,58 @@ +#!/bin/sh +#=============================================================================== +# +# suspend +# +# Copyright (C) 2016 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 +# +#=============================================================================== + +scriptname="$(basename ${0})" +syspower="/sys/power/state" + +usage() { + printf "\nSuspend system to RAM memory\n" + printf "\nUsage: ${scriptname} [OPTIONS]\n + -h Show this help + \n" +} + +suspend_interfaces() { + if grep -qs '^wlan0' /var/run/ifstate; then + ifdown wlan0 && up_wlan_on_resume="1" && sleep 0.5 && rmmod wlan + fi +} + +resume_interfaces() { + if ! grep -qs '^wlan0' /var/run/ifstate; then + [ -n "${up_wlan_on_resume}" ] && modprobe wlan && sleep 0.5 && ifup wlan0 + fi +} + +while getopts "h" c; do + case "${c}" in + h) usage; exit;; + esac +done + +if [ -f "${syspower}" ]; then + # Pre-suspend actions + suspend_interfaces + + # Suspend the device + printf "mem" > ${syspower} + sleep .5 + + # Post-resume actions + resume_interfaces +else + printf "\n[ERROR] File ${syspower} not found\n\n" +fi diff --git a/meta-digi-dey/recipes-core/busybox/busybox_1.23.2.bbappend b/meta-digi-dey/recipes-core/busybox/busybox_1.23.2.bbappend index db220bd20..89ba06284 100644 --- a/meta-digi-dey/recipes-core/busybox/busybox_1.23.2.bbappend +++ b/meta-digi-dey/recipes-core/busybox/busybox_1.23.2.bbappend @@ -74,3 +74,5 @@ do_install_append() { ln -s ../if-pre-up.d/bridgeifupdown ${D}${sysconfdir}/network/if-post-down.d/bridgeifupdown fi } + +PACKAGE_ARCH = "${MACHINE_ARCH}"