From 298528581d1a29032a1224600297316384d4e4f7 Mon Sep 17 00:00:00 2001 From: salmonik Date: Fri, 21 Aug 2026 19:13:52 +0200 Subject: image: single dd-able system.img replaces vvfat+data-disk pair MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mksystem.sh stages one FAT32 image: \bzImage + \initramfs.cpio.gz (rsbl paths), \EFI\BOOT\BOOTX64.EFI (kernel direct by default, --chain for rsboot), \etc\motd.txt, empty \bin\cli + \bin\gui, seed files at the root. --gpt wraps it in a partition table for real USB dd targets. Makefile: run/run-gui/debug attach only system.img on ide.0 (vvfat lines deleted); stamp-based 'system' target rebuilds only when the kernel is newer, so runtime writes survive reboots; system-fresh wipes; inspect lists via mtools. build-image.sh/mkdisk.sh removed. test-disk.sh boots system.img with a throwaway OVMF varstore — a stale NvVars makes the firmware skip the \EFI\BOOT fallback. sendkeys.py pacing 50ms->250ms/1.5s: keystroke loss under host load corrupted typed lines (guest-side PS/2 ring overflow). Gate: test-disk PASS (fsck clean, file survives poweroff). --- Makefile | 66 +++++++++++++++++++++++++++++----------------------------------- 1 file changed, 30 insertions(+), 36 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 4c57ac2..6f7f545 100644 --- a/Makefile +++ b/Makefile @@ -10,15 +10,14 @@ export INITRD=$(ESP_DIR)/initramfs.cpio.gz export BOOTLOADER=rsboot/rsboot.efi export OVMF=/usr/share/edk2/x64/OVMF.4m.fd export BOOT_EFI=$(ESP_DIR)/EFI/BOOT/BOOTX64.EFI -# Attach a raw disk image as the SATA drive (disk.img -> ide.0, ESP -> ide.1). -# Create one with: make disk (or: ./scripts/mkdisk.sh) -export DISK_IMG ?= /tmp/disk.img +# Attach the single dd-able system image as the SATA drive (ide.0). +# Create/re-create with: make system-fresh (or: ./scripts/mksystem.sh --force) +export SYSTEM_IMG ?= /tmp/system.img -.PHONY: all run run-gui clean image debug release fmt bootloader boot-image disk disk-fresh inspect test-disk test-mouse test-gfx test-fault test-msg # ---- Build --------------------------------------------------------------- -all: $(BZIMAGE) $(INITRD) +.PHONY: all run run-gui clean image debug release fmt bootloader boot-image system system-fresh inspect test-disk test-mouse test-gfx test-fault test-msg release: PROFILE=release release: export PROFILE=release @@ -43,13 +42,11 @@ $(INITRD): | $(ESP_DIR) # ---- QEMU runners -------------------------------------------------------- -run: all disk +run: all system qemu-system-x86_64 \ -bios $(OVMF) \ - -drive file=$(DISK_IMG),format=raw,if=none,id=disk \ + -drive file=$(SYSTEM_IMG),format=raw,if=none,id=disk \ -device ide-hd,drive=disk,bus=ide.0 \ - -drive file=fat:rw:$(ESP_DIR),format=raw,if=none,id=esp \ - -device ide-hd,drive=esp,bus=ide.1 \ -serial stdio \ -m 256M \ -machine q35 \ @@ -57,13 +54,11 @@ run: all disk -no-reboot \ -display none -run-gui: all disk +run-gui: all system qemu-system-x86_64 \ -bios $(OVMF) \ - -drive file=$(DISK_IMG),format=raw,if=none,id=disk \ + -drive file=$(SYSTEM_IMG),format=raw,if=none,id=disk \ -device ide-hd,drive=disk,bus=ide.0 \ - -drive file=fat:rw:$(ESP_DIR),format=raw,if=none,id=esp \ - -device ide-hd,drive=esp,bus=ide.1 \ -serial stdio \ -m 256M \ -machine q35 \ @@ -72,13 +67,11 @@ run-gui: all disk -vga std # GDB stub on :1234 -debug: all disk +debug: all system qemu-system-x86_64 \ -bios $(OVMF) \ - -drive file=$(DISK_IMG),format=raw,if=none,id=disk \ + -drive file=$(SYSTEM_IMG),format=raw,if=none,id=disk \ -device ide-hd,drive=disk,bus=ide.0 \ - -drive file=fat:rw:$(ESP_DIR),format=raw,if=none,id=esp \ - -device ide-hd,drive=esp,bus=ide.1 \ -serial stdio \ -m 256M \ -machine q35 \ @@ -90,23 +83,27 @@ debug: all disk # Boot from a raw disk image (delegates to boot-image.sh which builds the # full chain if the image doesn't exist yet) run-image: all - ./scripts/boot-image.sh rs-dos.img -# ---- Data disk ----------------------------------------------------------- +# ---- System image -------------------------------------------------------- -# Create the FAT32 data disk if it doesn't exist. Uses mkfs.fat -C (the -# flag that actually creates the file) and seeds it from seed/. -disk: - ./scripts/mkdisk.sh "$(DISK_IMG)" +# One dd-able FAT32 image: kernel + ESP + /etc + /bin + seed data. +# Stamp rule: rebuilt only when the kernel or this script changes — an +# up-to-date image is NEVER touched, so files written at runtime survive. +system: + @if [ ! -f "$(SYSTEM_IMG)" ] || [ "$$(stat -c %Y $(BZIMAGE) 2>/dev/null || echo 0)" -gt "$$(stat -c %Y $(SYSTEM_IMG) 2>/dev/null || echo 0)" ]; then \ + ./scripts/mksystem.sh --force "$(SYSTEM_IMG)"; \ + else \ + echo "system image up to date: $(SYSTEM_IMG)"; \ + fi -# Re-format the data disk from scratch (wipes it, then re-seeds). -disk-fresh: - ./scripts/mkdisk.sh --fresh "$(DISK_IMG)" +# Re-create the system image from scratch (wipes runtime data). +system-fresh: + ./scripts/mksystem.sh --force "$(SYSTEM_IMG)" -# List the data disk contents with mtools (requires mtools). +# List the system image contents with mtools (requires mtools). inspect: @command -v mdir >/dev/null 2>&1 || (echo "inspect needs mtools: sudo apt install mtools"; exit 1) - @mdir -i "$(DISK_IMG)" + @mdir -i "$(SYSTEM_IMG)" :: # Full automated round trip: build -> boot -> shell commands -> poweroff # -> fsck + mtools verification. @@ -152,7 +149,7 @@ fmt: clean: cargo clean - rm -rf $(ESP_DIR) rs-dos.img + rm -rf $(ESP_DIR) help: @echo "rs-dos — Make targets" @@ -163,16 +160,13 @@ help: @echo " make image build full chain disk image (bootloader + kernel)" @echo " make boot-image build + boot full chain via QEMU" @echo " make run QEMU serial console (direct boot, no bootloader)" - @echo " make run-gui QEMU with graphical window (GOP/PS2)" - @echo " make debug QEMU + GDB stub on :1234" - @echo " make disk create the data disk if missing (default /tmp/disk.img)" - @echo " make disk-fresh re-format the data disk (wipes it)" - @echo " make inspect list data disk contents (mtools)" + @echo " make system create the system image if stale/missing (/tmp/system.img)" + @echo " make system-fresh re-create the system image (wipes runtime data)" + @echo " make inspect list system image contents (mtools)" @echo " make test-disk automated disk round trip (build->boot->fsck)" @echo " make clean remove build artifacts" @echo " make fmt format Rust source" - @echo "" - @echo "Scripts:" + @echo " ./scripts/mksystem.sh build the dd-able system image" @echo " ./scripts/boot.sh quick direct boot (dev loop)" @echo " ./scripts/mkdisk.sh create/re-format the data disk" @echo " ./scripts/test-disk.sh automated disk round trip" -- cgit v1.2.3