Skip to content

Commit

Permalink
More Kobo scripts tweak...
Browse files Browse the repository at this point in the history
Trying to figure out why nickel deadlocks on restart...
  • Loading branch information
NiLuJe committed Apr 26, 2015
1 parent 1945873 commit c2bd85b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
6 changes: 2 additions & 4 deletions platform/kobo/koreader.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,10 @@ fi

if [ "${from_nickel}" == "true" ] ; then
# start kobo software because was running before koreader
./nickel.sh
./nickel.sh &
else
# if we were called from advboot then we must reboot to go to the menu
if [ -d "/mnt/onboard/.kobo/advboot" ] ; then
# FIXME: This is not precise enough, cf. #1503; but that alternate proposition is way too drastic, it doesn't account for people running neither KSM nor advboot
#if ! pkill -0 ksmhome.sh ; then
if ! pkill -0 ksmhome.sh ; then
reboot
fi
fi
29 changes: 23 additions & 6 deletions platform/kobo/nickel.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
#!/bin/sh
PATH=$PATH:/usr/sbin:/sbin
PATH="${PATH}:/usr/sbin:/sbin"

# Handle the rotation weirdness on some devices
cur_rotate="$(cat "/sys/class/graphics/fb0/rotate")"

# start fmon again:
( usleep 400000; /etc/init.d/on-animator.sh ) &

# environment needed by nickel, from /etc/init.d/rcS:

export INTERFACE="eth0"
export WIFI_MODULE="dhd"
export WIFI_MODULE_PATH="/drivers/ntx508/wifi/${WIFI_MODULE}.ko"
INTERFACE="wlan0"
WIFI_MODULE="ar6000"
if [ "${PLATFORM}" != "freescale" ] ; then
INTERFACE="eth0"
WIFI_MODULE="dhd"
fi
export INTERFACE
export WIFI_MODULE

export NICKEL_HOME="/mnt/onboard/.kobo"
export LD_LIBRARY_PATH="/usr/local/Kobo"

export WIFI_MODULE_PATH="/drivers/${PLATFORM}/wifi/${WIFI_MODULE}.ko"
export LANG="en_US.UTF-8"


# start nickel again (from tshering's start menu v0.4), this should
# cover all firmware versions from 2.6.1 to 3.4.1 (tested on a kobo
# mini with 3.4.1 firmware)
Expand All @@ -27,7 +40,7 @@ export LD_LIBRARY_PATH="/usr/local/Kobo"
if [ ! -e "/usr/local/Kobo/platforms/libkobo.so" ] ; then
export QWS_KEYBOARD="imx508kbd:/dev/input/event0"
export QT_PLUGIN_PATH="/usr/local/Kobo/plugins"
if [ -e "/usr/local/Kobo/plugins/gfxdrivers/libimxepd.so" ]; then
if [ -e "/usr/local/Kobo/plugins/gfxdrivers/libimxepd.so" ] ; then
export QWS_DISPLAY="imxepd"
else
export QWS_DISPLAY="Transformed:imx508:Rot90"
Expand All @@ -37,9 +50,13 @@ if [ ! -e "/usr/local/Kobo/platforms/libkobo.so" ] ; then
/usr/local/Kobo/nickel -qws -skipFontLoad
else
/usr/local/Kobo/hindenburg &
insmod "/drivers/ntx508/misc/lowmem.ko" &
lsmod | grep -q lowmem || insmod "/drivers/${PLATFORM}/misc/lowmem.ko" &
if grep -q "dhcpcd=true" "/mnt/onboard/.kobo/Kobo/Kobo eReader.conf" ; then
dhcpcd -d -t 10 &
fi
/usr/local/Kobo/nickel -platform kobo -skipFontLoad
fi

# Rotation weirdness, part II
echo "${cur_rotate}" > "/sys/class/graphics/fb0/rotate"
cat "/sys/class/graphics/fb0/rotate" > "/sys/class/graphics/fb0/rotate"

This comment has been minimized.

Copy link
@Frenzie

Frenzie Aug 23, 2015

Member

I'm not really sure what the point of this entire line is, but reading and writing a file in the same pipe is a race condition that should be avoided because it can lead to data loss (file being truncated), although I suppose since there's only one character that should be an issue. Anyway, that means it should be cat /sys/class/graphics/fb0/rotate > tmpfile && mv tmpfile /sys/class/graphics/fb0/rotate. Except obviously the entire thing seems redundant with the preceding line.

2 comments on commit c2bd85b

@NiLuJe
Copy link
Member Author

@NiLuJe NiLuJe commented on c2bd85b Aug 23, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, it's for the broken rotation crap on some devices (namely, the H2O). There's a bunch of threads about this on MR, frostschutz did extensive testing to try to handle it properly.

Since it's a sysfs virtual file, I'm not sure we really care about the potential raciness, though.
AFAICT, it does the job just fine as-is.

@Frenzie
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I found the rationale. Anyway, I noticed those lines through #1597 and wondered about the bad practice. :P

Please sign in to comment.