Some NG Amlogic boxes can’t wake from suspend by IR remote. The bl301 tool fixes this problem, but it’s not compatible with secure boot devices or encrypted bootloaders, like newer AM6+ and FireTV 2nd gen Cube.
An alternative to CE’s suspend (suspend-to-ram) is to use the suspend-to-idle option, which is one stage above suspend-to-ram. The IR receiver remains active, and can be woken with an IR power button press on any Amlogic device.
Suspend-to-idle puts all but one CPU offline, freezes all user space processes, and puts some other hardware offline. It reduces power consumption, but not to as much of an extent as suspend-to-ram.
This script freezes Kodi, and wakes it with an IR power key press. Wakeup is as fast as is possible, ~2-3sec.
Summary
#!/bin/sh
# Disable anything that might wake from suspend early
# echo disabled > /sys/devices/platform/bt-dev/power/wakeup
# echo disabled > /sys/devices/platform/ff80023c.aocec/power/wakeup
echo disabled > /sys/devices/platform/rtc/power/wakeup
echo disabled > /sys/devices/platform/rtc/input/input1/power/wakeup
# Turn off TV
printf '\x20\x36' > /dev/aocec
# Pause Kodi
pkill -STOP kodi.bin
# Suspend-to-idle
echo freeze > /sys/power/state
# Wakeup
# Turn on TV
printf '\x20\x04' > /dev/aocec
# Reset meson_remote
modprobe -r meson_remote && modprobe meson_remote
remotecfg /storage/.config/remote.conf
# Unpause Kodi
pkill -CONT kodi.bin
This version stops Kodi, freezes all processes, and restarts Kodi on wakeup. Wakeup is slower due to Kodi restarting.
Summary
#!/bin/sh
# Disable anything that might wake from suspend early
# echo disabled > /sys/devices/platform/bt-dev/power/wakeup
# echo disabled > /sys/devices/platform/ff80023c.aocec/power/wakeup
echo disabled > /sys/devices/platform/rtc/power/wakeup
echo disabled > /sys/devices/platform/rtc/input/input1/power/wakeup
systemctl mask systemd-poweroff.service
systemctl stop kodi
# Suspend-to-idle
echo freeze > /sys/power/state
# Wakeup commands
# Reset meson_remote
modprobe -r meson_remote && modprobe meson_remote
remotecfg /storage/.config/remote.conf
systemctl start kodi
sleep 10
systemctl unmask systemd-poweroff.service
The default CE suspend can be seamlessly replaced, by adding the suspend-to-idle script to systemd-suspend.service, and placing it at /storage/.config/system.d/ systemd-suspend.service
(samba ConfigFiles/system.d/systemd-suspend.service). Will be active after the next reboot
Summary
[Unit]
Description=System Suspend
[Service]
Type=oneshot
ExecStart=/bin/sh -c "\
systemctl mask suspend.target; \
\
# Disable anything that might wake from suspend early \
# echo disabled > /sys/devices/platform/bt-dev/power/wakeup \
# echo disabled > /sys/devices/platform/ff80023c.aocec/power/wakeup \
echo disabled > /sys/devices/platform/rtc/power/wakeup; \
echo disabled > /sys/devices/platform/rtc/input/input1/power/wakeup; \
echo disabled > /sys/devices/platform/ff3f0000.ethernet/power/wakeup; \
\
# Turn off TV \
printf '\x20\x36' > /dev/aocec; \
\
# Pause Kodi \
pkill -STOP kodi.bin; \
\
# Suspend-to-idle \
echo freeze > /sys/power/state; \
\
# Wakeup \
# Turn on TV \
printf '\x20\x04' > /dev/aocec & \
\
# Reset meson_remote \
modprobe -r meson_remote && modprobe meson_remote; \
remotecfg /storage/.config/remote.conf; \
\
# Unpause Kodi \
pkill -CONT kodi.bin; \
\
systemctl unmask suspend.target; \
"
I also recommend adding the following line to /storage/.config/autoscript.sh, in case the box is ever powered off completely while in suspend. If the autoscript.sh file wasn’t previously created, you’ll need to create it. Open a plain text file, copy & past the contents below, save it as autostart.sh, copy it to CE over samba to ConfigFiles/autostart.sh
#!/bin/sh
# Make sure suspend is unmasked
systemctl unmask suspend.target
Attached is a copy of systemd-suspend.service. This was tested on the 2nd gen Cube, it’s possible that one or two other pieces of hardware will need to have their wakeup function disabled in the script, to keep other box models from waking from suspend early.
systemd-suspend.service (1.0 KB)