From 18db50932507e5dc29cb3859af6eabe93caab5dc Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sat, 16 Jun 2018 17:05:20 -0400 Subject: [PATCH] Assorted bag of fixes (#4014) * Link to the WiKi, it's a bit more explainy ;). * More WiFi trickery for some HW revs * Fix Rev2 detection under KSM That's to future-proof it, the other end of this hasn't made it into current KSM build yet. * Resync nickel.sh w/ current rcS We don't have CPU, but we have PLATFORM, which is based on CPU, so, that'll do :). * Go back to using rmmod instead of modprobe -r Functionally identical on current FW, will potentially avoid getting outsmarted by modprobe if Kobo ever deigns shipping an actually usable Linux system one day... * Don't crash if screensavers directory doesn't exist c.f., https://www.mobileread.com/forums/showpost.php?p=3706979&postcount=2919 --- frontend/device/kobo/device.lua | 2 +- frontend/ui/screensaver.lua | 27 ++++++++++++++++----------- platform/kobo/disable-wifi.sh | 6 +++--- platform/kobo/enable-wifi.sh | 2 +- platform/kobo/fmon/README.txt | 2 +- platform/kobo/koreader.sh | 10 ++-------- platform/kobo/nickel.sh | 17 ++++++++++------- 7 files changed, 34 insertions(+), 32 deletions(-) diff --git a/frontend/device/kobo/device.lua b/frontend/device/kobo/device.lua index 77a178592..e861fb7e4 100644 --- a/frontend/device/kobo/device.lua +++ b/frontend/device/kobo/device.lua @@ -403,7 +403,7 @@ end local function getProductId() -- Try to get it from the env first (KSM only) - local product_id = os.getenv("PRODUCT_ID") + local product_id = os.getenv("MODEL_NUMBER") -- If that fails, devise it ourselves if not product_id then local version_file = io.open("/mnt/onboard/.kobo/version", "r") diff --git a/frontend/ui/screensaver.lua b/frontend/ui/screensaver.lua index 6d25d6c22..578f23851 100644 --- a/frontend/ui/screensaver.lua +++ b/frontend/ui/screensaver.lua @@ -24,19 +24,24 @@ local function getRandomImage(dir) local pics = {} local i = 0 math.randomseed(os.time()) - for entry in lfs.dir(dir) do - if lfs.attributes(dir .. entry, "mode") == "file" then - local extension = - string.lower(string.match(entry, ".+%.([^.]+)") or "") - if extension == "jpg" - or extension == "jpeg" - or extension == "png" then - i = i + 1 - pics[i] = entry + local ok, iter, dir_obj = pcall(lfs.dir, dir) + if ok then + for entry in iter, dir_obj do + if lfs.attributes(dir .. entry, "mode") == "file" then + local extension = + string.lower(string.match(entry, ".+%.([^.]+)") or "") + if extension == "jpg" + or extension == "jpeg" + or extension == "png" then + i = i + 1 + pics[i] = entry + end end end - end - if i == 0 then + if i == 0 then + return nil + end + else return nil end return dir .. pics[math.random(i)] diff --git a/platform/kobo/disable-wifi.sh b/platform/kobo/disable-wifi.sh index ffd584c44..96427e037 100755 --- a/platform/kobo/disable-wifi.sh +++ b/platform/kobo/disable-wifi.sh @@ -4,16 +4,16 @@ killall udhcpc default.script wpa_supplicant 2>/dev/null -[ "${WIFI_MODULE}" != "8189fs" ] && wlarm_le -i "${INTERFACE}" down +[ "${WIFI_MODULE}" != "8189fs" ] && [ "${WIFI_MODULE}" != "8189es" ] && wlarm_le -i "${INTERFACE}" down ifconfig "${INTERFACE}" down # Some sleep in between may avoid system getting hung # (we test if a module is actually loaded to avoid unneeded sleeps) if lsmod | grep -q "${WIFI_MODULE}"; then usleep 250000 - modprobe -r "${WIFI_MODULE}" + rmmod "${WIFI_MODULE}" fi if lsmod | grep -q sdio_wifi_pwr; then usleep 250000 - modprobe -r sdio_wifi_pwr + rmmod sdio_wifi_pwr fi diff --git a/platform/kobo/enable-wifi.sh b/platform/kobo/enable-wifi.sh index 837317e71..0c13b1039 100755 --- a/platform/kobo/enable-wifi.sh +++ b/platform/kobo/enable-wifi.sh @@ -11,7 +11,7 @@ lsmod | grep -q "${WIFI_MODULE}" || insmod "${WIFI_MODULE_PATH}" sleep 1 ifconfig "${INTERFACE}" up -[ "$WIFI_MODULE" != "8189fs" ] && wlarm_le -i "${INTERFACE}" up +[ "$WIFI_MODULE" != "8189fs" ] && [ "${WIFI_MODULE}" != "8189es" ] && wlarm_le -i "${INTERFACE}" up pidof wpa_supplicant >/dev/null \ || env -u LD_LIBRARY_PATH \ diff --git a/platform/kobo/fmon/README.txt b/platform/kobo/fmon/README.txt index e00a6acd5..affb0f44b 100644 --- a/platform/kobo/fmon/README.txt +++ b/platform/kobo/fmon/README.txt @@ -20,4 +20,4 @@ When you update KOReader manually, it should be sufficient to simply extract the NOTE: Using the legacy version of fmon (http://www.mobileread.com/forums/showthread.php?t=218283) is *STRONGLY* discouraged. NOTEĀ²: If you like the concept, and want to check out something a bit more flexible/complex, check out KFMon (https://github.com/NiLuJe/kfmon). - + In which case, look at the relevant WiKi page (https://github.com/koreader/koreader/wiki/Installation-on-Kobo-devices) for more details ;). diff --git a/platform/kobo/koreader.sh b/platform/kobo/koreader.sh index 736989448..c278f1bf6 100755 --- a/platform/kobo/koreader.sh +++ b/platform/kobo/koreader.sh @@ -71,7 +71,7 @@ if [ ! -n "${PRODUCT}" ]; then export PRODUCT fi -# PLATFORM is used in koreader for the path to the WiFi drivers +# PLATFORM is used in koreader for the path to the WiFi drivers (as well as when restarting nickel) if [ ! -n "${PLATFORM}" ]; then PLATFORM="freescale" if dd if="/dev/mmcblk0" bs=512 skip=1024 count=1 | grep -q "HW CONFIG"; then @@ -79,13 +79,7 @@ if [ ! -n "${PLATFORM}" ]; then PLATFORM="${CPU}-ntx" fi - if [ "${PLATFORM}" = "freescale" ]; then - if [ ! -s "/lib/firmware/imx/epdc_E60_V220.fw" ]; then - mkdir -p "/lib/firmware/imx" - dd if="/dev/mmcblk0" bs=512K skip=10 count=1 | zcat >"/lib/firmware/imx/epdc_E60_V220.fw" - sync - fi - elif [ ! -e "/etc/u-boot/${PLATFORM}/u-boot.mmc" ]; then + if [ "${PLATFORM}" != "freescale" ] && [ ! -e "/etc/u-boot/${PLATFORM}/u-boot.mmc" ]; then PLATFORM="ntx508" fi export PLATFORM diff --git a/platform/kobo/nickel.sh b/platform/kobo/nickel.sh index b105a4d2e..73696cc7e 100755 --- a/platform/kobo/nickel.sh +++ b/platform/kobo/nickel.sh @@ -3,8 +3,9 @@ PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/lib:" # Ensures fmon will restart. Note that we don't have to worry about reaping this, nickel kills on-animator.sh on start. ( - # NOTE: Recent FW versions appear to do away with the sleep on some platforms (I'm assuming the newer, faster, better ones!) - usleep 400000 + if [ "${PLATFORM}" = "freescale" ] || [ "${PLATFORM}" = "mx50-ntx" ] || [ "${PLATFORM}" = "mx6sl-ntx" ]; then + usleep 400000 + fi /etc/init.d/on-animator.sh ) & @@ -17,14 +18,16 @@ export LD_LIBRARY_PATH="/usr/local/Kobo" # NOTE: That check is possibly wrong on PLATFORM == freescale (because I don't know if the sdio_wifi_pwr module exists there), but we don't terribly care about that. if lsmod | grep -q sdio_wifi_pwr; then killall udhcpc default.script wpa_supplicant 2>/dev/null - [ "${WIFI_MODULE}" != "8189fs" ] && wlarm_le -i "${INTERFACE}" down + [ "${WIFI_MODULE}" != "8189fs" ] && [ "${WIFI_MODULE}" != "8189es" ] && wlarm_le -i "${INTERFACE}" down ifconfig "${INTERFACE}" down - # NOTE: Kobo's busybox build is weird. rmmod appears to be modprobe in disguise, defaulting to the -r flag. Use modprobe -r just to be safe... + # NOTE: Kobo's busybox build is weird. rmmod appears to be modprobe in disguise, defaulting to the -r flag... + # But since there's currently no modules.dep file being shipped, nor do they include the depmod applet, + # go with what the FW is doing, which is rmmod. # c.f., #2394? usleep 250000 - modprobe -r "${WIFI_MODULE}" + rmmod "${WIFI_MODULE}" usleep 250000 - modprobe -r sdio_wifi_pwr + rmmod sdio_wifi_pwr fi # Flush buffers to disk, who knows. @@ -32,7 +35,7 @@ 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 running FW 4.7.x +# Last tested on an H2O running FW 4.7.x - 4.8.x /usr/local/Kobo/hindenburg & LIBC_FATAL_STDERR_=1 /usr/local/Kobo/nickel -platform kobo -skipFontLoad &