Skip to content

Freeze on Paperwhite 3: msync() on /dev/fb0 mmap blocks forever, screen never updates #2

Description

@iamgagan

Summary

On a Kindle Paperwhite 7th gen (PW3, 2015, firmware 5.x, mxcfb driver), the native renderer hangs forever inside renderToFramebuffer(), so the dashboard never appears on screen. Because the input thread holds an exclusive EVIOCGRAB on /dev/input/event1 the whole device appears frozen (no taps work anywhere), and users end up force-rebooting.

Root cause

msync(fb, screensize, MS_SYNC) on the /dev/fb0 mmap never returns on this kernel. The pixel copy completes, but execution never reaches the eips '' refresh call.

Diagnosed by instrumenting renderToFramebuffer() with a log line after each step. The log ends at copy_done, and the process stays alive (the touch thread keeps logging events after it):

render=fb-geometry xres=1072 yres=1448 xres_virtual=1088 yres_virtual=6144 xoffset=0 yoffset=0 bpp=8 line_length=1088 screensize=6684672
render=save-pgm /mnt/us/documents/kindle-dashboard-last-render.pgm width=1072 height=1448
render=fb-step copy_start
render=fb-step copy_done
input=action touch action=9 x=1002 y=59     <- input thread still alive, main thread stuck in msync

Fix

Remove the msync() calls (one in renderToFramebuffer(), two in flashTouchRectOnFramebuffer()). They are unnecessary: the mapping is MAP_SHARED on device memory, so stores land directly in framebuffer memory, and the display refresh is driven by eips/the EPDC, not by page-cache writeback. With the calls removed, the dashboard renders and refreshes correctly on the PW3.

   free(canvas.pixels);
-  msync(fb, screensize, MS_SYNC);
   munmap(fb, screensize);
   close(fd);
   system("eips '' >/dev/null 2>&1 || true");
   invertFramebufferArea(fb, &vinfo, &finfo, left, top, right, bottom, 0);
-  msync(fb, screensize, MS_SYNC);
   system("eips '' >/dev/null 2>&1 || true");
   usleep(120000);
   invertFramebufferArea(fb, &vinfo, &finfo, left, top, right, bottom, 0);
-  msync(fb, screensize, MS_SYNC);
   munmap(fb, screensize);

Happy to open a PR with this if useful.

Repro / environment

  • Kindle Paperwhite 7th gen (PW3), jailbroken, KUAL
  • Built with make -C kindle/native extension-zig
  • Any KUAL action that renders (Refresh Once / Start Dashboard) hangs; kindle-dashboard-last-render.pgm is written correctly, screen never updates

Side note

While debugging this, two small things that might be worth a look:

  1. scripts/bootstrap-insforge-kit.mjs aborts if a function slug already exists (SLUG_ALREADY_IN_USE) even though functions deploy normally updates in place. A failed/interrupted first run leaves the script unable to re-run.
  2. generated_at is built as `${today}T00:00:00+05:30` with a hardcoded IST offset, and the functions default DASHBOARD_TIMEZONE to Asia/Kolkata. For non-IST users this shows tomorrow's date on the dashboard until they discover the DASHBOARD_TIMEZONE secret. A more prominent mention in the install docs (or requiring it during setup) would help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions