-
Notifications
You must be signed in to change notification settings - Fork 23
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
implement LD_PRELOAD shim for rM1 apps #12
Comments
I'd recommend doing this by keeping a static array of bools (the size of the maximum FD) to record if each one is one which needs to be shimmed. Next, intercept open/close to compare the path then update this array and redirect the file if needed. Then, intercept ioctl and any other functions to transform the data (I'd recommend keeping statically allocated thread-local memory to avoid needing to keep reallocating memory for every call) and call msgsend instead. You could also intercept mmap for debugging. |
thanks for the recommendation! i have a prototype semi-working, just shimming out each piece as necessary.
can share code when it's working better. EDIT: HOLY &^#%, the shim works :-D |
https://imgur.com/a/c3Wr8dS <--- image of koreader the shim in ipc branch in for koreader: it pretty much crashes immediately, but it can draw that initial screen and sometimes half a modal dialog. i can draw to screen with qt apps did not work immediately with the shim, as they complained about an unrecognized device id (mxsfb-lcdif). this needs further investigation. big thanks to @LinusCDE for spending time this morning explaining libremarkable stuff |
🎉 And yes, LD_PRELOAD can be quite fun to work with!
Have a look at pgaskin/kobo-mods/kobo-dotfile-hack-ng.
Out of curiosity, if you've tested it, how's the current performance overhead without it?
Do you have a @NiLuJe might also have some ideas on why this happens.
I'm not familiar with this, but remapping the device IDs might work. I'm not sure what side-effects this will have, though.
That can be shimmed too, but I think it'd be better to properly implement it to avoid scope creep for the shim, since the shim is mainly intended to hide the differences in communication with the FB. Edit: One other thing: I'd recommend avoiding c++ stdlib features (if you must, prefer the Qt implementations of the same thing) in the shim if possible, since that can cause issues in some cases. Edit 2: I'd also recommend dlsyming the next symbols during library initialization to improve performance, reduce the possibility of issues in multi-threaded applications, and prevent some edge cases involving conflicting libraries. Edit 3: For debugging (if you'll be including that in the final version), consider writing to a ring buffer in shared memory instead of to stderr for better performance. Edit 4: Another random note about integration with other libraries/apps: note that it'll be possible to link this shim directly into an application, either during or after compilation. |
I'm not at the perf improvement stage, please don't review code as though its in final form - it's just to show progress If you want to run a test on kobo or rM to see overhead, you can write high res timers (+ the full struct of mxcfb_update) through IPC and compare when they were sent and received. |
Random "add it to the pile for later" comment: is there an easy way for the "host" application to detect the shim? (Case in point: I currently abort in FBInk on the rM2 ^^). |
Oh, and, yeah, as far as KOReader is concerned, if you can get me a strace (and/or verbose debug logs from KOReader itself, which maybe might be flushed before stuff blows up if we're lucky ^^), I can certainly try to help ;). Since it crashes early, you'll want to tweak the settings manually, to set the |
But, yeah, might be as easy for starters as simply handling (You can pass |
I don't think anyone actually makes use of anything else, but if you want to go the (really) extra mile, the only other ioctls one might really have cause to use are |
EDIT: koreader video I found what was was causing crashes with KOReader (or at least one issue) and now KOReader works as expected and I can interact with it. Plato also works as expected (libremarkable app with some crazy drawing, supposedly). The touch input doesn't really work for either app (because the input is no longer inverted on x axis?), but the stylus does.
there will be
thanks, i'll look into these (should give us a nice todo list)
this would be a very nice tool to have where we can smack a binary from being rM1 compatible into being rM2 compatible |
on qt apps complaining about lcdif, i think it is in fixscreen struct, fbioget |
the shim works with libremarkable, koreader, qsgepaper and rmkit now. @pgaskin ok, now can code review (what's in master) and make PRs if you want (thank you!). list of stuff so far:
i'll take a look tomorrow at perf and report some numbers. still no fast drawing yet, needs investigation. |
For perf, I put a millisecond counter into the struct being passed over IPC. It takes 0ms (i didn't bother measuring nano seconds) to pass the struct over IPC. depending on the update being used it can take 1 - 3ms (for small rects like pencil drawing) to 100+ms (for full screen (1404x1872) high quality updates) The perf can be tested by enabling the |
Kernel is out: https://github.com/reMarkable/linux/tree/zero-sugar |
yes,
https://github.com/reMarkable/linux/blob/zero-sugar/drivers/video/fbdev/mxsfb.c
data ist just shuffled out to the display (if i can interpret this right)
…On Sun, 8 Nov 2020 at 17:01 NiLuJe ***@***.***> wrote:
Kernel is out: https://github.com/reMarkable/linux/tree/zero-sugar
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#12 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIYZFLWFSN7CXAPLQUDNB5DSO26FBANCNFSM4TKUUYEA>
.
|
Regarding the bool array, the idea was to allow an application to open/close multiple instances instead of using a shared FD. Otherwise, it wouldn't be completely transparent since it would act slightly differently than native applications. And, since you currently open the shared FD when the lib is loaded and LD_PRELOAD is propagated to child processes, this may cause unnecessary instances from children. |
the shim has been implemented and we are considering this the "official" way of interacting with the rm2fb server, but using msgq + shm alone is also fine. |
as per #11 (comment), we can try making a shim that intercepts system calls for apps built for the rM1
if done right, this would mean the other integration (rmkit, libremarkable, koreader, qt's eprenderer) work is not necessary.
The text was updated successfully, but these errors were encountered: