From 83ed5adb66c4cd10254d5179243b5a4878031135 Mon Sep 17 00:00:00 2001 From: Matthias Larisch Date: Fri, 23 Aug 2024 20:30:46 +0200 Subject: [PATCH 1/6] accept /var/volatile/tmp as temp path --- platform/kobo/koreader.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/kobo/koreader.sh b/platform/kobo/koreader.sh index fd8a2e041528..8cbae42dc498 100755 --- a/platform/kobo/koreader.sh +++ b/platform/kobo/koreader.sh @@ -10,7 +10,7 @@ export KOREADER_DIR="${KOREADER_DIR:-${SCRIPT_DIR}}" cd "${KOREADER_DIR:-/dev/null}" || exit # To make USBMS behave, relocalize ourselves outside of onboard -if [ "${SCRIPT_DIR}" != "/tmp" ]; then +if [ "${SCRIPT_DIR}" != "/tmp" ] && [ "${SCRIPT_DIR}" != "/var/volatile/tmp" ]; then cp -pf "${0}" "/tmp/koreader.sh" chmod 777 "/tmp/koreader.sh" exec "/tmp/koreader.sh" "$@" From 896f3e7d3e3c5a81145adba3bfddfb7b5cc92463 Mon Sep 17 00:00:00 2001 From: Matthias Larisch Date: Sat, 24 Aug 2024 15:40:24 +0200 Subject: [PATCH 2/6] alternatively accept udev rule file to identify kobo device --- frontend/device.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/device.lua b/frontend/device.lua index 77f848a0ab91..ec42adc4245c 100644 --- a/frontend/device.lua +++ b/frontend/device.lua @@ -14,7 +14,7 @@ local function probeDevice() return require("device/kindle/device") end - local kobo_test_stat = lfs.attributes("/bin/kobo_config.sh") + local kobo_test_stat = lfs.attributes("/bin/kobo_config.sh") or lfs.attributes("/lib/udev/rules.d/99-kobo.rules") if kobo_test_stat then util.noSDL() return require("device/kobo/device") From 2a4589440413fc2400c9de987941f5fa4880b978 Mon Sep 17 00:00:00 2001 From: Matthias Larisch Date: Sat, 24 Aug 2024 17:05:24 +0200 Subject: [PATCH 3/6] use kobo hwdetect script for product id --- frontend/device/kobo/device.lua | 8 ++++++++ platform/kobo/koreader.sh | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/frontend/device/kobo/device.lua b/frontend/device/kobo/device.lua index a8baa0bd2614..42b767d439ec 100644 --- a/frontend/device/kobo/device.lua +++ b/frontend/device/kobo/device.lua @@ -1154,6 +1154,14 @@ local function getCodeName() std_out:close() end end + -- If that fails, run another script (since kobo v5 firmware) + if not codename then + local std_out = io.popen("/usr/bin/hwdetect.sh 2>/dev/null", "re") + if std_out then + codename = std_out:read("*line") + std_out:close() + end + end return codename end diff --git a/platform/kobo/koreader.sh b/platform/kobo/koreader.sh index 8cbae42dc498..1613707065a5 100755 --- a/platform/kobo/koreader.sh +++ b/platform/kobo/koreader.sh @@ -241,6 +241,11 @@ if [ -z "${PRODUCT}" ]; then export PRODUCT fi +if [ -z "${PRODUCT}" ]; then + PRODUCT="$(/usr/bin/hwdetect.sh 2>/dev/null)" + export PRODUCT +fi + # PLATFORM is used in koreader for the path to the Wi-Fi drivers (as well as when restarting nickel) if [ -z "${PLATFORM}" ]; then # shellcheck disable=SC2046 From c8c5fecdd7947bff2fb68d2349c70ef388e45e7e Mon Sep 17 00:00:00 2001 From: Matthias Larisch Date: Sat, 24 Aug 2024 19:33:13 +0200 Subject: [PATCH 4/6] Use nickel wifi config on v5 Credits to @NiLuJe --- platform/kobo/enable-wifi.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/platform/kobo/enable-wifi.sh b/platform/kobo/enable-wifi.sh index a7ecaa24b756..84750ada614a 100755 --- a/platform/kobo/enable-wifi.sh +++ b/platform/kobo/enable-wifi.sh @@ -211,5 +211,16 @@ esac ifconfig "${INTERFACE}" up [ "${WIFI_MODULE}" = "dhd" ] && wlarm_le -i "${INTERFACE}" up +# The wifi config moved in FW 5.x +if [ -f "/mnt/onboard/.kobo/wpa_supplicant.conf" ]; then + # FIXME: This *might* be problematic for USBMS, as we allow Wi-Fi during USBMS (and it happens to be super useful for debugging). + # Although wpa_supplicant doesn't appear to keep an fd open to it (good boy!). + WPA_SUPP_CONF="/mnt/onboard/.kobo/wpa_supplicant.conf" + # -s not supported in FW 5.x + WPA_SUPP_EXTRA_PARAMS="" +else + WPA_SUPP_CONF="/etc/wpa_supplicant/wpa_supplicant.conf" + WPA_SUPP_EXTRA_PARAMS="-s" +fi pkill -0 wpa_supplicant || - wpa_supplicant -D "${WPA_SUPPLICANT_DRIVER}" -s -i "${INTERFACE}" -c /etc/wpa_supplicant/wpa_supplicant.conf -C /var/run/wpa_supplicant -B + wpa_supplicant -D "${WPA_SUPPLICANT_DRIVER}" ${WPA_SUPP_EXTRA_PARAMS} -i "${INTERFACE}" -c "${WPA_SUPP_CONF}" -C /var/run/wpa_supplicant -B From 306487c6242eba2f9ca5fbc7f4c2464c29b8adad Mon Sep 17 00:00:00 2001 From: Matthias Larisch Date: Mon, 26 Aug 2024 21:52:07 +0200 Subject: [PATCH 5/6] Fix nickel script for v5 --- platform/kobo/nickel.sh | 60 ++++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/platform/kobo/nickel.sh b/platform/kobo/nickel.sh index 7acf81f3975e..b5b9af40fc3d 100755 --- a/platform/kobo/nickel.sh +++ b/platform/kobo/nickel.sh @@ -4,6 +4,7 @@ PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/lib:" # We don't need to duplicate any of the env setup from rcS, since we will only ever run this to *restart* nickel, and not bootstrap it. # Meaning we've already got most of the necessary env from nickel itself via both our launcher (fmon/KFMon) and our own startup script. # NOTE: LD_LIBRARY_PATH is the only late export from rcS we don't siphon in koreader.sh, for obvious reasons ;). +# NOTE: For v5, env will be restored properly before nickel start script. export LD_LIBRARY_PATH="/usr/local/Kobo" # Ditto, 4.28+ export QT_GSTREAMER_PLAYBIN_AUDIOSINK=alsasink @@ -17,13 +18,19 @@ unset LC_ALL STARDICT_DATA_DIR EXT_FONT_DIR unset KO_DONT_GRAB_INPUT unset FBINK_FORCE_ROTA -# Ensures fmon will restart. Note that we don't have to worry about reaping this, nickel kills on-animator.sh on start. -( - if [ "${PLATFORM}" = "freescale" ] || [ "${PLATFORM}" = "mx50-ntx" ] || [ "${PLATFORM}" = "mx6sl-ntx" ]; then - usleep 400000 - fi - /etc/init.d/on-animator.sh -) & +if [ -e "/etc/init.d/display-init.sh" ]; then + /etc/init.d/display-init.sh +fi + +if [ -e "/etc/init.d/on-animator.sh" ]; then + # Ensures fmon will restart. Note that we don't have to worry about reaping this, nickel kills on-animator.sh on start. + ( + if [ "${PLATFORM}" = "freescale" ] || [ "${PLATFORM}" = "mx50-ntx" ] || [ "${PLATFORM}" = "mx6sl-ntx" ]; then + usleep 400000 + fi + /etc/init.d/on-animator.sh + ) & +fi # Make sure we kill the Wi-Fi first, because nickel apparently doesn't like it if it's up... (cf. #1520) if grep -q "^${WIFI_MODULE} " "/proc/modules"; then @@ -118,14 +125,6 @@ fi unset KOREADER_DIR unset CPUFREQ_DVFS CPUFREQ_CONSERVATIVE -# Recreate Nickel's FIFO ourselves, like rcS does, because udev *will* write to it! -# Plus, we actually *do* want the stuff udev writes in there to be processed by Nickel, anyway. -rm -f "/tmp/nickel-hardware-status" -mkfifo "/tmp/nickel-hardware-status" - -# Flush buffers to disk, who knows. -sync - # Handle the sdcard: # We need to unmount it ourselves, or Nickel wigs out and shows an "unrecognized FS" popup until the next fake sd add event. # The following udev trigger should then ensure there's a single sd add event enqueued in the FIFO for it to process, @@ -134,11 +133,28 @@ if [ -e "/dev/mmcblk1p1" ]; then umount /mnt/sd fi -# And finally, simply restart nickel. -# We don't care about horribly legacy stuff, because if people switch between nickel and KOReader in the first place, I assume they're using a decently recent enough FW version. -# Last tested on an H2O & a Forma running FW 4.7.x - 4.25.x -/usr/local/Kobo/hindenburg & -LIBC_FATAL_STDERR_=1 /usr/local/Kobo/nickel -platform kobo -skipFontLoad & -[ "${PLATFORM}" != "freescale" ] && udevadm trigger & +if [ -e "/etc/init.d/z-nickel-hardware-status" ]; then + # on v5 use the existing startup scripts + # Clear LD_LIBRARY_PATH as it gets prepended by start script + export LD_LIBRARY_PATH= + /etc/init.d/z-nickel-hardware-status + sync + /etc/rc.local +else + # Recreate Nickel's FIFO ourselves, like rcS does, because udev *will* write to it! + # Plus, we actually *do* want the stuff udev writes in there to be processed by Nickel, anyway. + rm -f "/tmp/nickel-hardware-status" + mkfifo "/tmp/nickel-hardware-status" + + # Flush buffers to disk, who knows. + sync + + # And finally, simply restart nickel. + # We don't care about horribly legacy stuff, because if people switch between nickel and KOReader in the first place, I assume they're using a decently recent enough FW version. + # Last tested on an H2O & a Forma running FW 4.7.x - 4.25.x + /usr/local/Kobo/hindenburg & + LIBC_FATAL_STDERR_=1 /usr/local/Kobo/nickel -platform kobo -skipFontLoad & + [ "${PLATFORM}" != "freescale" ] && udevadm trigger & +fi -return 0 +exit 0 From 8e353af0a7a8f8d53ce98d0b5cd37f18fb39febd Mon Sep 17 00:00:00 2001 From: Matthias Larisch Date: Mon, 26 Aug 2024 22:35:14 +0200 Subject: [PATCH 6/6] Cleanup more nickel processes --- platform/kobo/koreader.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/kobo/koreader.sh b/platform/kobo/koreader.sh index 1613707065a5..65d47364372c 100755 --- a/platform/kobo/koreader.sh +++ b/platform/kobo/koreader.sh @@ -209,7 +209,7 @@ if [ "${VIA_NICKEL}" = "true" ]; then # as we want to be able to use our own per-if processes w/ custom args later on. # A SIGTERM does not break anything, it'll just prevent automatic lease renewal until the time # KOReader actually sets the if up itself (i.e., it'll do)... - killall -q -TERM nickel hindenburg sickel fickel strickel fontickel adobehost foxitpdf iink dhcpcd-dbus dhcpcd bluealsa bluetoothd fmon nanoclock.lua + killall -q -TERM nickel hindenburg sickel fickel strickel fontickel adobehost foxitpdf iink dhcpcd-dbus dhcpcd bluealsa bluetoothd fmon nanoclock.lua memorylogger QtWebEngineProcess # Wait for Nickel to die... (oh, procps with killall -w, how I miss you...) kill_timeout=0 @@ -223,6 +223,7 @@ if [ "${VIA_NICKEL}" = "true" ]; then done # Remove Nickel's FIFO to avoid udev & udhcpc scripts hanging on open() on it... rm -f /tmp/nickel-hardware-status + rm -f /var/volatile/tmp/nickel-hardware-status # We don't need to grab input devices (unless MiniClock is running, in which case that neatly inhibits it while we run). if [ ! -d "/tmp/MiniClock" ]; then