diff options
| author | salmonik <salmonik@tuta.io> | 2026-08-02 02:16:40 +0200 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-08-02 02:16:40 +0200 |
| commit | d9fe082ef07b6e5c599585d6911dbad2bbe4c787 (patch) | |
| tree | f54e2ff928bd23926858aba9bd44c7a6f82bb80b /scripts | |
| parent | v0.5.5: self-diagnosing boot — vt refuses 0x0 geometry, panic band shows la... (diff) | |
| download | rs-dos-d9fe082ef07b6e5c599585d6911dbad2bbe4c787.tar.gz rs-dos-d9fe082ef07b6e5c599585d6911dbad2bbe4c787.zip | |
v0.5.5: fix real-hardware boot crash — shadow back in heap as first allocation
User's machine: boot reached 'rsnix: boot done — shell' then panicked
'len is 0, index 0' at the first cell write — CELLS (the vt grid) was
valid at vt::init and empty at the first shell paint, i.e. something
stomped the heap between vt::init and the shell banner. The only
change in that window vs the working v0.5.3 was the v0.5.4 move of the
1.9 MB display shadow from the heap to the fb-aware page allocator:
on this machine's memory layout the page-allocator shadow's fill loop
(480K words) clobbered the heap's vt vectors.
- Shadow is again the *first* heap allocation, in gop::init before
vt::init builds its grids (the v0.5.3 layout that provably boots on
the user's hardware) — nothing else in the heap can collide with it.
- init_heap now splits the free list at the GOP framebuffer hole
instead of subtracting its size from one block that still *spanned*
the hole — no heap allocation of any size can land on the display.
- Kept the panic-proof try_reserve + fb-overlap rejection + no-shadow
warning band; dropped the late init_shadow() call in main.rs.
- Verified on QEMU: shadow @ 0x1980020 origin=heap, allocated before
vt::init, fb clean at 0x80000000; all 5 suites PASS; 0 warnings.
Diffstat (limited to '')
| -rwxr-xr-x | scripts/build-image-release.sh | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/scripts/build-image-release.sh b/scripts/build-image-release.sh new file mode 100755 index 0000000..32f8f91 --- /dev/null +++ b/scripts/build-image-release.sh | |||
| @@ -0,0 +1,99 @@ | |||
| 1 | #!/usr/bin/env bash | ||
| 2 | # | ||
| 3 | # scripts/build-image.sh — assemble a bootable rs-dos disk image (UEFI/GPT) | ||
| 4 | # | ||
| 5 | # Layout: | ||
| 6 | # Partition 1: ESP (FAT32) — rsboot bootloader + kernel | ||
| 7 | # | ||
| 8 | # Output: | ||
| 9 | # rs-dos.img (or custom path) — bootable raw disk image for UEFI | ||
| 10 | # | ||
| 11 | # Usage: | ||
| 12 | # ./scripts/build-image.sh [output.img] | ||
| 13 | # | ||
| 14 | set -euo pipefail | ||
| 15 | |||
| 16 | SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" | ||
| 17 | PROJECT_DIR="$(dirname "$SCRIPT_DIR")" | ||
| 18 | |||
| 19 | cd "$PROJECT_DIR" | ||
| 20 | |||
| 21 | BUILD_DIR="$PROJECT_DIR/build" | ||
| 22 | ESP_DIR="$PROJECT_DIR/esp" | ||
| 23 | |||
| 24 | IMAGE="${1:-$PROJECT_DIR/rs-dos.img}" | ||
| 25 | TARGET=x86_64-unknown-uefi | ||
| 26 | PROFILE=release | ||
| 27 | OUT_DIR="target/${TARGET}/${PROFILE}" | ||
| 28 | |||
| 29 | BOOTLOADER="$BUILD_DIR/bootloader/BOOTX64.EFI" | ||
| 30 | KERNEL="$OUT_DIR/rsdos.efi" | ||
| 31 | BZIMAGE="$ESP_DIR/bzImage" | ||
| 32 | INITRD="$ESP_DIR/initramfs.cpio.gz" | ||
| 33 | BOOT_EFI="$ESP_DIR/EFI/BOOT/BOOTX64.EFI" | ||
| 34 | |||
| 35 | ESP_START=2048 # 1 MiB offset (standard alignment) | ||
| 36 | ESP_SIZE_MB=64 | ||
| 37 | |||
| 38 | IMAGE_SIZE_MB=$((ESP_SIZE_MB + 2)) # ESP + GPT gap + backup | ||
| 39 | |||
| 40 | # ---- checks ---- | ||
| 41 | for cmd in sfdisk mkfs.vfat mcopy truncate dd; do | ||
| 42 | if ! command -v "$cmd" &>/dev/null; then | ||
| 43 | echo "Error: $cmd not found" | ||
| 44 | exit 1 | ||
| 45 | fi | ||
| 46 | done | ||
| 47 | |||
| 48 | # ---- build kernel ---- | ||
| 49 | echo "[1/4] Building kernel..." | ||
| 50 | cargo build --release --package rsdos --target x86_64-unknown-uefi ${CARGO_FLAGS:-} | ||
| 51 | |||
| 52 | # ---- build bootloader ---- | ||
| 53 | echo "[2/4] Building bootloader..." | ||
| 54 | if [ ! -f "$BOOTLOADER" ]; then | ||
| 55 | "$SCRIPT_DIR/build-bootloader.sh" | ||
| 56 | fi | ||
| 57 | |||
| 58 | # ---- assemble ESP ---- | ||
| 59 | echo "[3/4] Assembling ESP..." | ||
| 60 | mkdir -p "$ESP_DIR/EFI/BOOT" | ||
| 61 | cp "$KERNEL" "$BZIMAGE" | ||
| 62 | cp "$BOOTLOADER" "$BOOT_EFI" | ||
| 63 | if [ ! -f "$INITRD" ]; then | ||
| 64 | printf '' | gzip >"$INITRD" | ||
| 65 | fi | ||
| 66 | |||
| 67 | # ---- create disk image ---- | ||
| 68 | echo "[4/4] Writing disk image..." | ||
| 69 | rm -f "$IMAGE" | ||
| 70 | truncate -s "${IMAGE_SIZE_MB}M" "$IMAGE" | ||
| 71 | |||
| 72 | # GPT partition table: single EFI System partition | ||
| 73 | sfdisk --quiet "$IMAGE" <<EOF | ||
| 74 | label: gpt | ||
| 75 | type=U, start=$ESP_START, size=+ | ||
| 76 | EOF | ||
| 77 | |||
| 78 | # Build FAT32 image with ESP contents | ||
| 79 | ESP_IMG=$(mktemp) | ||
| 80 | truncate -s "${ESP_SIZE_MB}M" "$ESP_IMG" | ||
| 81 | mkfs.vfat -F 32 -n "RS-DOS" "$ESP_IMG" >/dev/null 2>&1 | ||
| 82 | |||
| 83 | # Copy files into FAT | ||
| 84 | mmd -i "$ESP_IMG" ::/EFI 2>/dev/null || true | ||
| 85 | mmd -i "$ESP_IMG" ::/EFI/BOOT 2>/dev/null || true | ||
| 86 | mcopy -i "$ESP_IMG" "$BOOT_EFI" ::/EFI/BOOT/BOOTX64.EFI | ||
| 87 | mcopy -i "$ESP_IMG" "$BZIMAGE" ::/bzImage 2>/dev/null || true | ||
| 88 | mcopy -i "$ESP_IMG" "$INITRD" ::/initramfs.cpio.gz 2>/dev/null || true | ||
| 89 | |||
| 90 | # Inject FAT into image at partition offset | ||
| 91 | dd if="$ESP_IMG" of="$IMAGE" bs=512 seek="$ESP_START" conv=notrunc 2>/dev/null | ||
| 92 | rm -f "$ESP_IMG" | ||
| 93 | |||
| 94 | echo "" | ||
| 95 | echo "=== Done: $IMAGE ===" | ||
| 96 | ls -lh "$IMAGE" | ||
| 97 | echo "" | ||
| 98 | echo "Boot with: ./scripts/boot-image.sh" | ||
| 99 | echo "USB: sudo dd if=$IMAGE of=/dev/sdX bs=4M status=progress" | ||
