Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kobo: Initial Elipsa 2E support #10719

Merged
merged 17 commits into from Aug 1, 2023
Merged

Kobo: Initial Elipsa 2E support #10719

merged 17 commits into from Aug 1, 2023

Conversation

NiLuJe
Copy link
Member

@NiLuJe NiLuJe commented Jul 21, 2023

Depends on koreader/koreader-base#1642, Fix #10408


This change is Reviewable

@NiLuJe
Copy link
Member Author

NiLuJe commented Jul 21, 2023

For potential testers, I've just updated the OCP thread with a KFMon build that should handle the basics (but may fail after an USBMS session, more on that later).

And since this requires a few built binaries, here's a delta package you can drop over a current nightly that should contain everything in this PR.
KOReader-Elipsa2E.tar.gz

@NiLuJe
Copy link
Member Author

NiLuJe commented Jul 21, 2023

Re: that KFMon issue, I would also very much like to take a look at a KFMon log, to see how the framebuffer evolves during the boot process.

So, ideally, install KFMon, try a simple USBMS session in nickel, eject, and send me the log (/usr/local/kfmon/kfmon.log).


Speaking of USBMS, the KOReader USBMS tool should also be working, but obviously I haven't tested that ;).

@ealex
Copy link

ealex commented Jul 25, 2023

hello
koreader still crashes, but with a different error:
crash.log

"USBMS session in nickel" = ? just a normal usb files transfer ?
this is the log:
kfmon.log

@NiLuJe
Copy link
Member Author

NiLuJe commented Jul 25, 2023

Looks like I fumbled the ffi decls, I'll take a look when I get back on Friday, thanks!

At least the KFMon stuff went better than I expected ;p.

@ealex
Copy link

ealex commented Jul 27, 2023

Looks like I fumbled the ffi decls, I'll take a look when I get back on Friday, thanks!

At least the KFMon stuff went better than I expected ;p.

i'll be away until 7 August

Copy link
Member Author

@NiLuJe NiLuJe left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 5 files at r1, 4 of 4 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @NiLuJe)

Copy link
Member Author

@NiLuJe NiLuJe left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @NiLuJe)

@NiLuJe NiLuJe marked this pull request as ready for review July 30, 2023 18:15
@Frenzie Frenzie added this to the 2023.08 milestone Jul 30, 2023
Comment on lines +59 to +70
# Black magic courtesy of wmt_dbg_func_ctrl @ (out of tree) modules/connectivity/wmt_mt66xx/common_main/linux/wmt_dbg.c
# Enable debug commands
echo "0xDB9DB9" >/proc/driver/wmt_dbg
# Disable the LPBK test
echo "7 9 0" >/proc/driver/wmt_dbg
# Nickel appears to sleep for ~1s
sleep 1
echo "0xDB9DB9" >/proc/driver/wmt_dbg
# Enable the LPBK test (this'll block for ~1.3s)
echo "7 9 1" >/proc/driver/wmt_dbg
# Finally, power on the chip
echo 1 >/dev/wmtWifi
Copy link
Member

Choose a reason for hiding this comment

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

Heh wtf

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, don't ask me what LPBK stands for ;D.

# Moar sleep!
usleep 250000

# Load WiFi modules
# NOTE: Used to be exported in WIFI_MODULE_PATH before FW 4.23
if ! grep -q "^${WIFI_MODULE}" "/proc/modules"; then
if ! grep -q "^${WIFI_MODULE} " "/proc/modules"; then
Copy link
Member

Choose a reason for hiding this comment

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

Was it at risk of actually matching something it shouldn't or just for sanity?

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently, no, but a common prefix used for a series of interdependent modules is not terribly far fetched (and it was nearly the case here, which prompted that change ^^).

@ealex
Copy link

ealex commented Aug 11, 2023

hello

[admin@condor root]# ./fbdepth -R UR
[FBInk] Detected a Kobo Elipsa 2E (389 => Condor @ Mark 11)
[FBInk] This device does not support HW inversion
[FBInk] Enabled MediaTek quirks
[FBInk] Clock tick frequency appears to be 100 Hz
[FBInk] Screen density set to 227 dpi
[FBInk] Variable fb info: 1404x1872, 32bpp @ rotation: 1 (Clockwise, 90°)
[FBInk] Fixed fb info: ID is "hwtcon", length of fb mem: 10543104 bytes & line length: 5616 bytes
[FBInk] Canonical rotation: 0 (Upright, 0°)
[FBInk] Fontsize set to 24x24 (IBM (Default) base glyph size: 8x8)
[FBInk] Line length: 58 cols, Page size: 78 rows
[FBDepth] Screen is 1404x1872 (1404x1877 addressable, fb says 1404x1872)
[FBDepth] Buffer is mapped for 10543104 bytes with a scanline stride of 5616 bytes
[FBDepth] Requested canonical rota 0 translates to 1 for this device
[FBDepth] Current rotation is already 1!

then:

[admin@condor root]# ./finger_trace 
[FBInk] Detected a Kobo Elipsa 2E (389 => Condor @ Mark 11)
[FBInk] This device does not support HW inversion
[FBInk] Enabled MediaTek quirks
[FBInk] Clock tick frequency appears to be 100 Hz
[FBInk] Screen density set to 227 dpi
[FBInk] Variable fb info: 1404x1872, 32bpp @ rotation: 1 (Clockwise, 90°)
[FBInk] Fixed fb info: ID is "hwtcon", length of fb mem: 10543104 bytes & line length: 5616 bytes
[FBInk] Canonical rotation: 0 (Upright, 0°)
[FBInk] Fontsize set to 24x24 (IBM (Default) base glyph size: 8x8)
[FBInk] Line length: 58 cols, Page size: 78 rows
[FBInk] Pen colors set to #000000 for the foreground and #000000 for the background
Initialized FBInk v1.25.0-95-g27816e1 for Kobo
Initialized libevdev for device `Elan Touchscreen`
Rotation: 1 -> 0


top left: draw appears on bottom left
1691729167.001603 [ FINGER ] [DOWN] @ (1812,   49) -> (  49, 1812) => (  49, 1812)
libevdev error in sanitize_event: BUG: Device "Elan Touchscreen" received a double tracking ID 211 in slot 0.
1691729167.013294 [ FINGER ] [DOWN] @ Similar coordinates
libevdev error in sanitize_event: BUG: Device "Elan Touchscreen" received a double tracking ID 211 in slot 0.
1691729167.026080 [ FINGER ] [DOWN] @ Similar coordinates
libevdev error in sanitize_event: BUG: Device "Elan Touchscreen" received a double tracking ID 211 in slot 0.
1691729167.038903 [ FINGER ] [DOWN] @ Similar coordinates
libevdev error in sanitize_event: BUG: Device "Elan Touchscreen" received a double tracking ID 211 in slot 0.
1691729167.051420 [ FINGER ] [DOWN] @ Similar coordinates
libevdev error in sanitize_event: BUG: Device "Elan Touchscreen" received a double tracking ID 211 in slot 0.
1691729167.064067 [ FINGER ] [DOWN] @ Similar coordinates
libevdev error in sanitize_event: BUG: Device "Elan Touchscreen" received a double tracking ID 211 in slot 0.
1691729167.076708 [ FINGER ] [DOWN] @ Similar coordinates
libevdev error in sanitize_event: BUG: Device "Elan Touchscreen" received a double tracking ID 211 in slot 0.
1691729167.089322 [ FINGER ] [DOWN] @ Similar coordinates
libevdev error in sanitize_event: BUG: Device "Elan Touchscreen" received a double tracking ID 211 in slot 0.
1691729167.102014 [ FINGER ] [DOWN] @ Similar coordinates
libevdev error in sanitize_event: BUG: Device "Elan Touchscreen" received a double tracking ID 211 in slot 0.
1691729167.114679 [ FINGER ] [DOWN] @ Similar coordinates
libevdev error in sanitize_event: BUG: Device "Elan Touchscreen" received a double tracking ID 211 in slot 0.
...

It looks like everything is mirrored around this line:
mirror_line

top left => bottom left
bottom left => top left
top right => bottom right
bottom right => top right

top and bottom are mirrored around the center of the screen, left and right is preserved

@NiLuJe
Copy link
Member Author

NiLuJe commented Aug 11, 2023

I love NTX kernels. >_<".

Does this one behave any better?

Kobo-DevCap-Test.tar.gz

@ealex
Copy link

ealex commented Aug 11, 2023

I love NTX kernels. >_<".

Does this one behave any better?

Kobo-DevCap-Test.tar.gz

this version works

@NiLuJe
Copy link
Member Author

NiLuJe commented Aug 11, 2023

Whee \o/

The following should make KOReader behave, then:

diff --git a/frontend/device/input.lua b/frontend/device/input.lua
index c316ca1eb..8f3b6a8ae 100644
--- a/frontend/device/input.lua
+++ b/frontend/device/input.lua
@@ -392,6 +392,20 @@ function Input:adjustABS_SwitchAxesAndMirrorX(ev, max_x)
     end
 end
 
+function Input:adjustABS_SwitchAxesAndMirrorY(ev, max_y)
+    if ev.code == C.ABS_X then
+        ev.code = C.ABS_Y
+        ev.value = max_y - ev.value
+    elseif ev.code == C.ABS_Y then
+        ev.code = C.ABS_X
+    elseif ev.code == C.ABS_MT_POSITION_X then
+        ev.code = C.ABS_MT_POSITION_Y
+        ev.value = max_y - ev.value
+    elseif ev.code == C.ABS_MT_POSITION_Y then
+        ev.code = C.ABS_MT_POSITION_X
+    end
+end
+
 function Input:adjustABS_Translate(ev, by)
     if ev.code == C.ABS_X or ev.code == C.ABS_MT_POSITION_X then
         ev.value = by.x + ev.value
diff --git a/frontend/device/kobo/device.lua b/frontend/device/kobo/device.lua
index d9d2a0676..8ea2c6e61 100644
--- a/frontend/device/kobo/device.lua
+++ b/frontend/device/kobo/device.lua
@@ -108,6 +108,8 @@ local Kobo = Generic:extend{
     touch_switch_xy = true,
     -- most Kobos have also mirrored X coordinates
     touch_mirrored_x = true,
+    -- but a few mirror on the Y axis instead
+    touch_mirrored_y = false,
     -- enforce portrait mode on Kobos
     --- @note: In practice, the check that is used for in ffi/framebuffer is no longer relevant,
     ---        since, in almost every case, we enforce a hardware Portrait rotation via fbdepth on startup by default ;).
@@ -516,6 +518,7 @@ local KoboCondor = Kobo:extend{
     display_dpi = 227,
     pressure_event = C.ABS_MT_PRESSURE,
     touch_mirrored_x = false,
+    touch_mirrored_y = true,
     hasNaturalLight = yes,
     frontlight_settings = {
         frontlight_white = "/sys/class/backlight/mxc_msp430.0/brightness",
@@ -975,7 +978,7 @@ end
 function Kobo:initEventAdjustHooks()
     -- Build a single composite hook, to avoid duplicated branches...
     local koboInputMangling
-    -- NOTE: touch_switch_xy is *always* true, but not touch_mirrored_x...
+    -- NOTE: touch_switch_xy is *always* true, but not touch_mirrored_x or touch_mirrored_y...
     if self.touch_switch_xy and self.touch_mirrored_x then
         local max_x = self.screen:getWidth() - 1
         koboInputMangling = function(this, ev)
@@ -985,7 +988,16 @@ function Kobo:initEventAdjustHooks()
                 gyroTranslation(ev)
             end
         end
-    elseif self.touch_switch_xy and not self.touch_mirrored_x then
+    elseif self.touch_switch_xy and self.touch_mirrored_y then
+        local max_y = self.screen:getHeight() - 1
+        koboInputMangling = function(this, ev)
+            if ev.type == C.EV_ABS then
+                this:adjustABS_SwitchAxesAndMirrorY(ev, max_y)
+            elseif ev.type == C.EV_MSC and ev.code == C.MSC_RAW then
+                gyroTranslation(ev)
+            end
+        end
+    elseif self.touch_switch_xy and not self.touch_mirrored_x and not self.touch_mirrored_y then
         koboInputMangling = function(this, ev)
             if ev.type == C.EV_ABS then
                 this:adjustABS_SwitchXY(ev)

@KnutSolvig
Copy link

If you grab a build from https://build.koreader.rocks/download/nightly/

How do I install a nightly version on my device after downloading it from this site? Following the usual installation manual from the Github page doesn't work, tells me that it finds no files...

@mergen3107
Copy link
Contributor

@Knut0730
Switch channel to developer.

@NiLuJe
Copy link
Member Author

NiLuJe commented Aug 15, 2023

@mergen3107: Not possible, the stable doesn't boot on those devices yet ;).

@Knut0730: You can't use the OCP scripts, you'll have to install manually.

@KnutSolvig
Copy link

@mergen3107: Not possible, the stable doesn't boot on those devices yet ;).

@Knut0730: You can't use the OCP scripts, you'll have to install manually.

Why does it have to be so complicated heh, but it looks to be like most things are working and that a stable release is right around the corner?

@Frenzie
Copy link
Member

Frenzie commented Aug 15, 2023

Of course without testing who knows how stable it'll be. ;-P

But anyway, you can just use the script to automate the install of 2023.6 and overwrite the files in /mnt/sd/.adds/koreader with those from the downloaded file?

@KnutSolvig
Copy link

@Frenzie where do I find these files? I have now installed the 2023.6 version but cannot find the directory you speak of.

@Frenzie
Copy link
Member

Frenzie commented Aug 16, 2023

When you plug in the device that probably just means .adds in what's mounted. On Windows you should just see that, on Linux it's typically Ctrl + H to show hidden folders and I think that's something like Command + Shift + . on Mac.

@KnutSolvig
Copy link

Aha! Now I see! So I was supposed to do that BEFORE installing the 2023.6 version, what do I then do if I made the mistake of installing the build completely without replacing the files with the nightly build? Can I simply run the install file once again and it will just overwrite it? I also don't understand how I would go fourth with uninstalling KOReader.

@Frenzie
Copy link
Member

Frenzie commented Aug 16, 2023

No, after, otherwise there wouldn't be any files to overwrite and it wouldn't be set up with NickelMenu and all that. ^_^

The difficult part is setting up the device so it can start the program, which is automated by the script. But most of "installing" just means "extract these files to .adds/koreader".

@KnutSolvig
Copy link

Okay, now it works! KOReader lauches on my Elipsa 2E! Looks good! Now - anything in particular you need testing @NiLuJe ?

@KnutSolvig
Copy link

I found that when turning on Night Mode all ink goes away and it becomes impossible to navigate. Please fix 😅

NiLuJe added a commit to NiLuJe/koreader that referenced this pull request Aug 25, 2023
Apparently, that doesn't quite work...
Re: koreader#10719
NiLuJe added a commit that referenced this pull request Aug 25, 2023
Apparently, that doesn't quite work...

Followup to #10719
@KnutSolvig
Copy link

Was #10841 to fix the Night Mode? After updating to the Aug 26 nightly build my WiFi connection works, but Night Mode still makes the screen blank.

@KnutSolvig
Copy link

I can also mention that when connecting a device (my Mac) to my Kobo I get the "Could not start the USBMS session! The device will shut down in 90 sec." message. This should probably also get fixed?

@NiLuJe
Copy link
Member Author

NiLuJe commented Aug 26, 2023

Was #10841 to fix the Night Mode? After updating to the Aug 26 nightly build my WiFi connection works, but Night Mode still makes the screen blank.

Try again after a full device restart for good measure.

If that doesn't help that would possibly point to wonky eclipse waveform modes, so I'll need a Nickel strace in Dark mode.

I can also mention that when connecting a device (my Mac) to my Kobo I get the "Could not start the USBMS session! The device will shut down in 90 sec." message.

That's slightly earlier than I was expecting it to fail, but, ditto, I need syslogs from an USBMS session to deal with that.
(Since it'll trip a shutdown, you'll need to do that live, over Wi-Fi).

@KnutSolvig
Copy link

KnutSolvig commented Aug 26, 2023

Try again after a full device restart for good measure.

I just did, a reboot did not help.

If that doesn't help that would possibly point to wonky eclipse waveform modes, so I'll need a Nickel strace in Dark mode.

Anything I can help with? If yes, how?

That's slightly earlier than I was expecting it to fail, but, ditto, I need syslogs from an USBMS session to deal with that.
(Since it'll trip a shutdown, you'll need to do that live, over Wi-Fi).

I cannot help much with getting the USBMS syslogs as I do not know how I get these. But I can attempt it if you give me some sort of instructions.

@NiLuJe
Copy link
Member Author

NiLuJe commented Aug 26, 2023

You'd need SSH access, pretty much like what was described in the original FR and/or the linked Clara 2E thread.

@KnutSolvig
Copy link

20230828_152350.jpg
Welp - hightling in Reflow isn't working as it should...

@NiLuJe
Copy link
Member Author

NiLuJe commented Aug 28, 2023

20230828_152350.jpg Welp - hightling in Reflow isn't working as it should...

That shouldn't be device-specific, so I've moved it to a dedicated issue (#10854).

Please attach a file that reproduces the crash and detailed reproduction steps in there.

@NiLuJe
Copy link
Member Author

NiLuJe commented Sep 5, 2023

Was #10841 to fix the Night Mode? After updating to the Aug 26 nightly build my WiFi connection works, but Night Mode still makes the screen blank.

A nickel strace was provided via the MR Discord, and AFAICT, this should work (in fact, that revert is irrelevant, the MDP invert works).

So new, idea: I'd really like an actual look at how the screen looks like, and I'd also like you to try to do this from inside a book, and, if you toggle NM via the menu, to blindly close the menu, and try to page around the book normally.

And the matching verbose debug logs, in case there's something wonky happening and we're not actually uring the right constants for some reason ;o).

katadelos added a commit to katadelos/koreader-base that referenced this pull request Apr 12, 2024
This commit "fixes" reported graphical problems caused by
switching to Night Mode on Elipsa 2E.

Mentioned here: koreader/koreader#10719 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

KOREader does not start on Kobo Elipsa 2E
6 participants