Auto shutdown Script on Linux
http://odroid.com/dokuwiki/doku.php?id=en:odroid-ups2
We will use UPS on Android.
Select CONFIG_GPIO_SYSFS
build kernel
$ make -j8copy drivers
$ adb remount$ find -name *.ko | xargs -i adb push {} /system/lib/modules/
write kernel
# fastboot flash kernel arch/arm/boot/zImage# fastboot reboot
make ups2.sh
-------------------------------------------------------------------------------------------------------------------#!/bin/sh
SYSFS_GPIO_DIR="/sys/class/gpio"
retval=""
gpio_export()
{
[ -e "$SYSFS_GPIO_DIR/gpio$1" ] && return 0
echo $1 > "$SYSFS_GPIO_DIR/export"
echo $1
}
gpio_getvalue()
{
echo in > "$SYSFS_GPIO_DIR/gpio$1/direction"
val=`cat "$SYSFS_GPIO_DIR/gpio$1/value"`
retval=$val
}
gpio_setvalue()
{
echo out > "$SYSFS_GPIO_DIR/gpio$1/direction"
echo $2 > "$SYSFS_GPIO_DIR/gpio$1/value"
}
AC_OK_GPIO=199
BAT_OK_GPIO=200
LATCH_GPIO=204
gpio_export $LATCH_GPIO
gpio_setvalue $LATCH_GPIO 1
check()
{
gpio_export $AC_OK_GPIO
gpio_export $BAT_OK_GPIO
gpio_getvalue $AC_OK_GPIO
if [ $retval -eq 1 ]
then
echo "DC Input Okay"
else
echo "Power is shutdown or AC Adaptor is disconnected"
gpio_getvalue $BAT_OK_GPIO
echo $retval
if [ $retval -eq 0 ]
then
echo "battery is low than 3.7V"
poweroff -d 5
else
echo "battery is good"
fi
fi
}
while true
do check
sleep 2
done
-------------------------------------------------------------------------------------------------------------------
copy script and modify permission.
$ adb remount$ adb push ups2.sh /system/bin
$ adb shell
# chmod 777 /system/bin/ups2.sh
register service
# mount -o rw,remount /# vi /init.odroidu.rc
add this in end of file.
service ups /system/bin/ups2.sh
class core
user root
group root
oneshot
Power is shutdown or AC Adaptor is disconnected
1
battery is good
Power is shutdown or AC Adaptor is disconnected
1
battery is good
Power is shutdown or AC Adaptor is disconnected
1
battery is good
Power is shutdown or AC Adaptor is disconnected
0
battery is low than 3.7V
[ 88.089377] SysRq : Emergency Remount R/O
[ 88.093736] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
[ 88.099412] EXT4-fs (mmcblk0p3): re-mounted. Opts: (null)
[ 88.105858] EXT4-fs (mmcblk0p4): re-mounted. Opts: (null)
[ 88.112916] Emergency Remount complete
[ 88.191188] exynos4_notifier_call : System Rrestart notifier call!
[ 88.191714] exynos4_notifier_call : Done!
[ 88.195726] REBOOT Notifier for CPUFREQ
[ 88.200303] Disabling non-boot CPUs ...
[ 88.204077] CPU1: shutdown
[ 88.206946] CPU2: shutdown
[ 88.209279] CPU3: shutdown
[ 88.211703] Restarting system.
댓글 없음:
댓글 쓰기