From 7cc4acff1ab567d8d4ecaa9f1a4b5d5af4c69c2e Mon Sep 17 00:00:00 2001 From: Michel-FK Date: Fri, 1 Jan 2021 16:02:43 +0100 Subject: [PATCH] use new Instant Play system Signed-off-by: Michel-FK --- .../etc/funkey_gpio_mapping.conf | 2 +- .../board/funkey/rootfs-overlay/etc/inittab | 8 +-- .../board/funkey/rootfs-overlay/root/.profile | 3 +- .../usr/games/launchers/gamegear_launch.sh | 9 ++- .../usr/games/launchers/gb_launch.sh | 8 ++- .../usr/games/launchers/gba_launch_gpsp.sh | 9 ++- .../games/launchers/gba_launch_mednafen.sh | 8 ++- .../usr/games/launchers/lynx_launch.sh | 9 ++- .../games/launchers/mame_launch_mednafen.sh | 9 ++- .../usr/games/launchers/megadrive_launch.sh | 8 ++- .../usr/games/launchers/nes_launch.sh | 7 ++- .../usr/games/launchers/ngp_launch.sh | 9 ++- .../usr/games/launchers/pce_launch.sh | 9 ++- .../games/launchers/psone_launch_mednafen.sh | 9 ++- .../usr/games/launchers/psone_launch_pcsx.sh | 9 ++- .../usr/games/launchers/sms_launch.sh | 8 ++- .../usr/games/launchers/snes_launch.sh | 8 ++- .../games/launchers/snes_launch_mednafen.sh | 8 ++- .../usr/games/launchers/wonderswan_launch.sh | 9 ++- .../usr/local/sbin/assembly_tests | 10 ++++ .../usr/local/sbin/cancel_sched_powerdown | 11 ++++ .../rootfs-overlay/usr/local/sbin/erase_pid | 12 ++++ .../usr/local/sbin/instant_play | 37 ++++++++++++ .../usr/local/sbin/kill_emulators | 4 -- .../rootfs-overlay/usr/local/sbin/record_pid | 12 ++++ .../usr/local/sbin/sched_shutdown | 20 ++++--- .../usr/local/sbin/shutdown_funkey | 2 + .../usr/local/sbin/signal_usr1_to_emulators | 23 ------- .../usr/local/sbin/start_launcher | 60 ++++++++++--------- FunKey/package/FCEUX/FCEUX.mk | 2 +- FunKey/package/PCSX-ReARMed/PCSX-ReARMed.mk | 2 +- FunKey/package/PocketSNES/PocketSNES.mk | 2 +- FunKey/package/gnuboy/gnuboy.mk | 2 +- FunKey/package/gpsp/gpsp.mk | 2 +- FunKey/package/mednafen/mednafen.mk | 2 +- FunKey/package/picodrive/picodrive.mk | 2 +- 36 files changed, 254 insertions(+), 100 deletions(-) create mode 100755 FunKey/board/funkey/rootfs-overlay/usr/local/sbin/cancel_sched_powerdown create mode 100755 FunKey/board/funkey/rootfs-overlay/usr/local/sbin/erase_pid create mode 100755 FunKey/board/funkey/rootfs-overlay/usr/local/sbin/instant_play delete mode 100755 FunKey/board/funkey/rootfs-overlay/usr/local/sbin/kill_emulators create mode 100755 FunKey/board/funkey/rootfs-overlay/usr/local/sbin/record_pid delete mode 100755 FunKey/board/funkey/rootfs-overlay/usr/local/sbin/signal_usr1_to_emulators diff --git a/FunKey/board/funkey/rootfs-overlay/etc/funkey_gpio_mapping.conf b/FunKey/board/funkey/rootfs-overlay/etc/funkey_gpio_mapping.conf index 11a4e43..e42c37d 100644 --- a/FunKey/board/funkey/rootfs-overlay/etc/funkey_gpio_mapping.conf +++ b/FunKey/board/funkey/rootfs-overlay/etc/funkey_gpio_mapping.conf @@ -53,7 +53,7 @@ 7+13, SHELL_COMMAND, quick_action_volume_down, Fn+A, Volume-- 7+11, SHELL_COMMAND, quick_action_bright_up, Fn+B, Brightness++ 7+14, SHELL_COMMAND, quick_action_bright_down, Fn+X, Brightness-- -10, SHELL_COMMAND, sched_shutdown 1 & signal_usr1_to_emulators, N_OE, Quick save and Poweroff because of N_OE +10, SHELL_COMMAND, sched_shutdown 1, N_OE, Instant Play save and Poweroff because of N_OE 7+15+2, SHELL_COMMAND, display_notif_system_stats, Fn+L1+L2, display system cpu and ram usage #7+12, KEYBOARD, KEY_G, KEY_G, Brightness++ diff --git a/FunKey/board/funkey/rootfs-overlay/etc/inittab b/FunKey/board/funkey/rootfs-overlay/etc/inittab index 005aff9..b0d4598 100644 --- a/FunKey/board/funkey/rootfs-overlay/etc/inittab +++ b/FunKey/board/funkey/rootfs-overlay/etc/inittab @@ -38,7 +38,7 @@ null::sysinit:/bin/ln -sf /proc/self/fd/2 /dev/stderr #::ctrlaltdel:/sbin/reboot # Stuff to do before rebooting -::shutdown:/etc/init.d/rcK -::shutdown:/sbin/swapoff -a -::shutdown:/bin/umount -r / -::shutdown:/bin/umount -r /mnt +#::shutdown:/etc/init.d/rcK +#::shutdown:/sbin/swapoff -a +#::shutdown:/bin/umount -r / +#::shutdown:/bin/umount -r /mnt diff --git a/FunKey/board/funkey/rootfs-overlay/root/.profile b/FunKey/board/funkey/rootfs-overlay/root/.profile index eb33949..2b3fefe 100755 --- a/FunKey/board/funkey/rootfs-overlay/root/.profile +++ b/FunKey/board/funkey/rootfs-overlay/root/.profile @@ -56,4 +56,5 @@ assembly_tests >/dev/null 2>&1 # Start launcher echo "Start launcher" -start_launcher >/dev/null 2>&1 & +#start_launcher >/dev/null 2>&1 & +start_launcher & diff --git a/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/gamegear_launch.sh b/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/gamegear_launch.sh index ad784a4..a3a4932 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/gamegear_launch.sh +++ b/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/gamegear_launch.sh @@ -1,8 +1,13 @@ #!/bin/sh -# Security cp /usr/games/mednafen-09x.cfg ${MEDNAFEN_HOME}/ export HOME=/tmp/funkey mkdir -p ${HOME} cd ${HOME} -mednafen -fs 1 -gg.stretch full "$1" + +# Launch the process in background, record the PID into a file, wait +# for the process to terminate and erase the recorded PID +mednafen -fs 1 -gg.stretch full "$1"& +record_pid $! +wait $! +erase_pid diff --git a/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/gb_launch.sh b/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/gb_launch.sh index e720655..2e0a542 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/gb_launch.sh +++ b/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/gb_launch.sh @@ -3,4 +3,10 @@ export HOME=/tmp/funkey mkdir -p ${HOME} cd ${HOME} -sdlgnuboy --syncrtc "$1" + +# Launch the process in background, record the PID into a file, wait +# for the process to terminate and erase the recorded PID +sdlgnuboy --syncrtc "$1"& +record_pid $! +wait $! +erase_pid diff --git a/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/gba_launch_gpsp.sh b/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/gba_launch_gpsp.sh index 583d447..3ad3baf 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/gba_launch_gpsp.sh +++ b/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/gba_launch_gpsp.sh @@ -2,5 +2,12 @@ export HOME=/tmp/funkey mkdir -p ${HOME} + +# Launch the process in background, record the PID into a file, wait +# for the process to terminate and erase the recorded PID cd ${HOME} -gpsp "$1" +gpsp "$1"& +record_pid $! +wait $! +erase_pid + diff --git a/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/gba_launch_mednafen.sh b/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/gba_launch_mednafen.sh index 583d447..cb7e912 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/gba_launch_mednafen.sh +++ b/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/gba_launch_mednafen.sh @@ -3,4 +3,10 @@ export HOME=/tmp/funkey mkdir -p ${HOME} cd ${HOME} -gpsp "$1" + +# Launch the process in background, record the PID into a file, wait +# for the process to terminate and erase the recorded PID +gpsp "$1"& +record_pid $! +wait $! +erase_pid diff --git a/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/lynx_launch.sh b/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/lynx_launch.sh index b49b791..1a97211 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/lynx_launch.sh +++ b/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/lynx_launch.sh @@ -1,8 +1,13 @@ #!/bin/sh -# Security cp /usr/games/mednafen-09x.cfg ${MEDNAFEN_HOME}/ export HOME=/tmp/funkey mkdir -p ${HOME} cd ${HOME} -mednafen -fs 1 -lynx.stretch full "$1" + +# Launch the process in background, record the PID into a file, wait +# for the process to terminate and erase the recorded PID +mednafen -fs 1 -lynx.stretch full "$1"& +record_pid $! +wait $! +erase_pid diff --git a/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/mame_launch_mednafen.sh b/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/mame_launch_mednafen.sh index cc29289..877da04 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/mame_launch_mednafen.sh +++ b/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/mame_launch_mednafen.sh @@ -1,8 +1,13 @@ #!/bin/sh -# Security cp /usr/games/mednafen-09x.cfg ${MEDNAFEN_HOME}/ export HOME=/tmp/funkey mkdir -p ${HOME} cd ${HOME} -mednafen -sound 1 -soundrate 22050 -soundbufsize 100 -vdriver sdl -frameskip 1 -fs 0 "$1" + +# Launch the process in background, record the PID into a file, wait +# for the process to terminate and erase the recorded PID +mednafen -sound 1 -soundrate 22050 -soundbufsize 100 -vdriver sdl -frameskip 1 -fs 0 "$1"& +record_pid $! +wait $! +erase_pid diff --git a/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/megadrive_launch.sh b/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/megadrive_launch.sh index 0186681..1ba8664 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/megadrive_launch.sh +++ b/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/megadrive_launch.sh @@ -3,4 +3,10 @@ export HOME=/tmp/funkey mkdir -p ${HOME} cd ${HOME} -PicoDrive "$1" + +# Launch the process in background, record the PID into a file, wait +# for the process to terminate and erase the recorded PID +PicoDrive "$1"& +record_pid $! +wait $! +erase_pid diff --git a/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/nes_launch.sh b/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/nes_launch.sh index 0555e12..5a419fc 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/nes_launch.sh +++ b/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/nes_launch.sh @@ -3,5 +3,10 @@ export HOME=/tmp/funkey mkdir -p ${HOME} cd ${HOME} -fceux "$1" +# Launch the process in background, record the PID into a file, wait +# for the process to terminate and erase the recorded PID +fceux "$1"& +record_pid $! +wait $! +erase_pid diff --git a/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/ngp_launch.sh b/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/ngp_launch.sh index 0e50eba..e1808cc 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/ngp_launch.sh +++ b/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/ngp_launch.sh @@ -1,8 +1,13 @@ #!/bin/sh -# Security cp /usr/games/mednafen-09x.cfg ${MEDNAFEN_HOME}/ export HOME=/tmp/funkey mkdir -p ${HOME} cd ${HOME} -mednafen -fs 1 -ngp.stretch full "$1" + +# Launch the process in background, record the PID into a file, wait +# for the process to terminate and erase the recorded PID +mednafen -fs 1 -ngp.stretch full "$1"& +record_pid $! +wait $! +erase_pid diff --git a/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/pce_launch.sh b/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/pce_launch.sh index 9bd08eb..81b4477 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/pce_launch.sh +++ b/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/pce_launch.sh @@ -1,8 +1,13 @@ #!/bin/sh -# Security cp /usr/games/mednafen-09x.cfg ${MEDNAFEN_HOME}/ export HOME=/tmp/funkey mkdir -p ${HOME} cd ${HOME} -mednafen -fs 1 -force_module pce_fast -pce_fast.stretch full "$1" + +# Launch the process in background, record the PID into a file, wait +# for the process to terminate and erase the recorded PID +mednafen -fs 1 -force_module pce_fast -pce_fast.stretch full "$1"& +record_pid $! +wait $! +erase_pid diff --git a/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/psone_launch_mednafen.sh b/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/psone_launch_mednafen.sh index 3afc12d..abf0514 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/psone_launch_mednafen.sh +++ b/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/psone_launch_mednafen.sh @@ -1,6 +1,11 @@ #!/bin/sh -export HOME=/tmp/funkey mkdir -p ${HOME} cd ${HOME} -pcsx -frameskip -cdfile "$1" + +# Launch the process in background, record the PID into a file, wait +# for the process to terminate and erase the recorded PID +pcsx -frameskip -cdfile "$1"& +record_pid $! +wait $! +erase_pid diff --git a/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/psone_launch_pcsx.sh b/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/psone_launch_pcsx.sh index f6c3e48..2db7452 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/psone_launch_pcsx.sh +++ b/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/psone_launch_pcsx.sh @@ -3,5 +3,10 @@ export HOME=/tmp/funkey mkdir -p ${HOME} cd ${HOME} -#pcsx -frameskip -cdfile "$1" -pcsx -cdfile "$1" + +# Launch the process in background, record the PID into a file, wait +# for the process to terminate and erase the recorded PID +pcsx -cdfile "$1"& +record_pid $! +wait $! +erase_pid diff --git a/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/sms_launch.sh b/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/sms_launch.sh index 0186681..1ba8664 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/sms_launch.sh +++ b/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/sms_launch.sh @@ -3,4 +3,10 @@ export HOME=/tmp/funkey mkdir -p ${HOME} cd ${HOME} -PicoDrive "$1" + +# Launch the process in background, record the PID into a file, wait +# for the process to terminate and erase the recorded PID +PicoDrive "$1"& +record_pid $! +wait $! +erase_pid diff --git a/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/snes_launch.sh b/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/snes_launch.sh index 5a5e718..3e7093a 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/snes_launch.sh +++ b/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/snes_launch.sh @@ -3,4 +3,10 @@ export HOME=/tmp/funkey mkdir -p ${HOME} cd ${HOME} -psnes "$1" + +# Launch the process in background, record the PID into a file, wait +# for the process to terminate and erase the recorded PID +psnes "$1"& +record_pid $! +wait $! +erase_pid diff --git a/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/snes_launch_mednafen.sh b/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/snes_launch_mednafen.sh index 5a5e718..3e7093a 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/snes_launch_mednafen.sh +++ b/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/snes_launch_mednafen.sh @@ -3,4 +3,10 @@ export HOME=/tmp/funkey mkdir -p ${HOME} cd ${HOME} -psnes "$1" + +# Launch the process in background, record the PID into a file, wait +# for the process to terminate and erase the recorded PID +psnes "$1"& +record_pid $! +wait $! +erase_pid diff --git a/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/wonderswan_launch.sh b/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/wonderswan_launch.sh index b274169..93fbd91 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/wonderswan_launch.sh +++ b/FunKey/board/funkey/rootfs-overlay/usr/games/launchers/wonderswan_launch.sh @@ -1,8 +1,13 @@ #!/bin/sh -# Security cp /usr/games/mednafen-09x.cfg ${MEDNAFEN_HOME}/ export HOME=/tmp/funkey mkdir -p ${HOME} cd ${HOME} -mednafen -fs 1 -wswan.stretch full "$1" + +# Launch the process in background, record the PID into a file, wait +# for the process to terminate and erase the recorded PID +mednafen -fs 1 -wswan.stretch full "$1"& +record_pid $! +wait $! +erase_pid diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/assembly_tests b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/assembly_tests index 1b9f2c2..d4a3aef 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/assembly_tests +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/assembly_tests @@ -1,5 +1,9 @@ #!/bin/sh +## Register ourself as the running FunKey task for receiving USR1 +## signal for shutting down +echo $$ > "/var/run/funkey.pid" + ## Check if tests must be run RUN_ENV_VAR=$(fw_printenv -n assembly_tests 2>/dev/null) if [ "x${RUN_ENV_VAR}" != "x1" ]; then @@ -40,6 +44,9 @@ function function_magnet_detected_ok { ## Kill scheduled shutdown pkill sched_shutdown + ## Kill the funkey_prod_screen binary + killall -s USR1 "${PROD_SCREEN_BIN} > /dev/null 2>&1 + ## Write magnet_detected file if $test_failed; then echo "1" > $MAGNET_DETECTED_FILE @@ -58,6 +65,9 @@ function function_magnet_detected_ok { ## Function called when SIGUSR1 is caught while NOT waiting for it function function_magnet_detected_ko { echo "ERROR: Caught SIGUSR1 signal (magnet detected!)" + + ## Kill the funkey_prod_screen binary + killall -s USR1 "${PROD_SCREEN_BIN} > /dev/null 2>&1 sync } diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/cancel_sched_powerdown b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/cancel_sched_powerdown new file mode 100755 index 0000000..2952a44 --- /dev/null +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/cancel_sched_powerdown @@ -0,0 +1,11 @@ +#!/bin/sh + +# Uncomment the following line to get debug info +#set -x + +if [ ${#} != 0 ]; then + echo "Usage: $(basename ${0})" + exit 1 +fi +pkill sched_powerdown +exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/erase_pid b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/erase_pid new file mode 100755 index 0000000..afb3597 --- /dev/null +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/erase_pid @@ -0,0 +1,12 @@ +#!/bin/sh + +# Uncomment the following line to get debug info +#set -x + +# Check args +if [ ${#} -ne 0 ]; then + echo "Usage: $(basename ${0})" + exit 1 +fi +rm -f /var/run/funkey.pid +exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/instant_play b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/instant_play new file mode 100755 index 0000000..42db9a0 --- /dev/null +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/instant_play @@ -0,0 +1,37 @@ +#!/bin/sh + +# Uncomment the following line to get debug info +#set -x + +# Check args +if [ ${#} -eq 0 ]; then + echo "Usage: $(basename ${0}) args..." + exit 1 +fi + +INSTANT_PLAY_FILE="/mnt/instant_play" + +# Write quick load file args +echo -n "" > "${INSTANT_PLAY_FILE}" +for arg in "$@"; do + if $(echo "${arg}" | egrep -q '[[:space:]]'); then + + # Add quotes around arguments containing spaces + echo -n "\"${arg}\" " >> "${INSTANT_PLAY_FILE}" + else + echo -n "${arg} " >> "${INSTANT_PLAY_FILE}" + fi +done + +# Add the magic sauce to launch the process in background, record the +# PID into a file, wait for the process to terminate and erase the +# recorded PID +cat << EOF >> "${INSTANT_PLAY_FILE}" +& +record_pid \$! +wait \$! +erase_pid +EOF + +# Now terminate gracefully +exec shutdown_funkey diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/kill_emulators b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/kill_emulators deleted file mode 100755 index 7e5efd8..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/kill_emulators +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -killall mednafen gpsp psnes pcsx sdlgnuboy PicoDriveBin -exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/record_pid b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/record_pid new file mode 100755 index 0000000..0f98bfc --- /dev/null +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/record_pid @@ -0,0 +1,12 @@ +#!/bin/sh + +# Uncomment the following line to get debug info +#set -x + +# Check args +if [ ${#} -ne 1 ]; then + echo "Usage: $(basename ${0}) pid" + exit 1 +fi +echo ${1} > /var/run/funkey.pid +exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/sched_shutdown b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/sched_shutdown index 00ff51f..a775843 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/sched_shutdown +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/sched_shutdown @@ -1,15 +1,21 @@ #!/bin/sh -if [ ${#} != 1 ]; then - echo "Usage: $0 seconds_before_shutdown" +# Uncomment the following line to get debug info +#set -x + +if [ ${#} != 1 -o "${1}" -eq 0 ]; then + echo "Usage: $(basename ${0}) grace_delay" exit 1 fi -nb_secs_to_wait=$1 +# Send USR1 signal to the running FunKey process to warn about +# impending shutdown +pkill -USR1 -F /var/run/funkey.pid > /dev/null 2>&1 -# Wait $nb_secs_to_wait seconds to catch signal USR2 -# If the signal is caught, then it means a process canceled this shutdown -sleep ${nb_secs_to_wait} +# Delay for the given grace period seconds to catch signal USR2. +# If the signal is caught, then it means the running FunKey process +# canceled this shutdown and will handle it by itself. +sleep ${1} -# Too late to cancel: init shutdown +# Delay expired, initiate shutdown shutdown_funkey diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/shutdown_funkey b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/shutdown_funkey index 9f1dc45..a8b2819 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/shutdown_funkey +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/shutdown_funkey @@ -9,5 +9,7 @@ start_audio_amp 0 >/dev/null 2>&1 # Force Read Only ro +umount -r /mnt + # Poweroff poweroff diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/signal_usr1_to_emulators b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/signal_usr1_to_emulators deleted file mode 100755 index fea17d1..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/signal_usr1_to_emulators +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -# This should replaced by storing the correct PID before -# launching an emulator and signaling only this one. - -RUN_ENV_VAR=$(fw_printenv -n assembly_tests 2>/dev/null) -if [ "x${RUN_ENV_VAR}" == "x1" ]; then - # First this one - killall -s USR1 assembly_tests > /dev/null 2>&1 - - # Then this one - killall -s USR1 funkey_prod_screens > /dev/null 2>&1 -fi - -# Send signal to all PCSX first (time critical) -killall -s USR1 pcsx > /dev/null 2>&1 - -# Send signal to all other emulators -killall -s USR1 gpsp psnes sdlgnuboy PicoDrive mednafen fceux > /dev/null 2>&1 - -# Send signal to launchers -killall -s USR1 retrofe gmenu2x > /dev/null 2>&1 - -exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/start_launcher b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/start_launcher index c130bbd..4be736c 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/start_launcher +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/start_launcher @@ -1,58 +1,60 @@ #!/bin/sh -LOCK_FILE=/var/lock/launcher.lock -PREVENT_LAUNCHER_FILE=/mnt/prevent_launcher -PREVENT_LAUNCHER_FILE2=/boot/prevent_launcher -QUICK_LOAD_FILE=/mnt/quick_load_cmd -GMENU2X_FILE=/mnt/gmenu2x -GMENU2X_HOME=/mnt/funkey/.gmenu2x +# Uncomment the following line to get debug info +#set -x -if [ -f ${LOCK_FILE} ]; then +LOCK_FILE="/var/lock/launcher.lock" +INSTANT_PLAY_FILE="/mnt/instant_play" +GMENU2X_FILE="/mnt/gmenu2x" +GMENU2X_HOME="/mnt/funkey/.gmenu2x" + +if [ -f "${LOCK_FILE}" ]; then echo "${LOCK_FILE} already exists" exit 1 fi -touch ${LOCK_FILE} +touch "${LOCK_FILE}" -mkdir -p ${MEDNAFEN_HOME} -cp /usr/games/lynxboot.img /usr/games/mednafen-09x.cfg ${MEDNAFEN_HOME}/ +mkdir -p "${MEDNAFEN_HOME}" +cp "/usr/games/lynxboot.img" "/usr/games/mednafen-09x.cfg" "${MEDNAFEN_HOME}/" -mkdir -p ${GMENU2X_HOME} -mkdir -p /mnt/apps +mkdir -p "${GMENU2X_HOME}" +mkdir -p "/mnt/apps" -# Launch Previous Game -if [ -f ${QUICK_LOAD_FILE} ]; then - command=$(cat ${QUICK_LOAD_FILE}) - echo "Found quick load file, restarting previous game with command:" - echo ${command} - rm ${QUICK_LOAD_FILE} - eval ${command} +# Launch Previous Game if any +if [ -f "${INSTANT_PLAY_FILE}" ]; then + echo "Found Instant Play file, restarting previous game with command: "$(head -n 1 "${INSTANT_PLAY_FILE}") + source "${INSTANT_PLAY_FILE}" + rm -f "${INSTANT_PLAY_FILE}" termfix_all fi -# Loop to launch launcher indefinitely +# Then loop to launch the launcher indefinitely while true; do # Check if prevent launcher file present - if [ -f ${PREVENT_LAUNCHER_FILE} ]; then - echo "Found file: ${PREVENT_LAUNCHER_FILE}, not launching launcher" - sleep 5 - elif [ -f ${PREVENT_LAUNCHER_FILE2} ]; then - echo "Found file: ${PREVENT_LAUNCHER_FILE2}, not launching launcher" + if [ -f "${PREVENT_LAUNCHER_FILE}" ]; then + echo "${PREVENT_LAUNCHER_FILE} file found, not starting launcher" sleep 5 else - if [ -f ${GMENU2X_FILE} ]; then + if [ -f "${GMENU2X_FILE}" ]; then # Launch gmenu2x - gmenu2x + gmenu2x& else # Launch Retrofe - retrofe + retrofe& fi + # Record the PID into a file, wait for the + # process to terminate and erase the recorded PID + record_pid $! + wait $! + erase_pid + # In case retrofe quits with errors, clear graphic VT termfix_all fi done -rm ${LOCK_FILE} +rm "${LOCK_FILE}" exit 0 diff --git a/FunKey/package/FCEUX/FCEUX.mk b/FunKey/package/FCEUX/FCEUX.mk index d811996..7a0cc30 100644 --- a/FunKey/package/FCEUX/FCEUX.mk +++ b/FunKey/package/FCEUX/FCEUX.mk @@ -4,7 +4,7 @@ # ################################################################################ -FCEUX_VERSION = 12a0245 +FCEUX_VERSION = addf9a3 FCEUX_SITE_METHOD = git FCEUX_SITE = https://github.com/FunKey-Project/fceux.git FCEUX_LICENSE = GPL-2.0 diff --git a/FunKey/package/PCSX-ReARMed/PCSX-ReARMed.mk b/FunKey/package/PCSX-ReARMed/PCSX-ReARMed.mk index 2b9863d..01045d0 100644 --- a/FunKey/package/PCSX-ReARMed/PCSX-ReARMed.mk +++ b/FunKey/package/PCSX-ReARMed/PCSX-ReARMed.mk @@ -4,7 +4,7 @@ # ################################################################################ -PCSX_REARMED_VERSION = dd50647 +PCSX_REARMED_VERSION = d048e75a PCSX_REARMED_SITE_METHOD = git PCSX_REARMED_SITE = https://github.com/FunKey-Project/pcsx_rearmed.git PCSX_REARMED_LICENSE = GPL-2.0 diff --git a/FunKey/package/PocketSNES/PocketSNES.mk b/FunKey/package/PocketSNES/PocketSNES.mk index 9dd8f34..ccee7f6 100644 --- a/FunKey/package/PocketSNES/PocketSNES.mk +++ b/FunKey/package/PocketSNES/PocketSNES.mk @@ -4,7 +4,7 @@ # ################################################################################ -POCKETSNES_VERSION = PocketSNES-FunKey-1.00 +POCKETSNES_VERSION = 2d5e38d POCKETSNES_SITE_METHOD = git POCKETSNES_SITE = https://github.com/FunKey-Project/PocketSNES.git POCKETSNES_LICENSE = GPL-2.0 diff --git a/FunKey/package/gnuboy/gnuboy.mk b/FunKey/package/gnuboy/gnuboy.mk index 201568e..b434ec0 100644 --- a/FunKey/package/gnuboy/gnuboy.mk +++ b/FunKey/package/gnuboy/gnuboy.mk @@ -4,7 +4,7 @@ # ################################################################################ -GNUBOY_VERSION = gnuboy-FunKey-1.00 +GNUBOY_VERSION = 63fcd82 GNUBOY_SITE_METHOD = git GNUBOY_SITE = https://github.com/FunKey-Project/gnuboy.git GNUBOY_LICENSE = GPL-2.0 diff --git a/FunKey/package/gpsp/gpsp.mk b/FunKey/package/gpsp/gpsp.mk index 1fbbd56..8ad3d63 100644 --- a/FunKey/package/gpsp/gpsp.mk +++ b/FunKey/package/gpsp/gpsp.mk @@ -4,7 +4,7 @@ # ################################################################################ -GPSP_VERSION = gpsp-FunKey-1.00 +GPSP_VERSION = fd81d8a GPSP_SITE_METHOD = git GPSP_SITE = https://github.com/FunKey-Project/gpsp.git GPSP_LICENSE = GPL-2.0 diff --git a/FunKey/package/mednafen/mednafen.mk b/FunKey/package/mednafen/mednafen.mk index de16fe9..ff86718 100644 --- a/FunKey/package/mednafen/mednafen.mk +++ b/FunKey/package/mednafen/mednafen.mk @@ -4,7 +4,7 @@ # ################################################################################ -MEDNAFEN_VERSION = 6016b5f +MEDNAFEN_VERSION = 6f4755e3 MEDNAFEN_SITE_METHOD = git MEDNAFEN_SITE = https://github.com/FunKey-Project/mednafen-git.git MEDNAFEN_LICENSE = GPL-2.0+ diff --git a/FunKey/package/picodrive/picodrive.mk b/FunKey/package/picodrive/picodrive.mk index ffbd88c..43a1a66 100644 --- a/FunKey/package/picodrive/picodrive.mk +++ b/FunKey/package/picodrive/picodrive.mk @@ -4,7 +4,7 @@ # ################################################################################ -PICODRIVE_VERSION = picodrive-FunKey-1.00 +PICODRIVE_VERSION = e37c0fa PICODRIVE_SITE_METHOD = git PICODRIVE_SITE = https://github.com/FunKey-Project/picodrive.git PICODRIVE_LICENSE = MAME