Skip to content

x86_64: desktop dev profile for PCs/laptops (pygame UI, hybrid BIOS+EFI USB image) + CI - #143

Open
3rdIteration wants to merge 12 commits into
mainfrom
feat/x86_64-desktop-profile
Open

3rdIteration wants to merge 12 commits into
mainfrom
feat/x86_64-desktop-profile

Conversation

@3rdIteration

Copy link
Copy Markdown
Owner

What

Adds an x86_64 build target that runs SeedSigner's existing desktop mode on an old laptop / PC: minimal Linux + X11, full-screen app, keyboard/mouse input via the app's pygame fallback, USB webcam via OpenCV/UVC (same stack as La Frite), full smartcard set (pcscd + ccid over USB), and real hotplug storage — USB sticks / SD readers auto-mount at /mnt/microsd\ instead of the repo MicroSD folder.

Everything needed already existed on the app side (\desktop_display.py, pygame keyboard mapping in \�uttons.py, OpenCV camera fallback, /mnt/microsd\ preference in \microsd.py); this PR is all OS plumbing. No app changes required: the desktop code paths engage automatically because \periphery/\spidev/\picamera\ are absent and no \io_config.json\ device model matches → \RUNTIME_PROFILE=desktop.

Components

  • *\opt/external-packages/python-pygame-ce* — pygame-ce 2.5.8 sdist (sha256-pinned), built with buildroot's meson infrastructure against \sdl2/\sdl2_image/\sdl2_mixer/\sdl2_ttf/\ reetype; midi off (no portmidi in buildroot), -Dstripped=true.
  • *\opt/x86_64-smartcard-dev* profile:
    • defconfig: La Frite smartcard package set minus Pi/GPIO/Wi-Fi, plus X11 (\xserver, fbdev driver, libinput, xinit) + SDL2(X11) + pygame-ce + OpenCV/V4L; dev tooling (dropbear, git, curl...).
    • kernel 6.6.22 (same tarball URL as La Frite → shared CI download cache): PS/2 keyboard, laptop RTC, USB host/storage/UVC, FAT/exFAT+NLS, broad DRM (i915/radeon/nouveau/vmwgfx) + VESA/EFI fb + DRM fbdev-emulation for HDMI.
    • boot: hybrid BIOS+EFI USB image — grub i386-pc core in the MBR gap + \�ootx64.efi/\�ootia32.efi\ on one FAT32 ESP; ext4 root with fixed UUID (
      oot=UUID=...) since the stick enumerates as sd[a-c]a depending on the machine's own disks.
    • storage hotplug: eudev (X/libinput require udev) rule \sd[a-z][0-9]\ → /usr/lib/udev/seedsigner-storage.sh\ → the *shared /etc/mdev/mdev.sh* (mount
      oexec,nosuid,nodev, /tmp/mdev_fifo\ app notification, unmount on remove).
    • launch: init respawn of /usr/bin/seedsigner-console\ on tty1 replaces the getty (X needs the foreground VT): waits for storage, honours the dev MicroSD-source override, primes the clock only when the RTC is unset, then \startx\ → app (log at /tmp/seedsigner-app.log).
  • *\opt/rootfs-overlay/etc/mdev/mdev.sh* — tiny \SS_SKIP_DIY=1\ opt-out (architectures without a pinned diy-tools squashfs skip only the squashfs verification; Pi/La Frite behaviour byte-identical, default off).
  • *\opt/build.sh* — --x86_64\ flag; --all\ includes it in dev runs; loud error for --x86_64\ without --dev\ until a hardened profile exists.
  • *\�uild.yml* — \x86_64\ added to the board matrix + \workflow_dispatch\ choices; jq filter drops it from non-dev runs. Existing shared download cache / per-config ccache / artifact / release-upload steps work unchanged (x86 runs native amd64 on ubuntu-latest).

Scope / follow-ups

  • Dev profile only (SSH, verbose console) — hardened \x86_64-smartcard\ + burnable hybrid live ISO (buildroot supports it) are the planned release follow-ups, per the agreed plan.
  • First CI run is the real test: pygame-ce meson cross-build and the hybrid-image boot path are the two things to watch.

Verified locally: shell syntax of all new/changed scripts, LF line endings, exec bits (\git ls-files -s), jq matrix selection semantics for all board/variant combos.

3rdIteration and others added 12 commits October 8, 2026 23:08
Runs SeedSigner's existing desktop mode (pygame display + keyboard/mouse,
OpenCV/UVC webcam, CCID readers) on a minimal X11 stack bootable from a
hybrid BIOS+EFI USB stick, so an ordinary laptop can run the tool.

- opt/external-packages/python-pygame-ce: pygame-ce 2.5.8 as a meson
  package (sdl2/image/mixer/ttf + freetype from buildroot, midi off,
  stripped install; sha256-pinned sdist)
- opt/x86_64-smartcard-dev: defconfig (La Frite smartcard package set
  minus Pi/GPIO/Wi-Fi bits, plus X11 + SDL2 + pygame-ce), laptop kernel
  (PS/2 kbd, UVC, FAT/exFAT, broad DRM+fbdev), grub hybrid EFI+BIOS with
  fixed-UUID ext4 root, eudev sd* rules reusing the shared mdev.sh mount
  helper, and a tty1 console launcher (startx -> app) in place of
  S02seedsigner/getty
- opt/rootfs-overlay/etc/mdev/mdev.sh: SS_SKIP_DIY=1 opt-out for
  architectures with no pinned diy-tools squashfs (no-op for Pi/La Frite)
- opt/build.sh: --x86_64 flag (dev-only until a hardened profile lands)
- build.yml: x86_64 in the build matrix and dispatch choices; dropped
  from non-dev runs automatically
embit ships prebuilt libsecp256k1 .so files for every platform and the
RPi arch patch restricts packaging to 'libsecp256k1_linux_arm*'. On the
new x86_64 profile that installed the two ARM32 shared objects into the
rootfs and buildroot's per-package check_bin_arch failed the build
('architecture ... is ARM, should be ... X86-64'). Mirror the existing
aarch64 hook: drop the foreign .so files from the source tree and point
the packaging glob at the linux_x86_64 prebuilt. No-op for every other
profile.
x86_64 CI build reached python-pygame-ce and compiled 111/117 modules,
then died on pypm (the MIDI extension):

  gcc: ERROR: unsafe header/library path used in cross-compilation:
       '-I/usr/local/include'

Root cause in pygame-ce's meson.build: with -Dmidi=disabled the portmidi
pkg-config lookup misses, and the fallback cc.find_library('portmidi',
required: false) yields a not-found library, but the surrounding
declare_dependency() still reports found(), so src_c/meson.build's
'if portmidi_dep.found()' is true and pypm is built anyway. That fallback
is the only dependency whose include_directories come from pg_inc_dirs
(every other dep resolves via pkg-config, which is why only pypm broke),
and pg_inc_dirs is seeded from bases including /usr/local -- so pypm is
compiled with -I/usr/local/include, which buildroot's cross gcc rejects.

Gate the fallback on get_option('midi').enabled(): with midi disabled the
dependency stays the not-found pkg-config result, pypm is skipped, and no
/usr path leaks into the compile. No-op when midi is enabled and portmidi
is present. Verified the patch applies cleanly to the 2.5.8 sdist.
The x86_64 build now compiles end to end (pygame-ce, X11, grub EFI+BIOS,
kernel bzImage, rootfs.ext2 with the fixed UUID all produced) and failed
only on the very last step:

  post-image-seedsigner.sh: line 35: cd: buildroot: No such file or directory

buildroot runs post-image scripts with CWD set to its own source tree
(the same reason the script's own path arrives as
../x86_64-smartcard-dev/board/...), not the output dir, so there is no
'buildroot' subdirectory to cd into -- buildroot's own
board/pc/post-image-efi.sh calls support/scripts/genimage.sh with no cd
for exactly this reason.

Drop the cd and invoke genimage.sh from wherever it lives: prefer the CWD
source tree, else resolve it relative to the (now absolute) board dir via
../../buildroot. genimage.sh derives input/output paths from the exported
BINARIES_DIR and BUILD_DIR and takes the config via an absolute -c, so it
is CWD-independent.
The kernel's early_lookup_bdev() parses only PARTUUID=/PARTLABEL=/dev/.../
major:minor for root= -- a bare UUID= is an initramfs convention this image
has no initramfs to resolve, so the Dell test machine panicked with
'Disabling rootwait; root= is invalid'. Switch grub to
root=PARTUUID=ba5eba11-02 and pin the MBR disk signature via genimage's
disk-signature option (which otherwise defaults to 0), re-pinned and
verified idempotently in post-image.
The Dell test bench has no serial access and no network adaptor, so a
black-screen boot is undiagnosable. Create seedsigner-bootlog.txt on the
SEEDSIGNOS FAT partition and the launcher mounts it and appends dmesg,
the live kernel ring, its own output, the app's stdout/stderr, and a
copy of Xorg.0.log on session exit to seedsigner-boot.log on the stick.
Marker checked at every respawn; no reflash to toggle; logs are FAT-
flushed plus sync on session exit so a hard power-cut keeps them.

The hotplug wrapper now skips the SEEDSIGNOS-labelled partition so the
boot stick's ESP is never mounted as /mnt/microsd (which would collide
with the log mount and get ripped away by the REMOVE handler).

Entirely in the dev profile's board overlay -- a release profile cannot
inherit it -- and inert without the marker file.
The shared overlay's fstab has no tmpfs /tmp line. Harmless on profiles
whose rootfs is gone at power-off, but this profile boots a persistent,
rw-remounted ext4, so a /tmp/.X0-lock left by a power-cut X session
survived reboot and every startx died with "Server is already active for
display 0" -- blank screen and an init respawn loop.

Append tmpfs /tmp to the target fstab in post-build, and have the
launcher remove display-0 locks before startx (init runs exactly one
copy on tty1, so any lock there is stale). Also mount the boot-log FAT
partition with -t vfat to stop the kernel probing ext*/squashfs with
'flush'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
xserver_xorg-server installs /etc/init.d/S40xorg, which starts a bare
"Xorg :0 vt01" at boot. It took display :0 and vt1 before the tty1
launcher ran, so every startx failed ("Server is already active", then
"server already running" once the lock was cleared) and the screen sat
on S40xorg's empty black root window. Remove it in post-build.

The launcher's lock cleanup now only removes /tmp/.X0-lock when the PID
in it is dead, and logs the holder's cmdline otherwise, so a real
conflict is reported instead of masked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rootfs: switch from an ext4 partition to a gzipped cpio that grub loads
as an initrd, so the whole system runs from RAM like the Pi / La Frite
images and the USB stick can be pulled after boot. It is a separate
initrd rather than embedded in bzImage (several hundred MB of X11 /
OpenCV / numpy). The image is now a single FAT32 ESP sized at build time
from bzImage + rootfs.cpio.gz; root=PARTUUID is gone and post-image
verifies the one-partition layout instead.

Display: the app's desktop window is a fixed 960x480, which sat in the
middle of a 1366x768 panel. grub passes video=eDP-1:960x480 (and LVDS-1)
so the internal panel runs at that mode and the GPU scales it to full
screen; external monitors are untouched. Editable in grub.cfg on the FAT.

Cards: the udev wrapper now runs fsck.fat -a before mounting a FAT card
(clears the dirty bit every reboot leaves), lazily unmounts a dead mount
left by a yanked card so the next card is not stacked on it, and on
remove only unmounts /mnt/microsd if the removed device is the one
mounted there -- pulling the boot stick no longer takes the card away.
With the bootlog marker set, the launcher logs the card mount state,
settings.json and the fsck/mount logs just before starting the app.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drop the video=eDP-1/LVDS-1:960x480 override from grub.cfg: forcing a
CVT mode depends on GPU panel-fitter behaviour and is a compatibility
risk across machines. The display stays at its native resolution, and
xinitrc-seedsigner exports SEEDSIGNER_DESKTOP_FULLSCREEN=1 as the hook for
the app to scale its fixed 960x480 desktop layout to fill the screen
(app-side work in the seedsigner repo; ignored by refs without it).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace the udev RUN rules with /usr/sbin/seedsigner-automount, started
by S30seedsigner-automount after udev has populated /dev. It polls once a
second and keeps one removable card mounted at /mnt/microsd, where the
app looks for it:

* a card already inserted at boot is mounted on the first pass, with no
  dependence on udev coldplug ordering;
* cards with no partition table (whole-disk FAT) are found -- the old
  sd[a-z][0-9] rule never matched them;
* only USB- or SD-bus devices qualify, so a laptop's internal SATA/NVMe/
  eMMC partitions (its own EFI FAT included) are never mistaken for a
  card; the boot stick's SEEDSIGNOS ESP is skipped;
* FAT is fsck'd before mounting; a yanked card's dead mount is always
  lazily cleared; pulling another stick never unmounts the card.

Mounting, options and the FIFO notification stay in the shared mdev.sh.
It runs with a deadline and is killed if blocked on the FIFO, so a
reader-less FIFO (between app respawns, or one the app recreated) can
never stall the loop -- the app polls the mount state itself.

xinitrc now launches main.py --fullscreen (app scales its 960x480 desktop
layout to the native screen), passing the flag only when the checkout's
main.py defines it so an older APP_BRANCH still boots; the
SEEDSIGNER_DESKTOP_FULLSCREEN env var stays as the same switch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The dev boot log found its partition by the SEEDSIGNOS label alone, so an
internal disk partition carrying that label could be mounted. Restrict it
to a USB device, mount vfat only (no type-probing fallback), and add
noexec,nosuid,nodev. State the removable-only rule explicitly in
seedsigner-automount and the README: only USB- and SD-bus media is ever
mounted; internal SATA/NVMe/eMMC storage is rejected before probing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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