From 4ea992c71dd0cdcffe0f74216e748256bd700a31 Mon Sep 17 00:00:00 2001 From: salmonik Date: Sat, 1 Aug 2026 01:56:12 +0200 Subject: scripts: automate the data-disk workflow (mkdisk / sendkeys / test-disk) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - scripts/mkdisk.sh: create the FAT32 disk with mkfs.fat -C (the flag that actually creates the file — plain mkfs.fat fails on a missing path), accept M/G/K sizes, seed seed/ files via mtools; --fresh re-formats, --no-seed skips seeding - scripts/sendkeys.py: type lines into the guest via the QEMU monitor (US layout). Punctuation must use QEMU's named keys (minus, slash, dot, ...) — bare '-', '.', '/' are not valid sendkey names, and '-' is the modifier separator, so they were silently dropped before - scripts/test-disk.sh: full automated round trip — build, deploy, ensure image, boot headless QEMU, drive the shell (ls /disk, mkdir, echo >, cat, poweroff), then verify with fsck.fat (must be clean) and mtype (file content must have survived poweroff) - Makefile: make disk / disk-fresh / inspect / test-disk; run, run-gui and debug now auto-create a missing DISK_IMG; fix the stale comment (mkfs.fat without -C) - scripts/boot.sh: auto-create a missing DISK_IMG via mkdisk.sh - seed/: motd.txt + lines.txt seeded onto fresh images - Verified end to end: ./scripts/test-disk.sh --fresh passes --- Makefile | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 7701d9d..01e265a 100644 --- a/Makefile +++ b/Makefile @@ -11,10 +11,10 @@ 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: mkfs.fat -F 32 -n RSDOS disk.img && mcopy -i disk.img files :: +# Create one with: make disk (or: ./scripts/mkdisk.sh) export DISK_IMG ?= /tmp/disk.img -.PHONY: all run run-gui clean image debug release fmt bootloader boot-image +.PHONY: all run run-gui clean image debug release fmt bootloader boot-image disk disk-fresh inspect test-disk # ---- Build --------------------------------------------------------------- @@ -43,7 +43,7 @@ $(INITRD): | $(ESP_DIR) # ---- QEMU runners -------------------------------------------------------- -run: all +run: all disk qemu-system-x86_64 \ -bios $(OVMF) \ -drive file=$(DISK_IMG),format=raw,if=none,id=disk \ @@ -57,7 +57,7 @@ run: all -no-reboot \ -display none -run-gui: all +run-gui: all disk qemu-system-x86_64 \ -bios $(OVMF) \ -drive file=$(DISK_IMG),format=raw,if=none,id=disk \ @@ -72,7 +72,7 @@ run-gui: all -vga std # GDB stub on :1234 -debug: all +debug: all disk qemu-system-x86_64 \ -bios $(OVMF) \ -drive file=$(DISK_IMG),format=raw,if=none,id=disk \ @@ -92,6 +92,27 @@ debug: all run-image: all ./scripts/boot-image.sh rs-dos.img +# ---- Data disk ----------------------------------------------------------- + +# 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)" + +# Re-format the data disk from scratch (wipes it, then re-seeds). +disk-fresh: + ./scripts/mkdisk.sh --fresh "$(DISK_IMG)" + +# List the data disk 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)" + +# Full automated round trip: build -> boot -> shell commands -> poweroff +# -> fsck + mtools verification. +test-disk: + ./scripts/test-disk.sh + # ---- Full boot chain ----------------------------------------------------- # Build bootloader only (rsboot submodule) @@ -126,11 +147,18 @@ help: @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 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/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" + @echo " ./scripts/sendkeys.py type into QEMU via the monitor" @echo " ./scripts/boot-image.sh boot full chain (builds if needed)" @echo " ./scripts/build-image.sh build full chain disk image" @echo " ./scripts/build-bootloader.sh build rsboot from source" -- cgit v1.2.3