# Installation guide This guide covers building Geminux images and flashing a Planet Computers Gemini PDA (Wi-Fi + 4G, MT6797X) directly from Linux without MediaTek's proprietary FlashTool GUI. ## Prerequisites on the Linux host 1. Docker (`docker`) installed and running for `aarch64` cross-compilation and Alpine rootfs assembly. 2. Python 3 (`python3`), `libusb-1.0`, and `udev` / `sudo` permissions for USB MediaTek BROM/DA access. 3. Optional: `img2simg` and `simg2img` (`android-tools` or `ext4` sparse utilities) if you want Android sparse rootfs conversion. 4. A Planet Computers Gemini PDA (x27 Wi-Fi+4G) and a USB-C data cable connected directly to a host USB port (avoid unpowered hubs). On Linux hosts running `ModemManager`, [flash-mtk.sh](file:///home/lux/proj/geminux/flash-mtk.sh) automatically pauses `ModemManager` during flashing and restarts it on exit so `/dev/ttyACM*` is not claimed away from the MediaTek Preloader/BROM handshake. ## Step 1: Build the Geminux images From the repository root: ```sh ./rebuild-image.sh ./scripts/check-rebuild.sh ``` This generates: - `images/boot-geminux.img` (`<= 16 MiB` LK boot slot image containing `Image.gz`, `mt6797-gemini-pda-geminux.dtb`, and initramfs) - `images/recovery-geminux.img` (initramfs recovery image with USB NCM network shell) - `images/geminux-rootfs.img` (ext4 root filesystem labeled `geminux-root`) - `images/geminux-rootfs.simg` (Android sparse copy of `geminux-rootfs.img` when `img2simg` is installed) - `images/SHA256SUMS` ## Step 2: Backup factory partitions and extract MediaTek firmware Never wipe or overwrite MediaTek factory calibration, baseband, or bootloader partitions (`proinfo`, `nvram`, `nvdata`, `protect1`, `protect2`, `seccfg`, `lk`, `tee1`, `md1img`, `scp1`, `preloader`). Power off the Gemini PDA completely and keep it unplugged. Run the backup command, then plug the USB-C cable into the **left** USB-C port (closest to the Esc side) while the device is powered off to enter MediaTek BROM/Preloader mode: ```sh ./flash-mtk.sh --only-backup ``` Backups are saved under `backup//` together with `pgpt.bin` and `sgpt.bin`. Next, extract the device-owned proprietary MediaTek firmware blobs (`MT6797` Wi-Fi, Bluetooth, SPM, and MD1 radio images, which are never redistributed in git) either directly from the Gemini's existing Android `system` partition or from a local `system.img`: ```sh # From a connected Gemini in BROM mode: ./flash-mtk.sh --extract-firmware # Or from a local stock Android system image: ./flash-mtk.sh --extract-firmware --system-img /path/to/system.img ``` Extracted blobs are placed in `firmware-cache/mt6797/` and automatically injected into `/lib/firmware/mediatek/mt6797/` the next time `./rebuild-image.sh` runs. Re-run `./rebuild-image.sh` after extracting firmware so `geminux-rootfs.img` includes the blobs: ```sh ./rebuild-image.sh ``` ## Step 3: Flash full eMMC with Geminux Geminux claims the entire user-writable eMMC past the protected MediaTek region (`LBA 0x70000`, byte offset `0x0E000000`, `SYS0..SYS27`), removing Android `system`, `cache`, and `userdata` in favor of `boot`, `recovery`, `boot2`, and a single full-disk `linux` ext4 partition: ```sh # Interactive: prompts for desktop username, desktop password, root password, # and optional LUKS2 full-disk encryption before waiting for USB BROM/Preloader: ./flash-mtk.sh --flash-full # Non-interactive with explicit credentials and interactive LUKS2 passphrase: ./flash-mtk.sh --flash-full --username alice --ask-user-password --ask-root-password --encrypt # Non-interactive using image defaults (unencrypted): ./flash-mtk.sh --flash-full --use-default-credentials ``` What `--flash-full` does automatically (implemented in [flash-mtk.py](file:///home/lux/proj/geminux/flash-mtk.py), [scripts/geminux_accounts.py](file:///home/lux/proj/geminux/scripts/geminux_accounts.py), [scripts/geminux_luks.py](file:///home/lux/proj/geminux/scripts/geminux_luks.py), and [scripts/geminux_gpt.py](file:///home/lux/proj/geminux/scripts/geminux_gpt.py)): 1. Resolves desktop `username`, desktop `password`, `root` `password`, and optional `--encrypt` LUKS2 passphrase before waiting for USB BROM/Preloader. Flags available: `--username`, `--user-password`, `--ask-user-password`, `--root-password`, `--ask-root-password`, `--use-default-credentials`, `--encrypt`, `--luks-password`, and `--ask-luks-password`. The LUKS2 disk passphrase is independent of the desktop and `root` login passwords (though you may enter the same passphrase if desired). 2. Takes an initial backup into `backup//` (or pass `--skip-backup --backup-dir backup/` on subsequent reflashes to reuse an existing backup). 3. Verifies the protected factory partition layout before `0x0E000000` (`pass --force-gpt` only if intentionally converting a non-standard partition table). 4. Writes updated Primary GPT (`LBA 0..33`) and Backup GPT with a mandatory readback verification check. 5. Stages a temporary copy of `geminux-rootfs.img` (leaving `images/geminux-rootfs.img` unmodified), provisions `/etc/passwd`, `/etc/group`, `/etc/shadow`, and `/home/` via `debugfs`/`e2fsck`, optionally wraps it inside a LUKS2 container (`aes-xts-plain64`, Argon2id), writes `boot-geminux.img` to `boot` and `boot2`, `recovery-geminux.img` to `recovery` (with readback verification), and the staged rootfs to `linux`, then sends the DA reboot handshake (`--reboot` default, `--poweroff` to stay powered off, or `--no-reboot` to remain in DA mode). Additional flashing and offline image utilities: ```sh # Update only boot, boot2, and recovery without touching GPT or linux: ./flash-mtk.sh --flash-kernel-only # Update only the linux rootfs partition (with optional credentials and --encrypt): ./flash-mtk.sh --flash-rootfs-only --username alice --ask-user-password --encrypt # Create an offline customized (and optionally LUKS2-encrypted) ext4 rootfs image: ./flash-mtk.sh --customize-rootfs /tmp/custom-rootfs.img --username alice --ask-user-password --ask-root-password --encrypt # Restore a previous backup: ./flash-mtk.sh --restore-backup backup/ ``` ## First boot and recovery notes - Disconnecting/reflashing notes: eSIM profiles provisioned onto the hardware ST33 eUICC survive full eMMC rootfs reflashes (whereas flashing `linux` replaces `/` and `/home`). - Disconnect the USB-C cable and hold the **Esc** (power) button until the unit boots. - If flashed with `--encrypt`, the initramfs loads the standalone binary Gemini US keyboard map (`/etc/gemini-us.kmap`) on `tty1` and prompts for the LUKS2 passphrase before mounting `PARTLABEL=linux` via `cryptsetup open --allow-discards` as `/dev/mapper/geminux_root` (off-mode battery charging still runs before the unlock prompt). Because LUKS2 data segment 0 uses dynamic whole-device length, unlocking immediately maps the full `linux` partition. - On first boot, the initramfs runs non-interactive `e2fsck -p` and `resize2fs -f` (`