diff --git a/FunKey/Config.in b/FunKey/Config.in index 49f20d4..9eb6313 100644 --- a/FunKey/Config.in +++ b/FunKey/Config.in @@ -18,3 +18,4 @@ source "$BR2_EXTERNAL_FUNKEY_PATH/package/agg/Config.in" source "$BR2_EXTERNAL_FUNKEY_PATH/package/fluidlite/Config.in" source "$BR2_EXTERNAL_FUNKEY_PATH/package/libmikmod/Config.in" source "$BR2_EXTERNAL_FUNKEY_PATH/package/commander/Config.in" +source "$BR2_EXTERNAL_FUNKEY_PATH/package/bibi/Config.in" diff --git a/FunKey/board/funkey/rootfs-overlay/etc/fkgpiod.conf b/FunKey/board/funkey/rootfs-overlay/etc/fkgpiod.conf index 49ef00e..2325877 100644 --- a/FunKey/board/funkey/rootfs-overlay/etc/fkgpiod.conf +++ b/FunKey/board/funkey/rootfs-overlay/etc/fkgpiod.conf @@ -15,11 +15,11 @@ MAP B TO KEY KEY_B MAP X TO KEY KEY_X MAP Y TO KEY KEY_Y MAP MENU TO KEY KEY_Q -MAP FN+UP TO COMMAND snap -MAP FN+A TO COMMAND quick_action_volume_up -MAP FN+Y TO COMMAND quick_action_volume_down -MAP FN+X TO COMMAND quick_action_bright_up -MAP FN+B TO COMMAND quick_action_bright_down +MAP FN+UP TO COMMAND snapshot +MAP FN+A TO COMMAND volume up +MAP FN+Y TO COMMAND volume down +MAP FN+X TO COMMAND brightness up +MAP FN+B TO COMMAND brightness down MAP FN+L TO KEY KEY_V MAP FN+R TO KEY KEY_O -MAP FN+L+R TO COMMAND display_notif_system_stats +MAP FN+L+R TO COMMAND system_stats toggle diff --git a/FunKey/board/funkey/rootfs-overlay/etc/issue b/FunKey/board/funkey/rootfs-overlay/etc/issue index d8e1e20..8bd19bc 100644 --- a/FunKey/board/funkey/rootfs-overlay/etc/issue +++ b/FunKey/board/funkey/rootfs-overlay/etc/issue @@ -5,6 +5,6 @@ |___| |_____|__|__||__|\__||_____|___ | FUN ON A KEYCHAIN |_____| ----------------------------------------------------- - Version 2.2.0 + Version 2.3.0 ----------------------------------------------------- diff --git a/FunKey/board/funkey/rootfs-overlay/etc/os-release b/FunKey/board/funkey/rootfs-overlay/etc/os-release index 946739f..ad8be6d 100644 --- a/FunKey/board/funkey/rootfs-overlay/etc/os-release +++ b/FunKey/board/funkey/rootfs-overlay/etc/os-release @@ -1,12 +1,12 @@ NAME="FunKey-OS" -VERSION="2.2.0 (Pyromaniac Penguin)" +VERSION="2.3.0 (Zen Zebu)" ID=funkey ID_LIKE=buildroot -PRETTY_NAME="FunKey-OS 2.2.0" -VERSION_ID="2.2.0" +PRETTY_NAME="FunKey-OS 2.3.0" +VERSION_ID="2.3.0" HOME_URL="https://www.funkey-project.com/" SUPPORT_URL="https://www.funkey-project.com/" BUG_REPORT_URL="https://www.funkey-project.com/" PRIVACY_POLICY_URL="https://www.funkey-project.com" -VERSION_CODENAME=Pyromaniac -UBUNTU_CODENAME=Pyromaniac +VERSION_CODENAME=Zen +UBUNTU_CODENAME=Zen diff --git a/FunKey/board/funkey/rootfs-overlay/etc/sw-versions b/FunKey/board/funkey/rootfs-overlay/etc/sw-versions index 0730586..879e564 100644 --- a/FunKey/board/funkey/rootfs-overlay/etc/sw-versions +++ b/FunKey/board/funkey/rootfs-overlay/etc/sw-versions @@ -1 +1 @@ -rootfs 2.2.0 +rootfs 2.3.0 diff --git a/FunKey/board/funkey/rootfs-overlay/root/.profile b/FunKey/board/funkey/rootfs-overlay/root/.profile index cad4256..15ec1c8 100755 --- a/FunKey/board/funkey/rootfs-overlay/root/.profile +++ b/FunKey/board/funkey/rootfs-overlay/root/.profile @@ -18,13 +18,46 @@ alias l='ls $LS_OPTIONS -lA' # alias cp='cp -i' # alias mv='mv -i' +# Alias functions for compatibility +volume_get() { + volume get "$@" +} + +volume_set() { + volume set "$@" +} + +brightness_get() { + brightness get "$@" +} + +brightness_set() { + brightness set "$@" +} + +notif_set() { + notif set "$@" +} + +start_audio_amp() { + audio_amp "$@" +} + +cancel_sched_powerdown() { + powerdown handle +} + # Relocate HOME into the r/w partition export HOME=/mnt/FunKey mkdir -p "${HOME}" export MEDNAFEN_HOME=$HOME/.mednafen mkdir -p "${MEDNAFEN_HOME}" +cp "/usr/games/lynxboot.img" "/usr/games/mednafen-09x.cfg" "${MEDNAFEN_HOME}/" export GMENU2X_HOME="$HOME/.gmenu2x" mkdir -p "${GMENU2X_HOME}" +export RETROFE_HOME="$HOME/.retrofe" +mkdir -p "${RETROFE_HOME}" +mkdir -p "${RETROFE_HOME}/layouts" # Resize the console to the terminal dimensions resize() { @@ -44,22 +77,20 @@ resize() { fi } +# Restore saved volume +echo "Restore saved volume" +volume set $(volume get) >/dev/null 2>&1 -# Start ampli -echo "Start audio amplifier" -start_audio_amp 1 >/dev/null 2>&1 - -# Force unmute sound card and reset volume -echo "Force unmute sound card and reset volume" -volume_set $(volume_get) >/dev/null 2>&1 - -# Reset saved brightness -echo "Reset saved brightness" -brightness_set $(brightness_get) >/dev/null 2>&1 +# Restore saved brightness +echo "Restore saved brightness" +brightness set $(brightness get) >/dev/null 2>&1 # Start Assembly tests (blocking process) assembly_tests >/dev/null 2>&1 -# Start launcher -echo "Start launcher" -start_launcher >/dev/null 2>&1 & +# Restart saved application/game if any +instant_play load + +# Start frontend +echo "Start frontend" +frontend init >/dev/null 2>&1 & 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 8364468..44c0072 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 @@ -5,6 +5,6 @@ cp /usr/games/mednafen-09x.cfg ${MEDNAFEN_HOME}/ # 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 $! +pid record $! wait $! -erase_pid +pid erase 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 5ae85d2..83076e7 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,6 +3,6 @@ # Launch the process in background, record the PID into a file, wait # for the process to terminate and erase the recorded PID sdlgnuboy --syncrtc --stereo=0 "$1"& -record_pid $! +pid record $! wait $! -erase_pid +pid erase 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 fb4d910..53b2069 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 @@ -4,7 +4,7 @@ # for the process to terminate and erase the recorded PID cd ${HOME} gpsp "$1"& -record_pid $! +pid record $! wait $! -erase_pid +pid erase 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 88dd220..fbaefaa 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,6 +3,6 @@ # 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 $! +pid record $! wait $! -erase_pid +pid erase 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 300941f..9672270 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 @@ -5,6 +5,6 @@ cp /usr/games/mednafen-09x.cfg ${MEDNAFEN_HOME}/ # 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 $! +pid record $! wait $! -erase_pid +pid erase 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 cca6afe..8d1026e 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 @@ -5,6 +5,6 @@ cp /usr/games/mednafen-09x.cfg ${MEDNAFEN_HOME}/ # 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 $! +pid record $! wait $! -erase_pid +pid erase 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 cf3805a..fc54ba5 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,6 +3,6 @@ # 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 $! +pid record $! wait $! -erase_pid +pid erase 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 e241779..11efc78 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,6 +3,6 @@ # 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 $! +pid record $! wait $! -erase_pid +pid erase 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 54e6eb9..ca5e48e 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 @@ -5,6 +5,6 @@ cp /usr/games/mednafen-09x.cfg ${MEDNAFEN_HOME}/ # 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 $! +pid record $! wait $! -erase_pid +pid erase 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 6c3f914..f98d467 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 @@ -5,6 +5,6 @@ cp /usr/games/mednafen-09x.cfg ${MEDNAFEN_HOME}/ # 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 $! +pid record $! wait $! -erase_pid +pid erase 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 b81a321..cda7247 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 @@ -3,6 +3,6 @@ # 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 $! +pid record $! wait $! -erase_pid +pid erase 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 b2a0613..b49fa61 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,6 +3,6 @@ # 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 $! +pid record $! wait $! -erase_pid +pid erase 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 cf3805a..fc54ba5 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,6 +3,6 @@ # 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 $! +pid record $! wait $! -erase_pid +pid erase 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 e0b39cf..7cf1ea7 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,6 +3,6 @@ # 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 $! +pid record $! wait $! -erase_pid +pid erase 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 e0b39cf..7cf1ea7 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,6 +3,6 @@ # 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 $! +pid record $! wait $! -erase_pid +pid erase 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 69f7ca2..bfb896f 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 @@ -5,6 +5,6 @@ cp /usr/games/mednafen-09x.cfg ${MEDNAFEN_HOME}/ # 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 $! +pid record $! wait $! -erase_pid +pid erase diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/lib/utils b/FunKey/board/funkey/rootfs-overlay/usr/local/lib/utils index ec02b68..0b554c3 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/lib/utils +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/lib/utils @@ -22,16 +22,7 @@ if [ $? -ne 0 ]; then local return_code=$1 shift warn "$@" - notif "$@" + notif set 0 "$@" exit $return_code } fi - -notif () { - info "$@" - printf "$@" > /sys/class/graphics/fb0/notification -} - -clear_notif () { - printf "clear" > /sys/class/graphics/fb0/notification -} 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 973cb5b..4a67fd5 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/assembly_tests +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/assembly_tests @@ -18,7 +18,7 @@ touch ${LOCK_FILE} ## Register ourself as the running FunKey task for receiving USR1 ## signal for shutting down -echo $$ > "/var/run/funkey.pid" +pid record $$ ## Binaries PROD_SCREEN_BIN="/usr/local/sbin/funkey_prod_screens" @@ -42,7 +42,7 @@ QR_CODE_IMG="/root/logs/assembly_tests/qrcode.png" ## Function called when SIGURS1 is caught while waiting for it function function_magnet_detected_ok { ## Kill scheduled shutdown - pkill sched_shutdown + pkill -f "powerdown schedule" ## Write magnet_detected file if $test_failed; then @@ -55,7 +55,7 @@ function function_magnet_detected_ok { ## Clean shutdown echo " Caught SIGUSR1 signal: magnet detected" echo " Rebooting now..." - shutdown_funkey + powerdown now exit 0 } @@ -78,7 +78,7 @@ function launch_tests_up_until_magnet { termfix_all > /dev/null ## Clear all notifs - notif_clear + notif clear ## Test if log file aleady exists if [[ -f $LOG_FILE ]]; then @@ -158,7 +158,7 @@ function launch_tests_up_until_magnet { ## Play 1kHz sine wave echo " Play 2kHz sine wave" - notif_set 0 "^^^ PLAYING SINE WAVE...^^^ ...... ^ ... ...^ .. ..^.. .^. . .^ . ..^ .. ..^ ... ...^ .......^^" + notif set 0 "^^^ PLAYING SINE WAVE...^^^ ...... ^ ... ...^ .. ..^.. .^. . .^ . ..^ .. ..^ ... ...^ .......^^" speaker-test -t sine -s 1 -f 2000 >/dev/null 2>&1 if [ $? -ne 0 ]; then echo " ERROR: SPEAKER SINE" @@ -166,7 +166,7 @@ function launch_tests_up_until_magnet { return fi sync - notif_clear + notif clear ## Launch prod screen test speaker $PROD_SCREEN_BIN SPEAKER 2>&1 @@ -224,7 +224,7 @@ function launch_tests_up_until_magnet { ## Register ourself back as the running FunKey task for receiving USR1 ## signal for shutting down - echo $$ > "/var/run/funkey.pid" + pid record $$ # check magnet test result if [[ "$res" == "0" ]]; then @@ -248,7 +248,7 @@ function launch_tests_after_magnet { #termfix_all > /dev/null ## Clear all notifs - #notif_clear + #notif clear # Log from magnet file echo " Found file: " $MAGNET_DETECTED_FILE @@ -370,6 +370,6 @@ if ! $test_failed; then exit 0 else ## Shutdown - shutdown_funkey & + powerdown now & exit 1 fi diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/audio_amp b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/audio_amp new file mode 100755 index 0000000..25752dd --- /dev/null +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/audio_amp @@ -0,0 +1,59 @@ +#!/bin/sh + +# Uncomment the following line to get debug info +#set -x + +SELF="$(basename ${0})" +SYSTEM_GPIO="/sys/class/gpio" + +# Power Audio Amplifier enable GPIO (('F' - 'A') * 32 + 6 = 166) +GPIO_PF6=166 + +usage() { + >2& echo "Usage: ${SELF} [1|on|ON|On for ON, 0|off|OFF|Off for OFF]" + exit 1 +} + +# Check number of arguments +if [ ${#} -ne 1 ]; then + usage +fi + +case "${1}" in + 1|on|ON|On) + + # Turn ON only if volume is not null + if [ "$(volume get)" -ne "0" ]; then + echo "Turning audio amplifier ON" + else + exit 0 + fi + new_state=1 + ;; + + 0|off|OFF|Off) + echo "Turning audio amplifier OFF" + new_state=0 + ;; + + *) + usage + ;; +esac + +# Export the GPIO if necessary +if [ ! -d "${SYSTEM_GPIO}/gpio${GPIO_PF6}" ]; then + echo ${GPIO_PF6} > "${SYSTEM_GPIO}/export" +fi + +# Set the power audio amplifier GPIO as output +echo "out" > "${SYSTEM_GPIO}/gpio${GPIO_PF6}/direction" + +# Read the current power audio amplifier state +current_state=$(cat "${SYSTEM_GPIO}/gpio${GPIO_PF6}/value") + +# Enable/disable the power audio amplifier if necessary +if [ ${current_state} -ne ${new_state} ]; then + echo ${new_state} > "${SYSTEM_GPIO}/gpio${GPIO_PF6}/value" +fi +exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness new file mode 100755 index 0000000..f91d542 --- /dev/null +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness @@ -0,0 +1,128 @@ +#!/bin/sh + +# Uncomment the following line to get debug info +#set -x + +SELF="$(basename ${0})" +SYSTEM_BRIGHTNESS="/sys/class/backlight/backlight/brightness" +DEFAULT_BRIGHTNESS_VALUE=100 +BRIGHTNESS_STEP=10 +NOTIF_DURATION=2 + +usage() { + >&2 echo "Usage: ${SELF} get" + >&2 echo " ${SELF} set new_brightness_percentage" + exit 1 +} + +increase_brightness() { + + # Get current value + local current_brightness=$(get_brightness) + + # Compute new brightness value + local new_brightness=0 + let new_brightness=${current_brightness}+${BRIGHTNESS_STEP} + if [ ${new_brightness} -gt 100 ]; then + new_brightness=100 + fi + + # Change brightness + if [ ${new_brightness} -ne ${current_brightness} ]; then + set_brightness ${new_brightness} + fi + + # Notif + notif set ${NOTIF_DURATION} " BRIGHTNESS: ${new_brightness}%%" +} + +decrease_brightness() { + + # Get current value + local current_brightness=$(get_brightness) + + # Compute new brightness value + local new_brightness=0 + if [ ${current_brightness} -gt ${BRIGHTNESS_STEP} ]; then + let new_brightness=${current_brightness}-${BRIGHTNESS_STEP} + fi + + # Change brightness + if [ ${new_brightness} -ne ${current_brightness} ]; then + set_brightness ${new_brightness} + fi + + # Notif + notif set ${NOTIF_DURATION} " BRIGHTNESS: ${new_brightness}%%" +} + +get_brightness() { + local brightness=$(fw_printenv -n brightness 2>/dev/null) + if ! [ ! "${brightness}" -ne "${brightness}" ] 2> /dev/null; then + brightness=${DEFAULT_BRIGHTNESS_VALUE} + fw_setenv brightness ${brightness} + fi + echo ${brightness} +} + +set_brightness() { + + # Set the new brightness percentage in the kernel driver + local brightness=${1} + local kernel_brightness + let kernel_brightness=${brightness}+10 + let kernel_brightness/=10 + echo ${kernel_brightness} > "${SYSTEM_BRIGHTNESS}" + + # Set the new brightness value in a bootloader variable + if [ ${?} -eq 0 -a $(get_brightness) -ne ${brightness} ]; then + fw_setenv brightness ${brightness} + fi +} + +# Check number of arguments +if [ ${#} -lt 1 -o ${#} -gt 2 ]; then + usage +fi + +case "${1}" in + up) + if [ ${#} -ne 1 ]; then + usage + fi + increase_brightness + ;; + + down) + if [ ${#} -ne 1 ]; then + usage + fi + decrease_brightness + ;; + + get) + if [ ${#} -ne 1 ]; then + usage + fi + get_brightness + ;; + + set) + if [ ${#} -ne 2 ]; then + usage + fi + + # Make sure the argument is a positive number <= 100 + if [ -n "${2}" ] && [ "${2}" -eq "${2}" ] 2>/dev/null && \ + [ "${2}" -ge 0 ] && [ "${2}" -le 100 ]; then + set_brightness "${2}" + else + usage + fi + ;; + + *) + usage + ;; +esac +exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness_get b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness_get deleted file mode 100755 index 399bc37..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness_get +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -BRIGHTNESS_DEFAULT_VALUE=100 - -# Check args -if [ ${#} -ne 0 ]; then - echo "Usage: $(basename ${0})" - exit 1 -fi - -# Sanity check: Check if integer -brightness=$(fw_printenv -n brightness 2>/dev/null) -if ! [ ! "${brightness}" -ne "${brightness}" ] 2> /dev/null; then - brightness=${BRIGHTNESS_DEFAULT_VALUE} - fw_setenv brightness ${brightness} -fi -echo ${brightness} -exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness_get_sysfs b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness_get_sysfs deleted file mode 100755 index a682958..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness_get_sysfs +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -SYSTEM_BRIGHTNESS=/sys/class/backlight/backlight/brightness - -# Check args -if [ ${#} -ne 0 ]; then - echo "Usage: $(basename ${0})" - exit 1 -fi - -let brightness=$(cat ${SYSTEM_BRIGHTNESS})*10-10 -echo ${brightness} -exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness_set b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness_set deleted file mode 100755 index 8d45575..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness_set +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -SYSTEM_BRIGHTNESS=/sys/class/backlight/backlight/brightness - -# Check args -if [ ${#} -ne 1 ]; then - echo "Usage: $(basename ${0}) new_brightness_percentage" - exit 1 -fi - -# Check value's range -if [ ${1} -gt 100 ]; then - echo "Usage: Wrong brightness percentage (${1}), must be between 0 and 100" - exit 1 -fi -brightness_percentage=${1} - -# Set new brightness percentage -let value=${1}+10 -let value/=10 -echo ${value} > ${SYSTEM_BRIGHTNESS} - -# Set new brightness value in brightness file -if [ ${?} -eq 0 -a $(brightness_get) -ne ${brightness_percentage} ]; then - fw_setenv brightness ${brightness_percentage} -fi -exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness_set_sysfs b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness_set_sysfs deleted file mode 100755 index 424a3d8..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness_set_sysfs +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -SYSTEM_BRIGHTNESS=/sys/class/backlight/backlight/brightness - -# Check args -if [ ${#} -ne 1 ]; then - echo "Usage: $(basename ${0}) new_brightness_percentage" - exit 1 -fi - -# Check value's range -if [ ${1} -gt 100 ]; then - echo "Usage: Wrong brightness percentage (${1}), must be between 0 and 100" - exit 1 -fi - -# Set new brightness percentage -let value=${1}+10 -let value/=10 -echo ${value} > ${SYSTEM_BRIGHTNESS} -exit 0 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 deleted file mode 100755 index 2952a44..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/cancel_sched_powerdown +++ /dev/null @@ -1,11 +0,0 @@ -#!/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/display_notif_system_stats b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/display_notif_system_stats deleted file mode 100755 index a3cbd27..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/display_notif_system_stats +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -notif_set 0 " Getting system stats..." -killall -s USR1 system_stats -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 deleted file mode 100755 index afb3597..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/erase_pid +++ /dev/null @@ -1,12 +0,0 @@ -#!/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/first_boot b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/first_boot index b121a54..d13761f 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/first_boot +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/first_boot @@ -202,8 +202,8 @@ copy_files_to_usb_partition () { mount /mnt/ || die_notif 16 "Cannot mount /mnt" fi - # Copy freware games - unzip -q -o /usr/local/share/mnt_freware_games.zip -d /mnt/ + # Copy freware games and other necessary mnt files + unzip -q -o /usr/local/share/mnt_files.zip -d /mnt/ # Copy OPKs set +f @@ -216,29 +216,29 @@ copy_files_to_usb_partition () { } check_root_id -notif " FIRST BOOT DETECTED" +notif set 0 " FIRST BOOT DETECTED" -notif " 1/6 RESIZE ROOT PARTITION" +notif set 0 " 1/6 RESIZE ROOT PARTITION" resize_rootfs_partition -notif " 2/6 RESIZE ROOT FILESYSTEM" +notif set 0 " 2/6 RESIZE ROOT FILESYSTEM" resize_rootfs_filesystem -notif " 3/6 CREATE SWAP" +notif set 0 " 3/6 CREATE SWAP" create_swap -notif " 4/6 CREATE USB PARTITION" +notif set 0 " 4/6 CREATE USB PARTITION" create_usb_partition -notif " 5/6 FORMAT USB PARTITION" +notif set 0 " 5/6 FORMAT USB PARTITION" format_usb_partition -notif " 6/6 COPY FILES TO ^ USB PARTITION" +notif set 0 " 6/6 COPY FILES TO ^ USB PARTITION" copy_files_to_usb_partition -notif " FIRST BOOT SETUP FINISHED!" +notif set 0 " FIRST BOOT SETUP FINISHED!" fw_setenv first_boot_ok 1 sleep 1 -clear_notif +notif clear diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/frontend b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/frontend new file mode 100755 index 0000000..c4e3d69 --- /dev/null +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/frontend @@ -0,0 +1,161 @@ +#!/bin/sh + +# Uncomment the following line to get debug info +#set -x + +SELF="$(basename ${0})" +LAUNCHER_FILE="$HOME/Launchers/launcher.txt" +FRONTEND_FILE="$HOME/.frontend" +PREVENT_LAUNCHER_FILE="/mnt/prevent_launcher" +DISABLE_FRONTEND_FILE="/mnt/disable_frontend" +DEFAULT_FRONTEND=retrofe +LOCK_FILE="/var/lock/frontend.lock" +REBOOTING_FILE="/run/rebooting" +LAST_OPK_FILE="/mnt/last_opk" + +# Convert old launcher file to new frontend +if [ -f "${LAUNCHER_FILE}" ]; then + mv "${LAUNCHER_FILE}" "${FRONTEND_FILE}" + rm -rf $(dirname "${LAUNCHER_FILE}") 2>/dev/null +fi + +# Convert old prevent launcher file to new frontend disable file +if [ -f "${PREVENT_LAUNCHER_FILE}" ]; then + mv "${PREVENT_LAUNCHER_FILE}" "${DISABLE_FRONTEND_FILE}" +fi + +usage() { + >&2 echo "Usage: ${SELF} init" + >&2 echo " ${SELF} get" + >&2 echo " ${SELF} set gmenu2x|retrofe|none" + exit 1 +} + +set_frontend() { + mkdir -p "$(dirname "$FRONTEND_FILE")" + local frontend=$(get_frontend) + local new_frontend="${1}" + echo "Setting frontend: ${new_frontend}" + if [ "${new_frontend}" = "none" ]; then + touch "${DISABLE_FRONTEND_FILE}" + else + rm -f "${DISABLE_FRONTEND_FILE}" + fi + if [ "${frontend}" != "none" ]; then + pkill "${frontend}" + fi + echo "${new_frontend}" > "${FRONTEND_FILE}" +} + +get_frontend() { + local frontend=$(cat "${FRONTEND_FILE}" 2>/dev/null | head -1) + + # Check if not empty + if [ "x${frontend}" = "x" ]; then + frontend="${DEFAULT_FRONTEND}" + echo "${frontend}" > "${FRONTEND_FILE}" + fi + + # Return frontend name + echo "${frontend}" +} + +init_frontend() { + if [ -f "${LOCK_FILE}" ]; then + >&2 echo "${LOCK_FILE} already exists" + exit 1 + fi + touch "${LOCK_FILE}" + + # Then loop to launch the frontend indefinitely + while true; do + + # Check if frontend disable file is present + if [ -f "${DISABLE_FRONTEND_FILE}" -o -f "${REBOOTING_FILE}" ]; then + echo "${DISABLE_FRONTEND_FILE} file found, not starting frontend" + sleep 5 + else + + # Umount any remaining OPK, if any + umount /opk >/dev/null 2>&1 + if [ -r "${LAST_OPK_FILE}" -a ! -f "${REBOOTING_FILE}" ]; then + rm "${LAST_OPK_FILE}" + fi + + # Launch selected frontend + local frontend="$(get_frontend)" + case "${frontend}" in + gmenu2x|retrofe) + "${frontend}"& + ;; + + none) + echo "no frontend" + sleep 5 + ;; + + *) + DEFAULT_FRONTEND=retrofe + echo "Unrecognized frontend: $frontend, setting $DEFAULT_FRONTEND" + set_frontend "${DEFAULT_FRONTEND}" + ;; + esac + + # Record the PID into a file, wait for the process to + # terminate and erase the recorded PID + pid record $! + wait $! + pid erase + + # In case retrofe/opkrun quits with errors, clear graphic VT + termfix_all + + # In case retrofe/opkrun quits with errors, reset default key mapping + keymap default + fi + + # Prevent 100% CPU usage + sleep 0.5 + + # Exit if console rebooting + if [ -f "${REBOOTING_FILE}" ]; then + break + fi + done + + # Remove lock file and exit + rm "${LOCK_FILE}" +} + +# Check number of arguments +if [ ${#} -lt 1 -o ${#} -gt 2 ]; then + usage +fi + +case "${1}" in + set) + if [ ${#} -ne 2 ]; then + usage + fi + set_frontend "${2}" + ;; + + get) + if [ ${#} -ne 1 ]; then + usage + fi + get_frontend + ;; + + init) + if [ ${#} -ne 1 ]; then + usage + fi + init_frontend + ;; + + *) + usage + ;; +esac +exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/get_launcher b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/get_launcher deleted file mode 100755 index 0911e80..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/get_launcher +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh - -# Check args -if [ ${#} -ne 0 ]; then - echo "Usage: $(basename ${0})" - exit 1 -fi - -# Launcher File -LAUNCHER_FILE=$HOME/Launchers/launcher.txt -DEFAULT_LAUNCHER=retrofe - -# Check that file exists -[ -f "$LAUNCHER_FILE" ] || set_launcher $DEFAULT_LAUNCHER >/dev/null 2>&1 - -# Check Launcher -launcher=$(cat "$LAUNCHER_FILE" | head -1) - -# Check not empty -[ -z "$LAUNCHER_FILE" ] && launcher=$DEFAULT_LAUNCHER; set_launcher $launcher >/dev/null 2>&1 - -# Return launcher name -echo $launcher - -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 index 42db9a0..fd04638 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/instant_play +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/instant_play @@ -3,35 +3,103 @@ # Uncomment the following line to get debug info #set -x -# Check args -if [ ${#} -eq 0 ]; then - echo "Usage: $(basename ${0}) args..." +SELF="$(basename ${0})" +INSTANT_PLAY_FILE="/mnt/instant_play" +RESUME_PLAY_FILE="/mnt/resume_play" +LAST_OPK_FILE="/mnt/last_opk" +PID_PATH="/var/run/pid_path" +REBOOTING_FILE="/run/rebooting" + +usage() { + >&2 echo "Usage: ${SELF} load" + >&2 echo " ${SELF} save application args..." exit 1 +} + +# Check number of arguments +if [ ${#} -lt 1 ]; then + usage 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}" +case ${1} in +load) + if [ ${#} -ne 1 ]; then + usage 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}" + # Umount any remaining OPK, if any + umount /opk >/dev/null 2>&1 + + # Mount last OPK, if any + if [ -r "${LAST_OPK_FILE}" ]; then + last_opk=$(cat "${LAST_OPK_FILE}") + mount -t squashfs "${last_opk}" /opk + fi + + # Remove unnecessary files + rm -f "${RESUME_PLAY_FILE}" + + # Launch Previous Game if any + if [ -f "${INSTANT_PLAY_FILE}" ]; then + keymap resume + echo -n "Found Instant Play file, restarting previous game with command: " + cat "${INSTANT_PLAY_FILE}" + mv "${INSTANT_PLAY_FILE}" "${RESUME_PLAY_FILE}" + source "${RESUME_PLAY_FILE}" + rm -f "${RESUME_PLAY_FILE}" + keymap default + termfix_all + fi + + # Unmount last OPK, if any + if [ -r "${LAST_OPK_FILE}" -a ! -f "${REBOOTING_FILE}" ]; then + umount /opk + rm "${LAST_OPK_FILE}" + fi + ;; + +save) + if [ ${#} -lt 2 ]; then + usage + fi + shift + + # Get curent binary real path + bin=$(printf %s "$1" | sed "s/'/'\\\\''/g") + bin_name=$(basename "$bin") + bin_path="$(cat $PID_PATH)"/"$bin_name" + + # Write quick load file args + echo -n "" > "${INSTANT_PLAY_FILE}" + printf "'" >> "${INSTANT_PLAY_FILE}" + echo -n "$bin_path" >> "${INSTANT_PLAY_FILE}" + printf "' " >> "${INSTANT_PLAY_FILE}" + shift + + while [ "$#" != "0" ] + do + printf "'" >> "${INSTANT_PLAY_FILE}" + printf %s "$1" | sed "s/'/'\\\\''/g" >> "${INSTANT_PLAY_FILE}" + printf "' " >> "${INSTANT_PLAY_FILE}" + shift + 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 \$! +pid record \$! wait \$! -erase_pid +pid erase EOF -# Now terminate gracefully -exec shutdown_funkey + # Now terminate gracefully + exec powerdown now + ;; + +*) + usage + ;; +esac +exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/is_usb_data_connected b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/is_usb_data_connected deleted file mode 100755 index c447693..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/is_usb_data_connected +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -# Uncomment the following line to get debug info -#set -x - -# Get USB state -usb_present=$(cat /sys/class/power_supply/axp20x-usb/present) - -# Get udc state -udc_state=$(cat /sys/class/udc/musb-hdrc.1.auto/state) - -if [[ x"$udc_state" == "xconfigured" -a "$usb_present" == "1" ]]; then - - # Connected succesfully to a host - echo "yes" - exit 0 -else - echo "no" - exit 1 -fi diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/keymap b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/keymap index ddba97d..097e93c 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/keymap +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/keymap @@ -1,14 +1,116 @@ #!/bin/sh -# Check number of args -if [ ${#} -ne 1 ]; then - echo "Usage: $(basename ${0}) keymap_file" +# Uncomment the following line to get debug info +#set -x + +SELF=$(basename ${0}) +LAST_MAPPING="/mnt/FunKey/.last_mapping.key" +FIFO="/tmp/fkgpiod.fifo" + +usage() { + echo "Usage: ${SELF} default" + echo " ${SELF} load " + echo " ${SELF} resume" + echo " ${SELF} rom " + echo " ${SELF} save " exit 1 +} + +log() { + logger -t "${SELF}[$$]" "$*" +} + +write_fifo() { + echo "${1}" >"${FIFO}" 2>/dev/null +} + +# Check number of args +if [ ${#} -lt 1 ]; then + usage fi -if [ "${1}" = "reset" ]; then - keymap_file="/etc/fkgpiod.conf" -else - keymap_file="${1}" + +# Create FIFO it it does not exist yet +if [ ! -p "${FIFO}" ]; then + rm -f "${FIFO}" + log "FIFO does not exist, create it" + mkfifo "${FIFO}" + chmod 0640 "${FIFO}" fi -echo "LOAD ${keymap_file}" >/tmp/fkgpiod.fifo 2>/dev/null + +case "${1}" in + default) + if [ ${#} -ne 1 ]; then + usage + fi + log "default: LOAD /etc/fkgpiod.conf" + write_fifo "LOAD /etc/fkgpiod.conf" + ;; + + load) + if [ ${#} -ne 2 ]; then + usage + fi + config_file="${2}" + log "load: LOAD ${config_file}" + write_fifo "LOAD ${config_file}" + log "load: SAVE ${LAST_MAPPING}" + write_fifo "SAVE ${LAST_MAPPING}" + ;; + + resume) + if [ ${#} -ne 1 ]; then + usage + fi + if [ -f "${LAST_MAPPING}" ]; then + log "resume: LOAD ${LAST_MAPPING}" + write_fifo "LOAD ${LAST_MAPPING}" + fi + ;; + + rom) + if [ ${#} -gt 2 ]; then + usage + elif [ ${#} -eq 1 ]; then + console_keymap="" + rom_keymap="" + else + rom_path="${2}" + console_keymap="$(dirname "${rom_path}")/default_config.key" + rom_keymap="${rom_path%.*}.key" + fi + if [ -f "${console_keymap}" ]; then + log "rom: LOAD ${console_keymap}" + write_fifo "LOAD ${console_keymap}" + fi + for desktop_file in $(ls /opk/*.desktop 2>/dev/null); do + opk_keymap=$(grep FK-Keymap= "${desktop_file}" | cut -d '=' -f 2) + if [ "${opk_keymap:0:1}" != "/" ]; then + opk_keymap="/opk/${opk_keymap}" + fi + if [ -f "${opk_keymap}" ]; then + log "rom: LOAD ${opk_keymap}" + write_fifo "LOAD ${opk_keymap}" + fi + done + if [ -f "${rom_keymap}" ]; then + log "rom: LOAD ${rom_keymap}" + write_fifo "LOAD ${rom_keymap}" + fi + log "rom: SAVE ${LAST_MAPPING}" + write_fifo "SAVE ${LAST_MAPPING}" + ;; + + save) + if [ ${#} -ne 2 ]; then + usage + fi + config_file="${2}" + log "save: SAVE ${config_file}" + write_fifo "SAVE ${config_file}" + ;; + + *) + usage + ;; +esac exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/low_bat_check b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/low_bat_check index 51908e3..e9dcfe9 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/low_bat_check +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/low_bat_check @@ -3,32 +3,28 @@ # General constants declaration THRESHOLD_PERCENT_LOW_BAT=5 THRESHOLD_PERCENT_EXTREMELY_LOW_BAT=2 -MAX_EXTREMELY_LOW_BAT_BEFORE_SHUTDOWN=5 +MAX_LOW_BAT_COUNT=5 SLEEP_SECS=2 RESCALE_MAX_PERCENTAGE=120 # Blink Low bat constants declaration BLINK_ICON=0 -LOW_BAT_SECS_DISPLAYED=5 -LOW_BAT_SECS_NOT_DISPLAYED=5 +LOW_BAT_DISPLAY_TIMEOUT=5 # Files and commands declaration -USB_PRESENT_FILE=/sys/class/power_supply/axp20x-usb/present +USB_PRESENT_FILE="/sys/class/power_supply/axp20x-usb/present" # Cheat for no USB present simulation when debugging -#USB_PRESENT_FILE=/sys/class/power_supply/axp20x-ac/present -BAT_PRESENT_FILE=/sys/class/power_supply/axp20x-battery/present -BAT_PERCENT_FILE=/sys/class/power_supply/axp20x-battery/capacity -BAT_PERCENT_RESCALED_FILE=/tmp/current_battery_percentage -LOW_BAT_ICON=/sys/class/graphics/fb0/low_battery -SCHEDULE_SHUTDOWN_CMD=sched_shutdown -SIGNAL_URS1_TO_EMULATORS_CMD=signal_usr1_to_emulators +BAT_PRESENT_FILE="/sys/class/power_supply/axp20x-battery/present" +BAT_PERCENT_FILE="/sys/class/power_supply/axp20x-battery/capacity" +BAT_PERCENT_RESCALED_FILE="/tmp/current_battery_percentage" +LOW_BAT_ICON="/sys/class/graphics/fb0/low_battery" # Variables declaration low_bat_status=0 low_bat_displayed=0 cur_secs_disp=0 -cur_nb_extremely_low_bat_before_shutdown=0 +low_bat_count=0 # Default: Hide Low Bat Icon echo 0 > ${LOW_BAT_ICON} @@ -73,7 +69,7 @@ while true; do # Reset status low_bat_status=0 - cur_nb_extremely_low_bat_before_shutdown=0 + low_bat_count=0 echo 0 > ${LOW_BAT_ICON} fi fi @@ -82,7 +78,7 @@ while true; do # Reset status low_bat_status=0 - cur_nb_extremely_low_bat_before_shutdown=0 + low_bat_count=0 echo 0 > ${LOW_BAT_ICON} fi fi @@ -92,24 +88,24 @@ while true; do # Check extremely low bat for clean shutdown if [ ${cur_bat_percent} -le ${THRESHOLD_PERCENT_EXTREMELY_LOW_BAT} ]; then - let cur_nb_extremely_low_bat_before_shutdown++ - echo "cur_nb_extremely_low_bat_before_shutdown = ${cur_nb_extremely_low_bat_before_shutdown}" + let low_bat_count++ + echo "low_bat_count = ${low_bat_count}" # Clean shutdown - if [ ${cur_nb_extremely_low_bat_before_shutdown} -ge ${MAX_EXTREMELY_LOW_BAT_BEFORE_SHUTDOWN} ]; then + if [ ${low_bat_count} -ge ${MAX_LOW_BAT_COUNT} ]; then echo "Battery extremely low, shutting down now..." - sched_shutdown 1 & signal_usr1_to_emulators + powerdown schedule 1 exit 0 fi fi # Blinking process if [ ${BLINK_ICON} -eq 1 ]; then - if [ ${low_bat_displayed} -eq 1 -a ${cur_secs_disp} -ge ${LOW_BAT_SECS_DISPLAYED} ]; then + if [ ${low_bat_displayed} -eq 1 -a ${cur_secs_disp} -ge ${LOW_BAT_DISPLAY_TIMEOUT} ]; then low_bat_displayed=0 cur_secs_disp=0 echo 0 > ${LOW_BAT_ICON} - elif [ ${low_bat_displayed} -eq 0 -a ${cur_secs_disp} -ge ${LOW_BAT_SECS_NOT_DISPLAYED} ]; then + elif [ ${low_bat_displayed} -eq 0 -a ${cur_secs_disp} -ge ${LOW_BAT_DISPLAY_TIMEOUT} ]; then low_bat_displayed=1 cur_secs_disp=0 echo 1 > ${LOW_BAT_ICON} diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/notif b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/notif new file mode 100755 index 0000000..a9afe6a --- /dev/null +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/notif @@ -0,0 +1,78 @@ +#!/bin/sh + +# Uncomment the following line to get debug info +#set -x + +SELF="$(basename ${0})" +NOTIFICATION_DISPLAY=/sys/class/graphics/fb0/notification + +usage() { + >&2 echo "Usage: ${SELF} set duration message" + >&2 echo " ${SELF} display duration message" + >&2 echo " ${SELF} clear" + exit 1 +} + +notif_clear() { + + printf "clear" > "${NOTIFICATION_DISPLAY}" +} + +notif_display() { + local duration="${1}" + local message="${*:2}" + if ! [ ! "${duration}" -ne "${duration}" ] 2> /dev/null; then + >&2 echo "error: ${duration} is not a number" + exit 3 + fi + printf "${message}" > "${NOTIFICATION_DISPLAY}" + if [ ${duration} -ne 0 ]; then + sleep ${duration} + notif_clear + fi +} + +notif_set() { + local duration="${1}" + local message="${*:2}" + if ! [ ! "${duration}" -ne "${duration}" ]; then + >&2 echo "error: ${duration} is not a number" + exit 2 + fi + + # Kill previous notif disp process + pkill -f "notif display" 2> /dev/null + + # Print new notif + notif display "${duration}" "${message}" & +} + +case "${1}" in + set) + if [ ${#} -ne 3 ]; then + usage + fi + shift + notif_set "${1}" "${2}" + ;; + + clear) + if [ ${#} -ne 1 ]; then + usage + fi + notif_clear + ;; + + display) + if [ ${#} -ne 3 ]; then + usage + fi + shift + notif_display "${1}" "${2}" + ;; + + *) + usage + ;; +esac +exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/notif_clear b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/notif_clear deleted file mode 100755 index 44f6c1b..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/notif_clear +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# Clear all current notifications - -NOTIFICATION_DISPLAY=/sys/class/graphics/fb0/notification - -printf "clear" > ${NOTIFICATION_DISPLAY} - -exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/notif_disp b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/notif_disp deleted file mode 100755 index d40bd9f..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/notif_disp +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -# Display notification for a certain amount of time -# Special char: ^ to add a new line -# Set seconds to 0 to display indefinitely (until the next notif) - -NOTIFICATION_DISPLAY=/sys/class/graphics/fb0/notification - -display_usage() { - echo -e "Usage:\n$(basename ${0}) nb_seconds_display message_to_display\n" -} - -# If less than two arguments supplied, display usage -if [ ${#} -le 1 ]; then - echo "Display notification for a certain amount of time" - display_usage - exit 1 -fi - -# Get number of seconds to display notif -nb_secs=${1} -if ! [ ! "${nb_secs}" -ne "${nb_secs}" ] 2> /dev/null; then - echo "error: ${nb_secs} is not a number" >&2 - exit 1 -fi - -# Print notif -printf "${*:2}" > ${NOTIFICATION_DISPLAY} - -# Clear notif if NB_SECS is not 0, otherwise never clear -if [ ${nb_secs} -ne 0 ]; then - - # Wait time before clearing notif - sleep ${nb_secs} - - # Clear notif - printf "clear" > ${NOTIFICATION_DISPLAY} -fi -exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/notif_set b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/notif_set deleted file mode 100755 index bc04835..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/notif_set +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# Erase previous notif and display new one in background process for a certain amount of seconds -# Special char: ^ to add a new line -# Set seconds to 0 to display indefinitely (until the next notif_set) - -NOTIFICATION_DISPLAY=/sys/class/graphics/fb0/notification - -display_usage() { - echo -e "Usage:\n$(basename ${0}) nb_seconds_display message_to_display\n" -} - -# If less than two arguments supplied, display usage -if [ ${#} -le 1 ]; then - echo "Erase previous notif and display new one in background process for a certain amount of time" - echo "Special char: ^ to add a new line" - echo "Set seconds to 0 to display indefinitely (until the next $(basename ${0}))" - display_usage - exit 1 -fi - -# Get number of seconds to display notif -nb_secs=${1} -if ! [ ! "${nb_secs}" -ne "${nb_secs}" ]; then - echo "error: ${nb_secs} is not a number" >&2 - exit 1 -fi - -# Kill previous notif_disp process -pkill notif_disp 2> /dev/null - -## Clear previous notif -#printf "clear" > ${NOTIFICATION_DISPLAY} - -# Print new notif -notif_disp "$@" & -exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/pid b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/pid new file mode 100755 index 0000000..84c21b6 --- /dev/null +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/pid @@ -0,0 +1,59 @@ +#!/bin/sh + +# Uncomment the following line to get debug info +#set -x + +SELF="$(basename ${0})" +PID_FILE="/var/run/funkey.pid" +PID_PATH="/var/run/pid_path" + +usage() { + >&2 echo "Usage: ${SELF} record pid" + >&2 echo " ${SELF} erase" + >&2 echo " ${SELF} print" + exit 1 +} + +record_pid() { + local pid="${1}" + if ! [ ! "${pid}" -ne "${pid}" ]; then + >&2 echo "error: ${pid} is not a number" + exit 2 + fi + + # Save PID + echo "${1}" > "${PID_FILE}" + + # Save current pid path + pid_path=$(dirname $(readlink /proc/${pid}/exe)) + echo -n "$pid_path" > "$PID_PATH" +} + +erase_pid() { + rm -f "${PID_FILE}" +} + +case "${1}" in + record) + if [ ${#} -ne 2 ]; then + usage + fi + record_pid "${2}" + ;; + + erase) + if [ ${#} -ne 1 ]; then + usage + fi + erase_pid + ;; + + print) + cat "${PID_FILE}" + ;; + + *) + usage + ;; +esac +exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/powerdown b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/powerdown new file mode 100755 index 0000000..930b710 --- /dev/null +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/powerdown @@ -0,0 +1,83 @@ +#!/bin/sh + +# Uncomment the following line to get debug info +#set -x + +SELF="$(basename ${0})" +REBOOTING_FILE="/run/rebooting" + +usage() { + >&2 echo "Usage: ${SELF} schedule delay" + >&2 echo " ${SELF} handle" + >&2 echo " ${SELF} now" + exit 1 +} + +schedule_powerdown() { + + # Send USR1 signal to the running FunKey process to warn about + # impending shutdown + kill -USR1 "$(pid print)" > /dev/null 2>&1 + + # 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} + + # Delay expired, initiate final powerdown + powerdown_now +} + +handle_powerdown() { + pkill -f "powerdown schedule" +} + +powerdown_now() { + + # Sync before all else + sync + + # Notif fullscreen "Shutting down" + notif set 0 "^^^^^^^^ SHUTTING DOWN...^^^^^^^^" + + # Notify system, reboot in progress + touch "${REBOOTING_FILE}" + + # Shutdown amp + audio_amp off >/dev/null 2>&1 + + # Force Read Only + ro + + # Poweroff + poweroff +} + +action="${1:-now}" +case "${action}" in + schedule) + if [ ${#} != 2 -o "${2}" == "0" ]; then + usage + fi + schedule_powerdown ${2} + ;; + + handle) + if [ ${#} -ne 1 ]; then + usage + fi + handle_powerdown + ;; + + now) + if [ ${#} -gt 1 ]; then + usage + fi + powerdown_now + ;; + + *) + usage + ;; +esac +exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_bright_down b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_bright_down deleted file mode 100755 index efd8d53..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_bright_down +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -STEP_BRIGHTNESS=10 -NOTIF_DURATION=2 - -# Get current value -current_brightness=$(brightness_get) - -# Compute new brightness value -new_brightness=0 -if [ ${current_brightness} -gt ${STEP_BRIGHTNESS} ]; then - let new_brightness=${current_brightness}-${STEP_BRIGHTNESS} -fi - -# Change brightness -if [ ${new_brightness} -ne ${current_brightness} ]; then - brightness_set ${new_brightness} -fi - -# Notif -notif_set ${NOTIF_DURATION} " BRIGHTNESS: ${new_brightness}%%" -exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_bright_up b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_bright_up deleted file mode 100755 index 6241430..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_bright_up +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -STEP_BRIGHTNESS=10 -NOTIF_DURATION=2 - -# Get current value -current_brightness=$(brightness_get) - -# Compute new brightness value -let new_brightness=${current_brightness}+${STEP_BRIGHTNESS} -if [ ${new_brightness} -gt 100 ]; then - new_brightness=100 -fi - -# Change brightness -if [ ${new_brightness} -ne ${current_brightness} ]; then - brightness_set ${new_brightness} -fi - -# Notif -notif_set ${NOTIF_DURATION} " BRIGHTNESS: ${new_brightness}%%" -exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_volume_down b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_volume_down deleted file mode 100755 index db87d23..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_volume_down +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -STEP_VOLUME=10 -NOTIF_DURATION=2 - -# Get current value -current_volume=$(volume_get) - -# Compute new volume value -new_volume=0 -if [ ${current_volume} -gt ${STEP_VOLUME} ]; then - let new_volume=${current_volume}-${STEP_VOLUME} -fi - -# Change volume -if [ ${new_volume} -ne ${current_volume} ]; then - volume_set ${new_volume} -fi - -# Notif -notif_set ${NOTIF_DURATION} " VOLUME: ${new_volume}%%" -exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_volume_up b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_volume_up deleted file mode 100755 index f33e96c..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_volume_up +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -STEP_VOLUME=10 -NOTIF_DURATION=2 - -# Get current value -current_volume=$(volume_get) - -# Compute new volume value -let new_volume=${current_volume}+${STEP_VOLUME} -if [ ${new_volume} -gt 100 ]; then - new_volume=100 -fi - -# Change volume -if [ ${new_volume} -ne ${current_volume} ]; then - volume_set ${new_volume} -fi - -# Notif -notif_set ${NOTIF_DURATION} " VOLUME: ${new_volume}%%" -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 deleted file mode 100755 index 0f98bfc..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/record_pid +++ /dev/null @@ -1,12 +0,0 @@ -#!/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 deleted file mode 100755 index 3fa1732..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/sched_shutdown +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -# 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 - -# Send USR1 signal to the running FunKey process to warn about -# impending shutdown -pkill -USR1 -F /var/run/funkey.pid > /dev/null 2>&1 - -# 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} - -# Delay expired, initiate shutdown -shutdown_funkey - diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/set_launcher b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/set_launcher deleted file mode 100755 index 1d20bd9..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/set_launcher +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -# Check number of args -if [ ${#} -ne 1 ]; then - echo "Usage: $(basename ${0}) launcher" - exit 1 -fi - -# Launcher File -LAUNCHER_FILE=$HOME/Launchers/launcher.txt -mkdir -p "$(dirname "$LAUNCHER_FILE")" - -# Check Launcher -NEW_LAUNCHER=${1} -echo "Setting launcher: ${NEW_LAUNCHER}" -echo ${NEW_LAUNCHER} > "$LAUNCHER_FILE" - -exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/share b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/share index f63d8a5..03c8254 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/share +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/share @@ -54,7 +54,7 @@ mount_share () { # Check if there is a firmware update file if [ -f /mnt/FunKey-*.fwu ]; then warn "found a firmware update file, going into recovery mode" - notif "^^^^^^^^ UPDATING...^^^^^^^^" + notif set 0 "^^^^^^^^ UPDATING...^^^^^^^^" recovery_mode fi @@ -127,6 +127,25 @@ is_share_started () { return $res } +is_usb_data_connected () { + + # Get USB state + local usb_present=$(cat /sys/class/power_supply/axp20x-usb/present) + + # Get udc state + local udc_state=$(cat /sys/class/udc/musb-hdrc.1.auto/state) + + if [ "x${udc_state}" = "xconfigured" -a "${usb_present}" -eq 1 ]; then + + # Connected succesfully to a host + echo "yes" + return 0 + else + echo "no" + return 1 + fi +} + case "$1" in init) @@ -145,6 +164,9 @@ case "$1" in is_share_started ;; + is_usb_data_connected) + is_usb_data_connected + ;; *) die 15 "Usage $0 {init|start|stop|is_sharing}" diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/shutdown_funkey b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/shutdown_funkey deleted file mode 100755 index 5accd47..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/shutdown_funkey +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -# Sync before all else -sync - -# Notif fullscreen "Shutting down" -notif_set 0 "^^^^^^^^ SHUTTING DOWN...^^^^^^^^" - -# Notify system, reboot in progress -REBOOTING_FILE="/run/rebooting" -touch $REBOOTING_FILE - -# Shutdown amp -start_audio_amp 0 >/dev/null 2>&1 - -# Force Read Only -ro - -# Poweroff -poweroff diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/snap b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/snapshot similarity index 94% rename from Recovery/board/funkey/rootfs-overlay/usr/local/sbin/snap rename to FunKey/board/funkey/rootfs-overlay/usr/local/sbin/snapshot index c727364..c45e079 100755 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/snap +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/snapshot @@ -24,7 +24,7 @@ mkdir -p "${SNAPSHOT_DIR}" last=$(cd ${SNAPSHOT_DIR}; ls IMG_*.${SNAPSHOT_EXT} 2> /dev/null | tail -1 | sed 's/^IMG_0*\([0-9]\+\)\.'${SNAPSHOT_EXT}'$/\1/') let last=${last}+1 snapshot_file=$(printf "IMG_%04d.${SNAPSHOT_EXT}" $last) -notif_set 2 " SCREEENSHOT ${snapshot_file}" +notif set 2 " SCREENSHOT ${snapshot_file}" fbgrab "${SNAPSHOT_DIR}/${snapshot_file}" >/dev/null 2>&1 & # Remove lock file diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/start_audio_amp b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/start_audio_amp deleted file mode 100755 index 50034e0..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/start_audio_amp +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh - -# Check number of args -if [ ${#} -ne 1 ]; then - echo "Usage: $(basename ${0}) [1 for on, 0 for off]" - exit 1 -fi - -# Check enable arg -enable=${1} -if [ ${enable} -eq 1 ]; then - - # Turn ON only if volume is not null - if [ "$(volume_get)" -ne "0" ]; then - echo "Turning audio amplifier ON" - else - exit 0 - fi -elif [ ${enable} -eq 0 ]; then - echo "Turning audio amplifier OFF" -else - echo "Usage: $(basename ${0}) [1 for on, 0 for off]" - exit 1 -fi - -# PA enable GPIO -GPIO_PF6=166 - -# Export GPIO -if [ ! -d /sys/class/gpio/gpio${GPIO_PF6} ]; then - echo ${GPIO_PF6} > /sys/class/gpio/export -fi - -# Enable/disable cmd -echo "out" > /sys/class/gpio/gpio${GPIO_PF6}/direction -echo ${enable} > /sys/class/gpio/gpio${GPIO_PF6}/value -exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/start_gpio_manager b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/start_gpio_manager deleted file mode 100755 index 635f18f..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/start_gpio_manager +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -LOCK_FILE=/var/lock/gpio_manager.lock - -if [ -f ${LOCK_FILE} ]; then - echo "${LOCK_FILE} already exists" - exit 1 -fi -touch ${LOCK_FILE} -funkey_gpio_management -rm "${LOCK_FILE}" -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 deleted file mode 100755 index ea37a12..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/start_launcher +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/sh - -# Uncomment the following line to get debug info -#set -x - -LOCK_FILE="/var/lock/launcher.lock" -INSTANT_PLAY_FILE="/mnt/instant_play" -RESUME_PLAY_FILE="/mnt/resume_play" -PREVENT_LAUNCHER_FILE="/mnt/prevent_launcher" -REBOOTING_FILE="/run/rebooting" - - -if [ -f "${LOCK_FILE}" ]; then - echo "${LOCK_FILE} already exists" - exit 1 -fi -touch "${LOCK_FILE}" - -# Sanity cmd: in case these files do not exist -mkdir -p "${MEDNAFEN_HOME}" -cp "/usr/games/lynxboot.img" "/usr/games/mednafen-09x.cfg" "${MEDNAFEN_HOME}/" - -# 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}") - rm -f "${RESUME_PLAY_FILE}" - mv "${INSTANT_PLAY_FILE}" "${RESUME_PLAY_FILE}" - source "${RESUME_PLAY_FILE}" - rm -f "${RESUME_PLAY_FILE}" - termfix_all -fi - -# Then loop to launch the launcher indefinitely -while true; do - - # Check if prevent launcher file present - if [ -f "${PREVENT_LAUNCHER_FILE}" ]; then - echo "${PREVENT_LAUNCHER_FILE} file found, not starting launcher" - sleep 5 - else - LAUNCHER=$(get_launcher) - - if [ ${LAUNCHER} == "gmenu2x" ]; then - - # Launch gmenu2x - gmenu2x& - elif [ ${LAUNCHER} == "retrofe" ]; then - - # Launch Retrofe - retrofe& - else - DEFAULT_LAUNCHER=retrofe - echo "Not recognized launcher: $LAUNCHER, setting $DEFAULT_LAUNCHER" - set_launcher $DEFAULT_LAUNCHER - 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/opkrun quits with errors, clear graphic VT - termfix_all - - # In case retrofe/opkrun quits with errors, reset default key mapping - keymap reset - fi - - # WD to prevent 100% CPU - sleep 0.5 - - # Exit if console rebooting - if [ -f $REBOOTING_FILE ]; then - break - fi -done - -# Remove lock file and exit -rm "${LOCK_FILE}" -exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/system_stats b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/system_stats index 4e6ad97..c4e3eb5 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/system_stats +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/system_stats @@ -1,7 +1,25 @@ #!/bin/sh +# Uncomment the following line to get debug info +#set -x + +SELF="$(basename ${0})" UPDATE_PERIOD=2 #seconds +usage() { + >2& echo "Usage: ${SELF} [toggle]" + exit 1 +} + +# Check number of arguments +if [ ${#} -eq 1 -a "${1}" = "toggle" ]; then + notif set 0 " Getting system stats..." + killall -s USR1 "${SELF}" + exit 0 +elif [ ${#} -ne 0 ]; then + usage +fi + notif_dirty=0 perform=0 @@ -10,7 +28,7 @@ function toggle_perform() { let perform=1-${perform} if [ ${perform} -eq 0 ]; then - notif_clear + notif clear notif_dirty=1 fi } @@ -27,13 +45,13 @@ while true; do # Notif if [ ${notif_dirty} -eq 1 ]; then - notif_clear + notif clear notif_dirty=0 else if [ "x${ip_addr}" != "x" ]; then - notif_set 0 " CPU:${cpu}%% RAM:${ram_mem}%% SWAP:${ram_swap}%%^IP:${ip_addr}" + notif set 0 " CPU:${cpu}%% RAM:${ram_mem}%% SWAP:${ram_swap}%%^IP:${ip_addr}" else - notif_set 0 " CPU:${cpu}%% RAM:${ram_mem}%% SWAP:${ram_swap}%%" + notif set 0 " CPU:${cpu}%% RAM:${ram_mem}%% SWAP:${ram_swap}%%" fi fi else diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume new file mode 100755 index 0000000..3d6765b --- /dev/null +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume @@ -0,0 +1,136 @@ +#!/bin/sh + +# Uncomment the following line to get debug info +#set -x + +SELF="$(basename ${0})" +DEFAULT_VOLUME_VALUE=50 +MINIMUM_VOLUME=16 +VOLUME_STEP=10 +NOTIF_DURATION=2 + +usage() { + >&2 echo "Usage: ${SELF} get" + >&2 echo " ${SELF} set new_volume_percentage" + exit 1 +} + +increase_volume() { + + # Get current value + local current_volume=$(get_volume) + + # Compute new volume value + local new_volume=0 + let new_volume=${current_volume}+${VOLUME_STEP} + if [ ${new_volume} -gt 100 ]; then + new_volume=100 + fi + + # Change volume + if [ ${new_volume} -ne ${current_volume} ]; then + set_volume ${new_volume} + fi + + # Notif + notif set ${NOTIF_DURATION} " VOLUME: ${new_volume}%%" +} + +decrease_volume() { + + # Get current value + local current_volume=$(get_volume) + + # Compute new volume value + local new_volume=0 + if [ ${current_volume} -gt ${VOLUME_STEP} ]; then + let new_volume=${current_volume}-${VOLUME_STEP} + fi + + # Change volume + if [ ${new_volume} -ne ${current_volume} ]; then + set_volume ${new_volume} + fi + + # Notif + notif set ${NOTIF_DURATION} " VOLUME: ${new_volume}%%" +} + +get_volume() { + local volume=$(fw_printenv -n volume 2>/dev/null) + if ! [ ! "${volume}" -ne "${volume}" ] 2> /dev/null; then + volume=${DEFAULT_VOLUME_VALUE} + fw_setenv volume ${volume} + fi + echo ${volume} +} + +set_volume() { + + local current_volume=$(get_volume) + + # Set the new volume value (from 0 to 63) into ALSA + local new_volume=${1} + local alsa_volume=$(echo "a = $new_volume * (63 - $MINIMUM_VOLUME) / 100 + \ + $MINIMUM_VOLUME + 0.5; scale = 0; a / 1" | bc -l) + amixer -q sset 'Headphone' ${alsa_volume} unmute + + # Set the new volume value in a bootloader variable + if [ ${?} -eq 0 -a ${current_volume} -ne ${new_volume} ]; then + fw_setenv volume ${new_volume} + fi + + # Turn on/off audio amplifier if necessary + if [ ${new_volume} -eq 0 ]; then + audio_amp off + else + audio_amp on + fi +} + +# Check number of arguments +if [ ${#} -lt 1 -o ${#} -gt 2 ]; then + usage +fi + +case "${1}" in + up) + if [ ${#} -ne 1 ]; then + usage + fi + increase_volume + ;; + + down) + if [ ${#} -ne 1 ]; then + usage + fi + decrease_volume + ;; + + get) + if [ ${#} -ne 1 ]; then + usage + fi + get_volume + ;; + + set) + if [ ${#} -ne 2 ]; then + usage + fi + + # Make sure the argument is a positive number <= 100 + if [ -n "${2}" ] && [ "${2}" -eq "${2}" ] 2>/dev/null && \ + [ "${2}" -ge 0 ] && [ "${2}" -le 100 ]; then + set_volume "${2}" + else + usage + fi + ;; + + *) + usage + ;; +esac +exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume_get b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume_get deleted file mode 100755 index a387a4d..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume_get +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -VOLUME_DEFAULT_VALUE=50 - -# Check args -if [ ${#} -ne 0 ]; then - echo "Usage: $(basename ${0})" - exit 1 -fi - -# Sanity check: Check if integer -volume=$(fw_printenv -n volume 2>/dev/null) -if ! [ ! "${volume}" -ne "${volume}" ] 2> /dev/null; then - volume=${VOLUME_DEFAULT_VALUE} - fw_setenv volume ${volume} -fi -echo ${volume} -exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume_get_alsa b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume_get_alsa deleted file mode 100755 index e30faff..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume_get_alsa +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -amixer sget 'Headphone' | tail -1 | cut -d' ' -f7 | sed 's/[^0-9]//g' -exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume_set b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume_set deleted file mode 100755 index 41c9619..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume_set +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh - -# Check args -if [ ${#} -ne 1 ]; then - echo "Usage: $(basename ${0}) new_volume_percentage" - exit 1 -fi - -# Check value's range -if [ ${1} -gt 100 ]; then - echo "Usage: Wrong volume percentage (${1}), must be between 0 and 100" - exit 1 -fi - -# Scale new volume value between 0 and 63 -volume_percent=${1} -vol_mini=16; -volume_scaled=$(echo "a = $volume_percent * (63 - $vol_mini) / 100 + $vol_mini + 0.5; scale = 0; a / 1" | bc -l) -#echo $volume_scaled - -# Get current value -current_volume=$(volume_get) - -# Set new volume -amixer -q sset 'Headphone' ${volume_scaled} unmute - -# Change new volume value in volume file -if [ ${?} -eq 0 -a ${current_volume} -ne ${volume_percent} ]; then - fw_setenv volume ${volume_percent} -fi - -# Turn on/off audio amplifier if necessary -if [ ${current_volume} -eq 0 -a ${volume_percent} -ne 0 ]; then - start_audio_amp 1 -elif [ ${current_volume} -ne 0 -a ${volume_percent} -eq 0 ]; then - start_audio_amp 0 -fi - -exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume_set_alsa b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume_set_alsa deleted file mode 100755 index 2153152..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume_set_alsa +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh - -# Check args -if [ ${#} -ne 1 ]; then - echo "Usage: ${0} new_volume_percentage" - exit 1 -fi - -# Check value's range -if [ ${1} -gt 100 ]; then - echo "Usage: Wrong volume percentage (${1}), must be between 0 and 100" - exit 1 -fi - -# Scale new volume value between 0 and 63 -volume_percent=${1} -volume_scaled=$(echo "a = ${1} * 63 / 100 + 0.5; scale = 0; a / 1" | bc -l) - -# Get current value -current_volume=$(volume_get) - -# Turn on/off ampli if necessary -if [ ${current_volume} -eq 0 -a ${volume_scaled} -ne 0 ]; then - start_audio_amp 1 -elif [ ${current_volume} -ne 0 -a ${volume_scaled} -eq 0 ]; then - start_audio_amp 0 -fi - -# Set new volume -amixer -q sset 'Headphone' ${volume_scaled} unmute -exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/write_args_quick_load_file b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/write_args_quick_load_file deleted file mode 100755 index e5e977f..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/write_args_quick_load_file +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -# Write quick load file args -QUICK_LOAD_FILE=/mnt/quick_load_cmd - -echo -n "" > $QUICK_LOAD_FILE -for i in "$@"; do - if $(echo "$i" | egrep -q '[[:space:]]'); then - - # Add quotes around arguments containing spaces - echo -n "\"$i\" " >> ${QUICK_LOAD_FILE} - else - echo -n "$i " >> ${QUICK_LOAD_FILE} - fi -done -echo "" >> ${QUICK_LOAD_FILE} - -exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/share/mnt_freware_games.zip b/FunKey/board/funkey/rootfs-overlay/usr/local/share/mnt_files.zip similarity index 83% rename from FunKey/board/funkey/rootfs-overlay/usr/local/share/mnt_freware_games.zip rename to FunKey/board/funkey/rootfs-overlay/usr/local/share/mnt_files.zip index 9c93bd8..67fd8fe 100644 Binary files a/FunKey/board/funkey/rootfs-overlay/usr/local/share/mnt_freware_games.zip and b/FunKey/board/funkey/rootfs-overlay/usr/local/share/mnt_files.zip differ diff --git a/FunKey/board/funkey/update_partition b/FunKey/board/funkey/update_partition index 634f02c..5cf8ae6 100755 --- a/FunKey/board/funkey/update_partition +++ b/FunKey/board/funkey/update_partition @@ -7,9 +7,14 @@ root_part_num=2 root_part=/dev/mmcblk0p${root_part_num} root_mount=/tmp/rootfs +# Compatibility issue with older Recovery notifications +if [ -x /usr/local/sbin/notif ]; then + alias notif_set="notif set" +fi + do_preinst() { - notif " 1/4 EXTRACT FIRMWARE UPDATE..^DO NOT TURN OFF THE CONSOLE" + notif_set 0 " 1/4 EXTRACT FIRMWARE UPDATE..^DO NOT TURN OFF THE CONSOLE" exit 0 } @@ -19,55 +24,58 @@ do_postinst() ################# # Resize Rootfs # ################# - notif " 2/4 RESIZE ROOT FILESYSTEM^DO NOT TURN OFF THE CONSOLE" + notif_set 0 " 2/4 RESIZE ROOT FILESYSTEM^DO NOT TURN OFF THE CONSOLE" resize2fs ${root_part} if [ $? -ne 0 ]; then - notif " CANNOT RESIZE ROOT^FILESYSTEM" - exit 1 + notif_set 0 " CANNOT RESIZE ROOT^FILESYSTEM" + exit 1 fi ############################## # SHARED PARTITION PROCESSES # ############################## - notif " 3/4 COPY OPKS TO USB MOUNT^DO NOT TURN OFF THE CONSOLE" + notif_set 0 " 3/4 COPY FILES TO USB MOUNT^DO NOT TURN OFF THE CONSOLE" # Mount Rootfs mkdir -p ${root_mount} mount -t ext4 ${root_part} ${root_mount} if [ $? -ne 0 ]; then - notif "CANNOT MOUNT ROOT^FILESYSTEM" - exit 1 + notif_set 0 "CANNOT MOUNT ROOT^FILESYSTEM" + exit 1 fi # Copy OPKs cp -r ${root_mount}/usr/local/share/OPKs/* /mnt + # Copy freware games and other necessary mnt files + unzip -q -o ${root_mount}/usr/local/share/mnt_files.zip -d /mnt/ + # Fix PCE opk name if necessary - mv /mnt/Emulators/pce_mednaefn_funkey-s.opk /mnt/Emulators/pce_mednafen_funkey-s.opk 1>/dev/null 2>&1 + #mv /mnt/Emulators/pce_mednaefn_funkey-s.opk /mnt/Emulators/pce_mednafen_funkey-s.opk 1>/dev/null 2>&1 # Unmount Rootfs umount ${root_mount} if [ $? -ne 0 ]; then - notif "CANNOT UNMOUNT ROOT^FILESYSTEM" - exit 1 + notif_set 0 "CANNOT UNMOUNT ROOT^FILESYSTEM" + exit 1 fi # Change FunKey config files extension from .cfg to .fkcfg - SAVEIFS=$IFS - IFS=$(echo -en "\n\b") - for FOLDER in "Atari lynx" "Game Boy" "Game Boy Advance" "Game Boy Color" "Game Gear" "Neo Geo Pocket" "NES" "PCE-TurboGrafx" "PS1" "Sega Genesis" "Sega Master System" "SNES" "WonderSwan"; do - for FILE in $(ls /mnt/"${FOLDER}"/*.cfg 2>/dev/null); do - mv "$FILE" "${FILE%.cfg}.fkcfg" - done - done - IFS=$SAVEIFS + #SAVEIFS=$IFS + #IFS=$(echo -en "\n\b") + #for FOLDER in "Atari lynx" "Game Boy" "Game Boy Advance" "Game Boy Color" "Game Gear" "Neo Geo Pocket" "NES" "PCE-TurboGrafx" "PS1" "Sega Genesis" "Sega Master System" "SNES" "WonderSwan"; do + # for FILE in $(ls /mnt/"${FOLDER}"/*.cfg 2>/dev/null); do + # mv "$FILE" "${FILE%.cfg}.fkcfg" + # done + #done + #IFS=$SAVEIFS ##################### # Erase update file # ##################### for file in $(ls /mnt/FunKey-*.fwu); do - notif " 4/4 ERASE UPDATE FILE^DO NOT TURN OFF THE CONSOLE" - rm -f "${file}" + notif_set 0 " 4/4 ERASE UPDATE FILE^DO NOT TURN OFF THE CONSOLE" + rm -f "${file}" done exit 0 } diff --git a/FunKey/configs/funkey_defconfig b/FunKey/configs/funkey_defconfig index 6ec9ebc..51bec87 100644 --- a/FunKey/configs/funkey_defconfig +++ b/FunKey/configs/funkey_defconfig @@ -105,7 +105,7 @@ BR2_PACKAGE_UTIL_LINUX_BINARIES=y BR2_PACKAGE_NANO=y BR2_TARGET_ROOTFS_EXT2=y BR2_TARGET_ROOTFS_EXT2_4=y -BR2_TARGET_ROOTFS_EXT2_SIZE="200M" +BR2_TARGET_ROOTFS_EXT2_SIZE="220M" # BR2_TARGET_ROOTFS_TAR is not set BR2_PACKAGE_HOST_DOSFSTOOLS=y BR2_PACKAGE_HOST_DTC=y diff --git a/FunKey/package/FCEUX/FCEUX.mk b/FunKey/package/FCEUX/FCEUX.mk index 8e8d7db..268568a 100644 --- a/FunKey/package/FCEUX/FCEUX.mk +++ b/FunKey/package/FCEUX/FCEUX.mk @@ -4,7 +4,7 @@ # ################################################################################ -FCEUX_VERSION = fceux-FunKey-1.2.1 +FCEUX_VERSION = fceux-FunKey-1.2.2 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 d84acce..05e46d9 100644 --- a/FunKey/package/PCSX-ReARMed/PCSX-ReARMed.mk +++ b/FunKey/package/PCSX-ReARMed/PCSX-ReARMed.mk @@ -4,7 +4,7 @@ # ################################################################################ -PCSX_REARMED_VERSION = pcsx_rearmed-FunKey-1.2.1 +PCSX_REARMED_VERSION = pcsx_rearmed-FunKey-1.2.2 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 fd90c33..14dfab8 100644 --- a/FunKey/package/PocketSNES/PocketSNES.mk +++ b/FunKey/package/PocketSNES/PocketSNES.mk @@ -4,7 +4,7 @@ # ################################################################################ -POCKETSNES_VERSION = PocketSNES-FunKey-1.2.1 +POCKETSNES_VERSION = PocketSNES-FunKey-1.2.2 POCKETSNES_SITE_METHOD = git POCKETSNES_SITE = https://github.com/FunKey-Project/PocketSNES.git POCKETSNES_LICENSE = GPL-2.0 diff --git a/FunKey/package/ProdScreens/ProdScreens.mk b/FunKey/package/ProdScreens/ProdScreens.mk index b8ba6a5..5883ed4 100644 --- a/FunKey/package/ProdScreens/ProdScreens.mk +++ b/FunKey/package/ProdScreens/ProdScreens.mk @@ -4,7 +4,7 @@ # ################################################################################ -PRODSCREENS_VERSION = 428290b +PRODSCREENS_VERSION = FunKey-ProdScreens-FunKey-1.1.2 PRODSCREENS_SITE_METHOD = git PRODSCREENS_SITE = https://github.com/FunKey-Project/FunKey-ProdScreens.git PRODSCREENS_SITE_LICENSE = GPL-2.1+ diff --git a/FunKey/package/bibi/Config.in b/FunKey/package/bibi/Config.in new file mode 100644 index 0000000..30f5897 --- /dev/null +++ b/FunKey/package/bibi/Config.in @@ -0,0 +1,5 @@ +config BR2_PACKAGE_BIBI + bool "FunKey S - bibi" + default y + help + Bomberman game in c with SDL, readapted for the FunKey S. diff --git a/FunKey/package/bibi/bibi.mk b/FunKey/package/bibi/bibi.mk new file mode 100644 index 0000000..2f276e3 --- /dev/null +++ b/FunKey/package/bibi/bibi.mk @@ -0,0 +1,48 @@ +################################################################################ +# +# bibi +# +################################################################################ + +BIBI_VERSION = Bibi-FunKey-1.0.0 +BIBI_SITE_METHOD = git +BIBI_SITE = https://github.com/FunKey-Project/Bibi.git +BIBI_SITE_LICENSE = GPL-2.1+ +BIBI_SITE_LICENSE_FILES = COPYING + +BIBI_DEPENDENCIES = sdl sdl_image sdl_ttf + +BIBI_CFLAGS = $(TARGET_CFLAGS) + +BIBI_SDL_CFLAGS += $(shell $(STAGING_DIR)/usr/bin/sdl-config --cflags) +BIBI_SDL_LIBS += $(shell $(STAGING_DIR)/usr/bin/sdl-config --libs) +BIBI_SDL_CFLAGS += $(shell $(STAGING_DIR)/usr/bin/libmikmod-config --cflags) +BIBI_SDL_LIBS += $(shell $(STAGING_DIR)/usr/bin/libmikmod-config --libs) + +BIBI_CFLAGS += -ggdb -O3 +BIBI_CFLAGS += $(BIBI_SDL_CFLAGS) +BIBI_CFLAGS += -DFUNKEY -DHW_SCREEN_RESIZE -DSOUND_SDL_ACTIVATED -DBYPASS_MENU -DFUNKEY_MENU + +BIBI_LIBS += $(BIBI_SDL_LIBS) +BIBI_LIBS += -lSDL -lSDL_ttf -lSDL_image -lSDL_mixer + +define BIBI_BUILD_CMDS + (cd $(@D); \ + make \ + CROSS_COMPILE=$(TARGET_CROSS) \ + CFLAGS='$(BIBI_CFLAGS)' \ + LDFLAGS='$(BIBI_LIBS)' \ + SDL_INCLUDES='$(BIBI_SDL_CFLAGS)' \ + SDL_LIBS='$(BIBI_SDL_LIBS)' \ + ) +endef + +define BIBI_INSTALL_TARGET_CMDS + $(INSTALL) -d -m 0755 $(TARGET_DIR)/usr/games/bibi + $(INSTALL) -m 0755 $(@D)/bibi $(TARGET_DIR)/usr/games/bibi/bibi + $(INSTALL) -D -m 0755 -t $(TARGET_DIR)/usr/games/bibi/sprite $(@D)/sprite/* + $(INSTALL) -D -m 0755 -t $(TARGET_DIR)/usr/games/bibi/data $(@D)/data/* + $(INSTALL) -D -m 0755 -t $(TARGET_DIR)/usr/games/bibi/audio $(@D)/audio/* +endef + +$(eval $(generic-package)) diff --git a/FunKey/package/commander/commander.mk b/FunKey/package/commander/commander.mk index bb24cd1..035d449 100644 --- a/FunKey/package/commander/commander.mk +++ b/FunKey/package/commander/commander.mk @@ -3,7 +3,7 @@ # commander # ############################################################# -COMMANDER_VERSION = commander-FunKey-1.1.0 +COMMANDER_VERSION = commander-FunKey-1.1.1 COMMANDER_SITE_METHOD = git COMMANDER_SITE = https://github.com/FunKey-Project/commander.git COMMANDER_LICENSE = GPL-2.0 diff --git a/FunKey/package/fkgpiod/fkgpiod.mk b/FunKey/package/fkgpiod/fkgpiod.mk index 4ca8ffb..b7ad3a6 100644 --- a/FunKey/package/fkgpiod/fkgpiod.mk +++ b/FunKey/package/fkgpiod/fkgpiod.mk @@ -4,7 +4,7 @@ # ################################################################################ -FKGPIOD_VERSION = fkgpiod-FunKey-1.0.0 +FKGPIOD_VERSION = fkgpiod-FunKey-1.0.1 FKGPIOD_SITE_METHOD = git FKGPIOD_SITE = https://github.com/FunKey-Project/fkgpiod.git FKGPIOD_SITE_LICENSE = GPL-2.1+ diff --git a/FunKey/package/gmenu2x/gmenu2x.mk b/FunKey/package/gmenu2x/gmenu2x.mk index f4c037b..e99a797 100644 --- a/FunKey/package/gmenu2x/gmenu2x.mk +++ b/FunKey/package/gmenu2x/gmenu2x.mk @@ -3,7 +3,8 @@ # gmenu2x # ############################################################# -GMENU2X_VERSION = gmenu2x-FunKey-1.0.3 + +GMENU2X_VERSION = gmenu2x-FunKey-1.0.4 GMENU2X_SITE_METHOD = git GMENU2X_SITE = https://github.com/FunKey-Project/gmenu2x.git GMENU2X_LICENSE = GPL-2.0 diff --git a/FunKey/package/gnuboy/gnuboy.mk b/FunKey/package/gnuboy/gnuboy.mk index adda50b..a261d7f 100644 --- a/FunKey/package/gnuboy/gnuboy.mk +++ b/FunKey/package/gnuboy/gnuboy.mk @@ -4,7 +4,7 @@ # ################################################################################ -GNUBOY_VERSION = gnuboy-FunKey-1.2.1 +GNUBOY_VERSION = gnuboy-FunKey-1.2.2 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 40b6843..004fa32 100644 --- a/FunKey/package/gpsp/gpsp.mk +++ b/FunKey/package/gpsp/gpsp.mk @@ -4,7 +4,7 @@ # ################################################################################ -GPSP_VERSION = gpsp-FunKey-1.2.1 +GPSP_VERSION = gpsp-FunKey-1.2.2 GPSP_SITE_METHOD = git GPSP_SITE = https://github.com/FunKey-Project/gpsp.git GPSP_LICENSE = GPL-2.0 diff --git a/FunKey/package/libopk/libopk.mk b/FunKey/package/libopk/libopk.mk index 53b4bdc..a0260fb 100644 --- a/FunKey/package/libopk/libopk.mk +++ b/FunKey/package/libopk/libopk.mk @@ -3,7 +3,8 @@ # libopk # ############################################################# -LIBOPK_VERSION = libopk-FunKey-1.0.2 + +LIBOPK_VERSION = libopk-FunKey-1.0.3 LIBOPK_SITE_METHOD = git LIBOPK_SITE = https://github.com/FunKey-Project/libopk.git diff --git a/FunKey/package/mednafen/mednafen.mk b/FunKey/package/mednafen/mednafen.mk index 8de4762..56cd0ba 100644 --- a/FunKey/package/mednafen/mednafen.mk +++ b/FunKey/package/mednafen/mednafen.mk @@ -4,7 +4,7 @@ # ################################################################################ -MEDNAFEN_VERSION = mednafen-git-FunKey-1.2.1 +MEDNAFEN_VERSION = mednafen-git-FunKey-1.2.2 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 a2a7e50..3d0ead1 100644 --- a/FunKey/package/picodrive/picodrive.mk +++ b/FunKey/package/picodrive/picodrive.mk @@ -4,9 +4,9 @@ # ################################################################################ -PICODRIVE_VERSION = picodrive-FunKey-1.2.2 +PICODRIVE_VERSION = picodrive-FunKey-1.3.1 PICODRIVE_SITE_METHOD = git -PICODRIVE_SITE = https://github.com/FunKey-Project/picodrive.git +PICODRIVE_SITE = https://github.com/FunKey-Project/picodrive-irixxxx.git PICODRIVE_LICENSE = MAME PICODRIVE_LICENSE_FILES = COPYING diff --git a/FunKey/package/retrofe/retrofe.mk b/FunKey/package/retrofe/retrofe.mk index 1140671..a0787fe 100644 --- a/FunKey/package/retrofe/retrofe.mk +++ b/FunKey/package/retrofe/retrofe.mk @@ -4,7 +4,7 @@ # ################################################################################ -RETROFE_VERSION = RetroFE-FunKey-1.1.2 +RETROFE_VERSION = RetroFE-FunKey-1.1.4 RETROFE_SITE_METHOD = git RETROFE_SITE = https://github.com/FunKey-Project/RetroFE.git RETROFE_DEPENDENCIES = gstreamer1 gst1-plugins-base sdl sdl_image sdl_mixer sdl_sound sdl_ttf libglib2 sqlite zlib diff --git a/Recovery/board/funkey/rootfs-overlay/etc/fkgpiod.conf b/Recovery/board/funkey/rootfs-overlay/etc/fkgpiod.conf index 49ef00e..2325877 100644 --- a/Recovery/board/funkey/rootfs-overlay/etc/fkgpiod.conf +++ b/Recovery/board/funkey/rootfs-overlay/etc/fkgpiod.conf @@ -15,11 +15,11 @@ MAP B TO KEY KEY_B MAP X TO KEY KEY_X MAP Y TO KEY KEY_Y MAP MENU TO KEY KEY_Q -MAP FN+UP TO COMMAND snap -MAP FN+A TO COMMAND quick_action_volume_up -MAP FN+Y TO COMMAND quick_action_volume_down -MAP FN+X TO COMMAND quick_action_bright_up -MAP FN+B TO COMMAND quick_action_bright_down +MAP FN+UP TO COMMAND snapshot +MAP FN+A TO COMMAND volume up +MAP FN+Y TO COMMAND volume down +MAP FN+X TO COMMAND brightness up +MAP FN+B TO COMMAND brightness down MAP FN+L TO KEY KEY_V MAP FN+R TO KEY KEY_O -MAP FN+L+R TO COMMAND display_notif_system_stats +MAP FN+L+R TO COMMAND system_stats toggle diff --git a/Recovery/board/funkey/rootfs-overlay/etc/init.d/S60recovery b/Recovery/board/funkey/rootfs-overlay/etc/init.d/S60recovery index c023ef2..28ca0cb 100755 --- a/Recovery/board/funkey/rootfs-overlay/etc/init.d/S60recovery +++ b/Recovery/board/funkey/rootfs-overlay/etc/init.d/S60recovery @@ -10,7 +10,7 @@ case "$1" in if [ "${keys}" != "0xF83F" ]; then # Automatic firmware update requested - updates=$(ls /mnt/FunKey-*.fwu) + updates=$(ls /mnt/FunKey-*.fwu 2>/dev/null) if [ "x${updates}" = "x" ]; then menu & exit 1 @@ -18,11 +18,11 @@ case "$1" in for file in ${updates} ; do swupdate -i "${file}" if [ $? -ne 0 ]; then - notif_disp 10 " CORRUPTED^ UPDATE FILE" + notif display 10 " CORRUPTED^ UPDATE FILE" rm -f "${file}" fi done - notif "^^^^^^^^ RESTARTING...^^^^^^^^" + notif set 0 "^^^^^^^^ RESTARTING...^^^^^^^^" normal_mode else diff --git a/Recovery/board/funkey/rootfs-overlay/etc/issue b/Recovery/board/funkey/rootfs-overlay/etc/issue index d2e81a5..cb97a30 100644 --- a/Recovery/board/funkey/rootfs-overlay/etc/issue +++ b/Recovery/board/funkey/rootfs-overlay/etc/issue @@ -5,6 +5,6 @@ |___| |_____|__|__||__|\__||_____|___ | FUN ON A KEYCHAIN |_____| ----------------------------------------------------- - Version 2.1.0 (Recovery) + Version 2.3.0 (Recovery) ----------------------------------------------------- diff --git a/Recovery/board/funkey/rootfs-overlay/etc/os-release b/Recovery/board/funkey/rootfs-overlay/etc/os-release index b8841f8..79857e6 100644 --- a/Recovery/board/funkey/rootfs-overlay/etc/os-release +++ b/Recovery/board/funkey/rootfs-overlay/etc/os-release @@ -1,12 +1,12 @@ NAME="FunKey-OS Recovery" -VERSION="2.1.0 (Hoopy Hawk)" +VERSION="2.3.0 (Zen Zebu)" ID=funkey-recovery ID_LIKE=buildroot -PRETTY_NAME="FunKey-OS Recovery 2.1.0" -VERSION_ID="2.1.0" +PRETTY_NAME="FunKey-OS Recovery 2.3.0" +VERSION_ID="2.3.0" HOME_URL="https://www.funkey-project.com/" SUPPORT_URL="https://www.funkey-project.com/" BUG_REPORT_URL="https://www.funkey-project.com/" PRIVACY_POLICY_URL="https://www.funkey-project.com" -VERSION_CODENAME=Hoopy -UBUNTU_CODENAME=Hoopy +VERSION_CODENAME=Zen +UBUNTU_CODENAME=Zen diff --git a/Recovery/board/funkey/rootfs-overlay/etc/sw-versions b/Recovery/board/funkey/rootfs-overlay/etc/sw-versions index 175a929..8e9cb2d 100644 --- a/Recovery/board/funkey/rootfs-overlay/etc/sw-versions +++ b/Recovery/board/funkey/rootfs-overlay/etc/sw-versions @@ -1 +1 @@ -Recovery 2.1.0 +Recovery 2.3.0 diff --git a/Recovery/board/funkey/rootfs-overlay/root/.profile b/Recovery/board/funkey/rootfs-overlay/root/.profile index 5e99a35..02dd032 100755 --- a/Recovery/board/funkey/rootfs-overlay/root/.profile +++ b/Recovery/board/funkey/rootfs-overlay/root/.profile @@ -36,6 +36,6 @@ resize() { fi } -# Reset saved brightness -echo "Reset saved brightness" -brightness_set $(brightness_get) >/dev/null 2>&1 +# Restore saved brightness +echo "Restore saved brightness" +brightness set $(brightness get) >/dev/null 2>&1 diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/lib/utils b/Recovery/board/funkey/rootfs-overlay/usr/local/lib/utils index a770cca..7a68128 100755 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/lib/utils +++ b/Recovery/board/funkey/rootfs-overlay/usr/local/lib/utils @@ -18,12 +18,3 @@ if [ $? -ne 0 ]; then exit $return_code } fi - -notif () { - info "$@" - printf "$@" > /sys/class/graphics/fb0/notification -} - -clear_notif () { - printf "clear" > /sys/class/graphics/fb0/notification -} diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness new file mode 100755 index 0000000..f91d542 --- /dev/null +++ b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness @@ -0,0 +1,128 @@ +#!/bin/sh + +# Uncomment the following line to get debug info +#set -x + +SELF="$(basename ${0})" +SYSTEM_BRIGHTNESS="/sys/class/backlight/backlight/brightness" +DEFAULT_BRIGHTNESS_VALUE=100 +BRIGHTNESS_STEP=10 +NOTIF_DURATION=2 + +usage() { + >&2 echo "Usage: ${SELF} get" + >&2 echo " ${SELF} set new_brightness_percentage" + exit 1 +} + +increase_brightness() { + + # Get current value + local current_brightness=$(get_brightness) + + # Compute new brightness value + local new_brightness=0 + let new_brightness=${current_brightness}+${BRIGHTNESS_STEP} + if [ ${new_brightness} -gt 100 ]; then + new_brightness=100 + fi + + # Change brightness + if [ ${new_brightness} -ne ${current_brightness} ]; then + set_brightness ${new_brightness} + fi + + # Notif + notif set ${NOTIF_DURATION} " BRIGHTNESS: ${new_brightness}%%" +} + +decrease_brightness() { + + # Get current value + local current_brightness=$(get_brightness) + + # Compute new brightness value + local new_brightness=0 + if [ ${current_brightness} -gt ${BRIGHTNESS_STEP} ]; then + let new_brightness=${current_brightness}-${BRIGHTNESS_STEP} + fi + + # Change brightness + if [ ${new_brightness} -ne ${current_brightness} ]; then + set_brightness ${new_brightness} + fi + + # Notif + notif set ${NOTIF_DURATION} " BRIGHTNESS: ${new_brightness}%%" +} + +get_brightness() { + local brightness=$(fw_printenv -n brightness 2>/dev/null) + if ! [ ! "${brightness}" -ne "${brightness}" ] 2> /dev/null; then + brightness=${DEFAULT_BRIGHTNESS_VALUE} + fw_setenv brightness ${brightness} + fi + echo ${brightness} +} + +set_brightness() { + + # Set the new brightness percentage in the kernel driver + local brightness=${1} + local kernel_brightness + let kernel_brightness=${brightness}+10 + let kernel_brightness/=10 + echo ${kernel_brightness} > "${SYSTEM_BRIGHTNESS}" + + # Set the new brightness value in a bootloader variable + if [ ${?} -eq 0 -a $(get_brightness) -ne ${brightness} ]; then + fw_setenv brightness ${brightness} + fi +} + +# Check number of arguments +if [ ${#} -lt 1 -o ${#} -gt 2 ]; then + usage +fi + +case "${1}" in + up) + if [ ${#} -ne 1 ]; then + usage + fi + increase_brightness + ;; + + down) + if [ ${#} -ne 1 ]; then + usage + fi + decrease_brightness + ;; + + get) + if [ ${#} -ne 1 ]; then + usage + fi + get_brightness + ;; + + set) + if [ ${#} -ne 2 ]; then + usage + fi + + # Make sure the argument is a positive number <= 100 + if [ -n "${2}" ] && [ "${2}" -eq "${2}" ] 2>/dev/null && \ + [ "${2}" -ge 0 ] && [ "${2}" -le 100 ]; then + set_brightness "${2}" + else + usage + fi + ;; + + *) + usage + ;; +esac +exit 0 diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness_get b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness_get deleted file mode 100755 index d664293..0000000 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness_get +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -BRIGHTNESS_DEFAULT_VALUE=100 - -# Check args -if [ ${#} -ne 0 ]; then - echo "Usage: $(basename ${0})" - exit 1 -fi - -# Sanity check: Check if integer -brightness=$(fw_printenv -n brightness 2>/dev/null) -if ! [ ! "${brightness}" -ne "${brightness}" ] 2> /dev/null; then - brightness=${BRIGHTNESS_DEFAULT_VALUE} - fw_setenv brightness ${brightness} -fi -echo ${brightness} -exit 0 diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness_get_sysfs b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness_get_sysfs deleted file mode 100755 index a682958..0000000 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness_get_sysfs +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -SYSTEM_BRIGHTNESS=/sys/class/backlight/backlight/brightness - -# Check args -if [ ${#} -ne 0 ]; then - echo "Usage: $(basename ${0})" - exit 1 -fi - -let brightness=$(cat ${SYSTEM_BRIGHTNESS})*10-10 -echo ${brightness} -exit 0 diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness_set b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness_set deleted file mode 100755 index 8d45575..0000000 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness_set +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -SYSTEM_BRIGHTNESS=/sys/class/backlight/backlight/brightness - -# Check args -if [ ${#} -ne 1 ]; then - echo "Usage: $(basename ${0}) new_brightness_percentage" - exit 1 -fi - -# Check value's range -if [ ${1} -gt 100 ]; then - echo "Usage: Wrong brightness percentage (${1}), must be between 0 and 100" - exit 1 -fi -brightness_percentage=${1} - -# Set new brightness percentage -let value=${1}+10 -let value/=10 -echo ${value} > ${SYSTEM_BRIGHTNESS} - -# Set new brightness value in brightness file -if [ ${?} -eq 0 -a $(brightness_get) -ne ${brightness_percentage} ]; then - fw_setenv brightness ${brightness_percentage} -fi -exit 0 diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness_set_sysfs b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness_set_sysfs deleted file mode 100755 index 424a3d8..0000000 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness_set_sysfs +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -SYSTEM_BRIGHTNESS=/sys/class/backlight/backlight/brightness - -# Check args -if [ ${#} -ne 1 ]; then - echo "Usage: $(basename ${0}) new_brightness_percentage" - exit 1 -fi - -# Check value's range -if [ ${1} -gt 100 ]; then - echo "Usage: Wrong brightness percentage (${1}), must be between 0 and 100" - exit 1 -fi - -# Set new brightness percentage -let value=${1}+10 -let value/=10 -echo ${value} > ${SYSTEM_BRIGHTNESS} -exit 0 diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/display_notif_system_stats b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/display_notif_system_stats deleted file mode 100755 index 5c4638d..0000000 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/display_notif_system_stats +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -notif_set 0 "Getting system stats..." -killall -s USR1 system_stats -exit 0 diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/low_bat_check b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/low_bat_check index b1a70da..e9dcfe9 100755 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/low_bat_check +++ b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/low_bat_check @@ -3,30 +3,28 @@ # General constants declaration THRESHOLD_PERCENT_LOW_BAT=5 THRESHOLD_PERCENT_EXTREMELY_LOW_BAT=2 -MAX_EXTREMELY_LOW_BAT_BEFORE_SHUTDOWN=5 +MAX_LOW_BAT_COUNT=5 SLEEP_SECS=2 RESCALE_MAX_PERCENTAGE=120 # Blink Low bat constants declaration BLINK_ICON=0 -LOW_BAT_SECS_DISPLAYED=5 -LOW_BAT_SECS_NOT_DISPLAYED=5 +LOW_BAT_DISPLAY_TIMEOUT=5 # Files and commands declaration -USB_PRESENT_FILE=/sys/class/power_supply/axp20x-usb/present -#USB_PRESENT_FILE=/sys/class/power_supply/axp20x-ac/present # Cheat for no USB present simulation when debugging -BAT_PRESENT_FILE=/sys/class/power_supply/axp20x-battery/present -BAT_PERCENT_FILE=/sys/class/power_supply/axp20x-battery/capacity -BAT_PERCENT_RESCALED_FILE=/tmp/current_battery_percentage -LOW_BAT_ICON=/sys/class/graphics/fb0/low_battery -SCHEDULE_SHUTDOWN_CMD=sched_shutdown -SIGNAL_URS1_TO_EMULATORS_CMD=signal_usr1_to_emulators +USB_PRESENT_FILE="/sys/class/power_supply/axp20x-usb/present" + +# Cheat for no USB present simulation when debugging +BAT_PRESENT_FILE="/sys/class/power_supply/axp20x-battery/present" +BAT_PERCENT_FILE="/sys/class/power_supply/axp20x-battery/capacity" +BAT_PERCENT_RESCALED_FILE="/tmp/current_battery_percentage" +LOW_BAT_ICON="/sys/class/graphics/fb0/low_battery" # Variables declaration low_bat_status=0 low_bat_displayed=0 cur_secs_disp=0 -cur_nb_extremely_low_bat_before_shutdown=0 +low_bat_count=0 # Default: Hide Low Bat Icon echo 0 > ${LOW_BAT_ICON} @@ -55,64 +53,64 @@ while true; do # Low bat status detection if [ "$(cat ${USB_PRESENT_FILE})" -eq "0" ]; then - # Value of 0 means wrong i2c reading - if [ "${cur_bat_percent}" -ne "0" ]; then + # Value of 0 means wrong i2c reading + if [ "${cur_bat_percent}" -ne "0" ]; then - # Check if we must change state - if [ ${cur_bat_percent} -le ${THRESHOLD_PERCENT_LOW_BAT} -a ${low_bat_status} -eq 0 ]; then + # Check if we must change state + if [ ${cur_bat_percent} -le ${THRESHOLD_PERCENT_LOW_BAT} -a ${low_bat_status} -eq 0 ]; then - # Set Low Bat status - low_bat_status=1 - low_bat_displayed=1 - cur_secs_disp=0 - echo 1 > ${LOW_BAT_ICON} + # Set Low Bat status + low_bat_status=1 + low_bat_displayed=1 + cur_secs_disp=0 + echo 1 > ${LOW_BAT_ICON} - elif [ ${cur_bat_percent} -gt ${THRESHOLD_PERCENT_LOW_BAT} -a ${low_bat_status} -eq 1 ]; then + elif [ ${cur_bat_percent} -gt ${THRESHOLD_PERCENT_LOW_BAT} -a ${low_bat_status} -eq 1 ]; then - # Reset status - low_bat_status=0 - cur_nb_extremely_low_bat_before_shutdown=0 - echo 0 > ${LOW_BAT_ICON} - fi - fi + # Reset status + low_bat_status=0 + low_bat_count=0 + echo 0 > ${LOW_BAT_ICON} + fi + fi else - if [ ${low_bat_status} -eq 1 ]; then + if [ ${low_bat_status} -eq 1 ]; then - # Reset status - low_bat_status=0 - cur_nb_extremely_low_bat_before_shutdown=0 - echo 0 > ${LOW_BAT_ICON} - fi + # Reset status + low_bat_status=0 + low_bat_count=0 + echo 0 > ${LOW_BAT_ICON} + fi fi # Low bat processing if [ ${low_bat_status} -eq 1 ]; then - # Check extremely low bat for clean shutdown - if [ ${cur_bat_percent} -le ${THRESHOLD_PERCENT_EXTREMELY_LOW_BAT} ]; then - let cur_nb_extremely_low_bat_before_shutdown++ - echo "cur_nb_extremely_low_bat_before_shutdown = ${cur_nb_extremely_low_bat_before_shutdown}" + # Check extremely low bat for clean shutdown + if [ ${cur_bat_percent} -le ${THRESHOLD_PERCENT_EXTREMELY_LOW_BAT} ]; then + let low_bat_count++ + echo "low_bat_count = ${low_bat_count}" - # Clean shutdown - if [ ${cur_nb_extremely_low_bat_before_shutdown} -ge ${MAX_EXTREMELY_LOW_BAT_BEFORE_SHUTDOWN} ]; then - echo "Battery extremely low, shutting down now..." - sched_shutdown 1 & signal_usr1_to_emulators - exit 0 - fi - fi + # Clean shutdown + if [ ${low_bat_count} -ge ${MAX_LOW_BAT_COUNT} ]; then + echo "Battery extremely low, shutting down now..." + powerdown schedule 1 + exit 0 + fi + fi - # Blinking process - if [ ${BLINK_ICON} -eq 1 ]; then - if [ ${low_bat_displayed} -eq 1 -a ${cur_secs_disp} -ge ${LOW_BAT_SECS_DISPLAYED} ]; then - low_bat_displayed=0 - cur_secs_disp=0 - echo 0 > ${LOW_BAT_ICON} - elif [ ${low_bat_displayed} -eq 0 -a ${cur_secs_disp} -ge ${LOW_BAT_SECS_NOT_DISPLAYED} ]; then - low_bat_displayed=1 - cur_secs_disp=0 - echo 1 > ${LOW_BAT_ICON} - fi - fi + # Blinking process + if [ ${BLINK_ICON} -eq 1 ]; then + if [ ${low_bat_displayed} -eq 1 -a ${cur_secs_disp} -ge ${LOW_BAT_DISPLAY_TIMEOUT} ]; then + low_bat_displayed=0 + cur_secs_disp=0 + echo 0 > ${LOW_BAT_ICON} + elif [ ${low_bat_displayed} -eq 0 -a ${cur_secs_disp} -ge ${LOW_BAT_DISPLAY_TIMEOUT} ]; then + low_bat_displayed=1 + cur_secs_disp=0 + echo 1 > ${LOW_BAT_ICON} + fi + fi fi # Sleep before next check diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/menu b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/menu index c0571fd..d23b5c6 100755 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/menu +++ b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/menu @@ -11,8 +11,6 @@ getkey() { # Display meny item menu_display () { local entry=${1} - - #clear_notif case ${entry} in 0) @@ -46,9 +44,9 @@ menu_display () { # Network enable/disable if [ -e /mnt/usbnet ]; then - message=" NETWORK DISABLE" + message=" NETWORK: ENABLED" else - message=" NETWORK ENABLE" + message=" NETWORK: DISABLED" fi ;; @@ -63,9 +61,9 @@ menu_display () { # Factory tests enable/disable RUN_ENV_VAR=$(fw_printenv -n assembly_tests 2>/dev/null) if [ "x${RUN_ENV_VAR}" == "x1" ]; then - message=" FACTORY TESTS DISABLE" + message=" FACTORY TESTS: ENABLED" else - message=" FACTORY TESTS ENABLE" + message=" FACTORY TESTS: DISABLED" fi ;; @@ -74,9 +72,9 @@ menu_display () { # First boot enable/disable FIRST_BOOT_OK_ENV_VAR=$(fw_printenv -n first_boot_ok 2>/dev/null) if [ "x${FIRST_BOOT_OK_ENV_VAR}" == "x1" ]; then - message=" FIRST BOOT DISABLE" + message=" FIRST BOOT: DISABLED" else - message=" FACTORY TESTS ENABLE" + message=" FIRST BOOT: ENABLED" fi ;; @@ -92,7 +90,7 @@ menu_display () { message=" SHUTDOWN" ;; esac - notif "${message}" + notif set 0 "${message}" } # Run menu item @@ -114,7 +112,7 @@ menu_run () { umount ${rootfs_mount} version_recovery=$(grep Recovery /etc/sw-versions | cut -f 2) ip_addr=$(ifconfig usb0 | grep "inet " | awk -F'[: ]+' '{ print $4 }') - notif "${message}^^ Recovery: ${version_recovery}^ rootfs : ${version_rootfs}^ IP addr : ${ip_addr}" + notif set 0 "${message}^^ Recovery: ${version_recovery}^ rootfs : ${version_rootfs}^ IP addr : ${ip_addr}" ;; 1) @@ -122,31 +120,31 @@ menu_run () { # USB mount/unmount mount | grep -q /dev/mmcblk0p4 if [ $? -eq 0 ]; then - notif "${message}..." + notif set 0 "${message}..." share start if [ $? -ne 0 ]; then - notif "${message}...^CANNOT MOUNT USB!" + notif set 0 "${message}...^CANNOT MOUNT USB!" else message=" USB UNMOUNT" - notif "${message}" + notif set 0 "${message}" fi else - notif "${message}..." + notif set 0 "${message}..." share stop if [ $? -ne 0 ]; then - notif "${message}...^CANNOT UNMOUNT USB!" + notif set 0 "${message}...^CANNOT UNMOUNT USB!" else for file in $(ls /mnt/FunKey-*.fwu); do swupdate -i "${file}" if [ $? -ne 0 ]; then - notif_disp 10 "${message}...^ CORRUPTED^ UPDATE FILE" + notif set 0 display 10 "${message}...^ CORRUPTED^ UPDATE FILE" rm -f "${file}" - notif "^^^^^^^^ RESTARTING...^^^^^^^^" + notif set 0 "^^^^^^^^ RESTARTING...^^^^^^^^" normal_mode fi done message=" USB MOUNT" - notif "${message}" + notif set 0 "${message}" fi fi ;; @@ -156,23 +154,23 @@ menu_run () { # USB check mount | grep -q /dev/mmcblk0p4 if [ $? -eq 0 ]; then - notif "${message}..." + notif set 0 "${message}..." umount /mnt >/dev/null 2>&1 if [ $? -ne 0 ]; then - notif "${message}...^CANNOT CHECK USB!" + notif set 0 "${message}...^CANNOT CHECK USB!" fi fsck.fat -a -v -w /dev/mmcblk0p4 if [ $? -ne 0 ]; then - notif "${message}...^CANNOT CHECK USB!" + notif set 0 "${message}...^CANNOT CHECK USB!" fi mount /mnt if [ $? -ne 0 ]; then - notif "${message}...^CANNOT CHECK USB!" + notif set 0 "${message}...^CANNOT CHECK USB!" else - notif "${message} DONE" + notif set 0 "${message} DONE" fi else - notif "${message}...^CANNOT CHECK USB WHEN MOUNTED!" + notif set 0 "${message}...^CANNOT CHECK USB WHEN MOUNTED!" fi ;; @@ -181,7 +179,7 @@ menu_run () { # USB format mount | grep -q /dev/mmcblk0p4 if [ $? -eq 0 ]; then - notif "${message}...^PRESS A TO CONFIRM" + notif set 0 "${message}...^PRESS A TO CONFIRM" while true; do case $(getkey) in 1e0001|1e0002) @@ -189,9 +187,9 @@ menu_run () { mkfs.vfat /dev/mmcblk0p4 && mount /mnt if [ $? -ne 0 ]; then - notif "${message}...^CANNOT FORMAT USB!" + notif set 0 "${message}...^CANNOT FORMAT USB!" else - notif "${message} DONE" + notif set 0 "${message} DONE" fi break ;; @@ -200,13 +198,13 @@ menu_run () { ;; *) - notif "${message}...^ABORTED!" + notif set 0 "${message}...^ABORTED!" break ;; esac done else - notif "${message}...^CANNOT FORMAT USB WHEN MOUNTED!" + notif set 0 "${message}...^CANNOT FORMAT USB WHEN MOUNTED!" fi ;; @@ -217,14 +215,14 @@ menu_run () { if [ $? -eq 0 ]; then if [ -e /mnt/usbnet ]; then rm -f /mnt/usbnet - message=" NETWORK ENABLE" + message=" NETWORK: DISABLED" else touch /mnt/usbnet - message=" NETWORK DISABLE" + message=" NETWORK: ENABLED" fi - notif "${message}" + notif set 0 "${message}" else - notif "${message}...^CANNOT CHANGE NET IF MOUNTED!" + notif set 0 "${message}...^CANNOT CHANGE NET IF MOUNTED!" fi ;; @@ -241,12 +239,12 @@ menu_run () { RUN_ENV_VAR=$(fw_printenv -n assembly_tests 2>/dev/null) if [ "x${RUN_ENV_VAR}" == "x1" ]; then fw_setenv assembly_tests 0 - message=" FACTORY TESTS ENABLE" + message=" FACTORY TESTS: DISABLED" else fw_setenv assembly_tests 1 - message=" FACTORY TESTS DISABLE" + message=" FACTORY TESTS: ENABLED" fi - notif "${message}" + notif set 0 "${message}" ;; 7) @@ -255,21 +253,21 @@ menu_run () { FIRST_BOOT_OK_ENV_VAR=$(fw_printenv -n first_boot_ok 2>/dev/null) if [ "x${FIRST_BOOT_OK_ENV_VAR}" == "x1" ]; then fw_setenv first_boot_ok - message=" FIRST BOOT ENABLE" + message=" FIRST BOOT: ENABLED" else fw_setenv first_boot_ok 1 - message=" FIRST BOOT DISABLE" + message=" FIRST BOOT: DISABLED" fi - notif "${message}" + notif set 0 "${message}" ;; 8) - notif "^^^^^^^^ RESTARTING...^^^^^^^^" + notif set 0 "^^^^^^^^ RESTARTING...^^^^^^^^" normal_mode ;; 9) - notif "^^^^^^^^ SHUTDOWN...^^^^^^^^" + notif set 0 "^^^^^^^^ SHUTDOWN...^^^^^^^^" poweroff ;; esac diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/notif b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/notif new file mode 100755 index 0000000..2a16366 --- /dev/null +++ b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/notif @@ -0,0 +1,78 @@ +#!/bin/sh + +# Uncomment the following line to get debug info +#set -x + +SELF="$(basename ${0})" +NOTIFICATION_DISPLAY=/sys/class/graphics/fb0/notification + +usage() { + >&2 echo "Usage: ${SELF} set duration message" + >&2 echo " ${SELF} display duration message" + >&2 echo " ${SELF} clear" + exit 1 +} + +notif_clear() { + + echo -n "clear" > "${NOTIFICATION_DISPLAY}" +} + +notif_display() { + local duration="${1}" + local message="${*:2}" + if ! [ ! "${duration}" -ne "${duration}" ] 2> /dev/null; then + >&2 echo "error: ${duration} is not a number" + exit 3 + fi + echo -n "${message}" > "${NOTIFICATION_DISPLAY}" + if [ ${duration} -ne 0 ]; then + sleep ${duration} + notif_clear + fi +} + +notif_set() { + local duration="${1}" + local message="${*:2}" + if ! [ ! "${duration}" -ne "${duration}" ]; then + >&2 echo "error: ${duration} is not a number" + exit 2 + fi + + # Kill previous notif disp process + pkill -f "notif display" 2> /dev/null + + # Print new notif + notif display "${duration}" "${message}" & +} + +case "${1}" in + set) + if [ ${#} -ne 3 ]; then + usage + fi + shift + notif_set "${1}" "${2}" + ;; + + clear) + if [ ${#} -ne 1 ]; then + usage + fi + notif_clear + ;; + + display) + if [ ${#} -ne 3 ]; then + usage + fi + shift + notif_display "${1}" "${2}" + ;; + + *) + usage + ;; +esac +exit 0 diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/notif_clear b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/notif_clear deleted file mode 100755 index 44f6c1b..0000000 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/notif_clear +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# Clear all current notifications - -NOTIFICATION_DISPLAY=/sys/class/graphics/fb0/notification - -printf "clear" > ${NOTIFICATION_DISPLAY} - -exit 0 diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/notif_disp b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/notif_disp deleted file mode 100755 index d40bd9f..0000000 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/notif_disp +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -# Display notification for a certain amount of time -# Special char: ^ to add a new line -# Set seconds to 0 to display indefinitely (until the next notif) - -NOTIFICATION_DISPLAY=/sys/class/graphics/fb0/notification - -display_usage() { - echo -e "Usage:\n$(basename ${0}) nb_seconds_display message_to_display\n" -} - -# If less than two arguments supplied, display usage -if [ ${#} -le 1 ]; then - echo "Display notification for a certain amount of time" - display_usage - exit 1 -fi - -# Get number of seconds to display notif -nb_secs=${1} -if ! [ ! "${nb_secs}" -ne "${nb_secs}" ] 2> /dev/null; then - echo "error: ${nb_secs} is not a number" >&2 - exit 1 -fi - -# Print notif -printf "${*:2}" > ${NOTIFICATION_DISPLAY} - -# Clear notif if NB_SECS is not 0, otherwise never clear -if [ ${nb_secs} -ne 0 ]; then - - # Wait time before clearing notif - sleep ${nb_secs} - - # Clear notif - printf "clear" > ${NOTIFICATION_DISPLAY} -fi -exit 0 diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/notif_set b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/notif_set deleted file mode 100755 index bc04835..0000000 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/notif_set +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# Erase previous notif and display new one in background process for a certain amount of seconds -# Special char: ^ to add a new line -# Set seconds to 0 to display indefinitely (until the next notif_set) - -NOTIFICATION_DISPLAY=/sys/class/graphics/fb0/notification - -display_usage() { - echo -e "Usage:\n$(basename ${0}) nb_seconds_display message_to_display\n" -} - -# If less than two arguments supplied, display usage -if [ ${#} -le 1 ]; then - echo "Erase previous notif and display new one in background process for a certain amount of time" - echo "Special char: ^ to add a new line" - echo "Set seconds to 0 to display indefinitely (until the next $(basename ${0}))" - display_usage - exit 1 -fi - -# Get number of seconds to display notif -nb_secs=${1} -if ! [ ! "${nb_secs}" -ne "${nb_secs}" ]; then - echo "error: ${nb_secs} is not a number" >&2 - exit 1 -fi - -# Kill previous notif_disp process -pkill notif_disp 2> /dev/null - -## Clear previous notif -#printf "clear" > ${NOTIFICATION_DISPLAY} - -# Print new notif -notif_disp "$@" & -exit 0 diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/powerdown b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/powerdown new file mode 100755 index 0000000..ac48edd --- /dev/null +++ b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/powerdown @@ -0,0 +1,84 @@ +#!/bin/sh + +# Uncomment the following line to get debug info +#set -x + +SELF="$(basename ${0})" +PID_FILE="/var/run/funkey.pid" +REBOOTING_FILE="/run/rebooting" + +usage() { + >&2 echo "Usage: ${SELF} schedule delay" + >&2 echo " ${SELF} handle" + >&2 echo " ${SELF} now" + exit 1 +} + +schedule_powerdown() { + + # Send USR1 signal to the running FunKey process to warn about + # impending shutdown + pkill -USR1 -F "${PID_FILE}" > /dev/null 2>&1 + + # 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} + + # Delay expired, initiate final powerdown + powerdown_now +} + +handle_powerdown() { + pkill -f "powerdown schedule" +} + +powerdown_now() { + + # Sync before all else + sync + + # Notif fullscreen "Shutting down" + notif set 0 "^^^^^^^^ SHUTTING DOWN...^^^^^^^^" + + # Notify system, reboot in progress + touch "${REBOOTING_FILE}" + + # Shutdown amp + audio_amp off >/dev/null 2>&1 + + # Force Read Only + ro + + # Poweroff + poweroff +} + +action="${1:-now}" +case "${action}" in + schedule) + if [ ${#} != 2 -o "${2}" -eq 0 ]; then + usage + fi + schedule_powerdown + ;; + + handle) + if [ ${#} -ne 1 ]; then + usage + fi + handle_powerdown + ;; + + now) + if [ ${#} -gt 1 ]; then + usage + fi + powerdown_now + ;; + + *) + usage + ;; +esac +exit 0 diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_bright_down b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_bright_down deleted file mode 100755 index b2170d5..0000000 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_bright_down +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -STEP_BRIGHTNESS=10 -NOTIF_DURATION=2 - -# Get current value -current_brightness=$(brightness_get) - -# Compute new brightness value -new_brightness=0 -if [ ${current_brightness} -gt ${STEP_BRIGHTNESS} ]; then - let new_brightness=${current_brightness}-${STEP_BRIGHTNESS} -fi - -# Change brightness -if [ ${new_brightness} -ne ${current_brightness} ]; then - brightness_set ${new_brightness} -fi - -# Notif -#notif_set ${NOTIF_DURATION} " BRIGHTNESS: ${new_brightness}%%" -exit 0 diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_bright_up b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_bright_up deleted file mode 100755 index 71235b5..0000000 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/quick_action_bright_up +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -STEP_BRIGHTNESS=10 -NOTIF_DURATION=2 - -# Get current value -current_brightness=$(brightness_get) - -# Compute new brightness value -let new_brightness=${current_brightness}+${STEP_BRIGHTNESS} -if [ ${new_brightness} -gt 100 ]; then - new_brightness=100 -fi - -# Change brightness -if [ ${new_brightness} -ne ${current_brightness} ]; then - brightness_set ${new_brightness} -fi - -# Notif -#notif_set ${NOTIF_DURATION} " BRIGHTNESS: ${new_brightness}%%" -exit 0 diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/sched_shutdown b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/sched_shutdown deleted file mode 100755 index d555501..0000000 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/sched_shutdown +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -# No waiting period in Recovery - -shutdown_funkey diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/shutdown_funkey b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/shutdown_funkey deleted file mode 100755 index 0d9c312..0000000 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/shutdown_funkey +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -# Notif fullscreen "Shutting down" -notif_set 0 "^^^^^^^^ SHUTTING DOWN...^^^^^^^^" - -# Kill Emulators -#kill_emulators >/dev/null 2>&1 - -# Kill Retrofe -#pkill retrofe - -# Sync filesystems (useful in case poweroff could not finish) -sync - -# Unmount Roms partition -#umount /mnt - -# Shutdown amp -start_audio_amp 0 >/dev/null 2>&1 - -# Poweroff -poweroff diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/snap b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/snapshot similarity index 94% rename from FunKey/board/funkey/rootfs-overlay/usr/local/sbin/snap rename to Recovery/board/funkey/rootfs-overlay/usr/local/sbin/snapshot index c727364..c45e079 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/snap +++ b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/snapshot @@ -24,7 +24,7 @@ mkdir -p "${SNAPSHOT_DIR}" last=$(cd ${SNAPSHOT_DIR}; ls IMG_*.${SNAPSHOT_EXT} 2> /dev/null | tail -1 | sed 's/^IMG_0*\([0-9]\+\)\.'${SNAPSHOT_EXT}'$/\1/') let last=${last}+1 snapshot_file=$(printf "IMG_%04d.${SNAPSHOT_EXT}" $last) -notif_set 2 " SCREEENSHOT ${snapshot_file}" +notif set 2 " SCREENSHOT ${snapshot_file}" fbgrab "${SNAPSHOT_DIR}/${snapshot_file}" >/dev/null 2>&1 & # Remove lock file diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/start_gpio_manager b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/start_gpio_manager deleted file mode 100755 index 635f18f..0000000 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/start_gpio_manager +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -LOCK_FILE=/var/lock/gpio_manager.lock - -if [ -f ${LOCK_FILE} ]; then - echo "${LOCK_FILE} already exists" - exit 1 -fi -touch ${LOCK_FILE} -funkey_gpio_management -rm "${LOCK_FILE}" -exit 0 diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/system_stats b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/system_stats index 4e6ad97..c4e3eb5 100755 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/system_stats +++ b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/system_stats @@ -1,7 +1,25 @@ #!/bin/sh +# Uncomment the following line to get debug info +#set -x + +SELF="$(basename ${0})" UPDATE_PERIOD=2 #seconds +usage() { + >2& echo "Usage: ${SELF} [toggle]" + exit 1 +} + +# Check number of arguments +if [ ${#} -eq 1 -a "${1}" = "toggle" ]; then + notif set 0 " Getting system stats..." + killall -s USR1 "${SELF}" + exit 0 +elif [ ${#} -ne 0 ]; then + usage +fi + notif_dirty=0 perform=0 @@ -10,7 +28,7 @@ function toggle_perform() { let perform=1-${perform} if [ ${perform} -eq 0 ]; then - notif_clear + notif clear notif_dirty=1 fi } @@ -27,13 +45,13 @@ while true; do # Notif if [ ${notif_dirty} -eq 1 ]; then - notif_clear + notif clear notif_dirty=0 else if [ "x${ip_addr}" != "x" ]; then - notif_set 0 " CPU:${cpu}%% RAM:${ram_mem}%% SWAP:${ram_swap}%%^IP:${ip_addr}" + notif set 0 " CPU:${cpu}%% RAM:${ram_mem}%% SWAP:${ram_swap}%%^IP:${ip_addr}" else - notif_set 0 " CPU:${cpu}%% RAM:${ram_mem}%% SWAP:${ram_swap}%%" + notif set 0 " CPU:${cpu}%% RAM:${ram_mem}%% SWAP:${ram_swap}%%" fi fi else diff --git a/Recovery/package/fkgpiod/fkgpiod.mk b/Recovery/package/fkgpiod/fkgpiod.mk index 370293e..cb6b85f 100644 --- a/Recovery/package/fkgpiod/fkgpiod.mk +++ b/Recovery/package/fkgpiod/fkgpiod.mk @@ -4,7 +4,7 @@ # ################################################################################ -FKGPIOD_VERSION = e74f688 +FKGPIOD_VERSION = 4df43ea FKGPIOD_SITE_METHOD = git FKGPIOD_SITE = https://github.com/FunKey-Project/fkgpiod.git FKGPIOD_SITE_LICENSE = GPL-2.1+ diff --git a/genimage-prod.cfg b/genimage-prod.cfg index 2fbe19a..b37fcd2 100644 --- a/genimage-prod.cfg +++ b/genimage-prod.cfg @@ -31,7 +31,7 @@ image sdcard-prod.img { partition-type = 0x83 bootable = "yes" image = "FunKey/output/images/rootfs.ext4" - size = 200M # This will be resized to 1G during first boot + size = 220M # This will be resized to 1G during first boot } # These partitions will be created during first boot diff --git a/genimage.cfg b/genimage.cfg index 2cac992..2160658 100644 --- a/genimage.cfg +++ b/genimage.cfg @@ -31,7 +31,7 @@ image sdcard.img { partition-type = 0x83 bootable = "yes" image = "FunKey/output/images/rootfs.ext4" - size = 200M # This will be resized to 1G during first boot + size = 220M # This will be resized to 1G during first boot } # These partitions will be created during first boot