From 62a97a358293bc712b2ad56d6ea7c0210952daab Mon Sep 17 00:00:00 2001 From: "mason.huo" Date: Fri, 14 Oct 2022 13:08:20 +0800 Subject: [PATCH] package: starfive: Add hibernation script to pm package Signed-off-by: mason.huo --- package/starfive/pm/S00hibernation | 22 ++++++++++++++++++++++ package/starfive/pm/pm.mk | 1 + 2 files changed, 23 insertions(+) create mode 100644 package/starfive/pm/S00hibernation diff --git a/package/starfive/pm/S00hibernation b/package/starfive/pm/S00hibernation new file mode 100644 index 00000000..d3bab548 --- /dev/null +++ b/package/starfive/pm/S00hibernation @@ -0,0 +1,22 @@ +#!/bin/sh +# +# hibernation This shell script to turn on swap partition and +# set the image_size as big as ram size. + +case "$1" in + start) + # Set the hibernation image_size as large as the ram size. + total_mem=$(cat /proc/meminfo | sed -n '1p') + echo $((${total_mem: 10: 15}*1024)) > /sys/power/image_size + swapon PARTLABEL="hibernation" + ;; + stop) + swapoff PARTLABEL="hibernation" + ;; + *) + echo "Usage: $0 {start|stop}" + exit 1 +esac + +exit 0 + diff --git a/package/starfive/pm/pm.mk b/package/starfive/pm/pm.mk index 2b5eb0e1..e1748225 100644 --- a/package/starfive/pm/pm.mk +++ b/package/starfive/pm/pm.mk @@ -7,6 +7,7 @@ PM_LICENSE = GPL-2.0+ define PM_INSTALL_TARGET_CMDS install -m 0755 -D package/starfive/pm/S90cpufreq $(TARGET_DIR)/etc/init.d/ + install -m 0755 -D package/starfive/pm/S00hibernation $(TARGET_DIR)/etc/init.d/ endef $(eval $(generic-package))