Skip to content

Fix Windows setup/build issues and two framebuffer msync hangs#1

Open
tfthushaar wants to merge 2 commits into
thecodedose:mainfrom
tfthushaar:fix/windows-build-and-msync-hangs
Open

Fix Windows setup/build issues and two framebuffer msync hangs#1
tfthushaar wants to merge 2 commits into
thecodedose:mainfrom
tfthushaar:fix/windows-build-and-msync-hangs

Conversation

@tfthushaar

Copy link
Copy Markdown

Summary

Fixes found while getting this project running end-to-end on Windows, for a Kindle Paperwhite 3 (armel/soft-float).

Setup scripts

scripts/bootstrap-insforge-kit.mjs, scripts/configure-telegram.mjs

Shelling out to npx @insforge/cli fails on Windows in three stacked ways:

  • ENOENT without a shell
  • EINVAL with one, due to Node's CVE-2024-27980 hardening on .cmd files
  • Silent argument-mangling by cmd.exe once shell: true is added (breaks any arg with spaces/newlines)

Fix: invoke the CLI's JS entry point directly via node instead — no shell involved. Also switches migration application to db query instead of db import, which crashes natively on Windows.

Native build

kindle/native/src/kindle_dashboard.cpp

  • Added a portable M_PI fallback (POSIX/glibc extension, undefined with Zig's bundled libc++ when cross-compiling)
  • Removed two duplicated msync(fb, screensize, MS_SYNC) calls on the mmap'd /dev/fb0 framebuffer, which hang indefinitely on this device's fbdev driver
    • One blocked every render
    • A second, in the tap visual-feedback code path, blocked every interactive touch after the first
    • Found both via targeted logging, not static reading
  • Fixed dark mode: --invert-images only flipped specific bitmap assets, never the actual canvas, so it had no visible effect. Added a full-canvas inversion pass.

.gitattributes (new)

Pins *.sh/*.sql to eol=lf. With none present, a Windows contributor with the common core.autocrlf=true git setting silently gets CRLF checked out into Kindle-side shell scripts, which then fail completely silently on-device.

Details

Full root-cause writeups, debugging approach, and reasoning for each fix are in WINDOWS_FIXES.md.

Windows-specific fixes for setup scripts and the native ARM build,
plus two real bugs in the native dashboard found via on-device testing
on a Kindle Paperwhite 3 (armel/soft-float):

- scripts/bootstrap-insforge-kit.mjs, scripts/configure-telegram.mjs:
  invoke the InsForge CLI's JS entry point directly via node instead of
  shelling out to `npx`, which fails on Windows in multiple ways
  (ENOENT without a shell, EINVAL with one due to Node's CVE-2024-27980
  hardening on .cmd files, and silent argument-mangling by cmd.exe once
  shell:true is added). Also switches migration application back to
  `db query <content>` instead of `db import <path>`, which crashes
  natively inside the CLI on Windows for at least one migration file.

- kindle/native/src/kindle_dashboard.cpp:
  - Add a portable M_PI fallback (POSIX/glibc extension, not standard
    C++; undefined when cross-compiling with Zig's bundled libc++).
  - Remove two independent `msync(fb, screensize, MS_SYNC)` calls on
    the mmap'd /dev/fb0 framebuffer. This Kindle's fbdev driver hangs
    indefinitely on msync for a device-backed mapping (msync is for
    syncing file-backed mmaps to disk; it's both unnecessary and
    apparently unimplemented correctly here). One instance completely
    blocked every render; a second, duplicated instance in the
    tap-visual-feedback code path blocked every interactive touch
    after the first. Found both via targeted fprintf/fflush bisection
    logging rather than static reading.
  - Add invertCanvasIfDark(): --invert-images previously only flipped
    specific loaded bitmap assets, never the dashboard canvas itself,
    so dark mode had no visible effect. Now inverts the full canvas.

- .gitattributes (new): pin *.sh and *.sql to eol=lf. The repo's
  stored blobs are already LF, but with no .gitattributes, a Windows
  contributor with the common core.autocrlf=true git setting gets
  CRLF silently reintroduced on checkout -- which breaks Kindle-side
  /bin/sh scripts completely silently (no error, no log output at
  all) and is very easy to misdiagnose as a FAT/exFAT permissions
  issue instead.

- WINDOWS_FIXES.md (new): full writeup of all of the above with root
  causes, debugging approach, and fixes, for repo maintainer review.
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.

1 participant