# ForgeOS ARM64 Architecture ## Goal ForgeOS ARM64 targets 64-bit ARM systems with UEFI firmware. The target image boots systemd as PID 1 and uses Nix as the core package manager. The current stack is: - Linux kernel source from kernel.org - systemd source from the upstream systemd project - BusyBox source from busybox.net for static rescue and early-boot tools - official Nix `aarch64-linux` binary tarball for the Nix store bootstrap - ForgeOS shell scripts, identity files, unit files, boot configuration, and image layout from this repository ## Boot Model 1. The disk image contains a GPT. 2. Partition 1 is a FAT32 EFI System Partition labeled `FORGE_EFI`. 3. `out/BOOTAA64.EFI` is a standalone GRUB UEFI fallback loader built for `arm64-efi`. 4. The ARM64 Linux `Image` with EFI stub support is copied to `EFI/BOOT/FORGEOS.EFI`. 5. UEFI firmware executes GRUB from `EFI/BOOT/BOOTAA64.EFI`. 6. GRUB starts the kernel with `root=PARTLABEL=root`. 7. The kernel mounts the ext4 root partition and executes `/sbin/init`. 8. `/sbin/init` points to `/usr/lib/systemd/systemd`. 9. systemd reaches `multi-user.target`, starts console login units, networkd, resolved, timesyncd, the Nix bootstrap service, and nix-daemon. The image also includes `rootfs.cpio.gz` on the EFI partition. The GRUB initramfs entries can use `/init` and `/sbin/forgeos-switch-root` to locate and switch to the real ext4 root partition before executing systemd. ## Root Filesystem Model The default rootfs is assembled in `staging/rootfs` from: - a systemd `DESTDIR` install tree - a statically linked ARM64 BusyBox utility tree - generated `/etc/passwd`, `/etc/shadow`, `/etc/group`, `/etc/fstab`, `/etc/systemd/*`, network, hostname, profile, and OS identity files - ForgeOS helper scripts from `overlay/rootfs` - the official Nix ARM64 store closure plus registration metadata - kernel modules from the ARM64 kernel build - the ARM64 kernel image copied to `/boot` systemd units are enabled by creating `.wants` symlinks in `/etc/systemd/system`, matching systemd's normal enablement model. Nix follows a multi-user daemon layout: `nixbld` users are generated in `/etc/passwd`, `/etc/nix/nix.conf` declares `build-users-group = nixbld`, and `nix-daemon.socket`/`nix-daemon.service` are enabled under systemd. ## QEMU Model The run scripts use `qemu-system-aarch64` with: - `-machine virt` - `-cpu max` - PL011 serial console through `ttyAMA0` - AAVMF firmware for UEFI image boots - virtio block, network, and rng devices ## Known Gaps - The Nix payload is currently the official binary tarball rather than a source-built Nix closure. - The systemd build depends on an ARM64 sysroot for target development and runtime libraries. - No desktop environment or graphical login. - No board-specific kernel profiles beyond QEMU `virt`. - No Microsoft/shim-signed Secure Boot chain. - No in-OS guided installer or update system. ## Suggested Next Steps 1. Add a first-class ARM64 sysroot recipe for systemd dependencies. 2. Add a source-built Nix recipe or a reproducible closure generator. 3. Add hardware profiles for common ARM64 laptops, SBCs, and servers. 4. Add CI that builds `make kernel`, `make rootfs`, and `make image` on an x86_64 host with the AArch64 cross toolchain.