Skip to content

Commit 96925f9

Browse files
committed
real-hw-test: build and deploy every architecture at once
'make artifacts' cross-compiles all supported architectures, and the USB install copies every artifact under build/ to its removable-media path, so one stick boots the test on any supported machine.
1 parent 101f017 commit 96925f9

3 files changed

Lines changed: 36 additions & 13 deletions

File tree

real-hw-test/Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
CARGO ?= cargo
22
ARCH ?= x86_64
3+
ARCHS := x86_64 aarch64
34

45
ifeq ($(ARCH),x86_64)
56
TARGET := x86_64-unknown-uefi
@@ -24,7 +25,7 @@ ARTIFACT := build/$(BOOT_NAME)
2425
BUILD := CARGO_TARGET_DIR=$(TARGET_DIR) $(CARGO) build --locked
2526
CLIPPY := CARGO_TARGET_DIR=$(TARGET_DIR) $(CARGO) clippy --locked
2627

27-
.PHONY: all artifact check qemu qemu-tcg ci-qemu install clean
28+
.PHONY: all artifact artifacts check qemu qemu-tcg ci-qemu install clean
2829

2930
all: artifact
3031

@@ -35,6 +36,9 @@ $(ARTIFACT): FORCE
3536
mkdir -p $(dir $(ARTIFACT))
3637
cp $(BINARY) $(ARTIFACT)
3738

39+
artifacts:
40+
for arch in $(ARCHS); do $(MAKE) artifact ARCH=$$arch || exit 1; done
41+
3842
check:
3943
$(CARGO) fmt --check
4044
$(CLIPPY) --target x86_64-unknown-uefi --release -- -D warnings
@@ -53,8 +57,9 @@ ci-qemu: artifact
5357
ARCH="$(ARCH)" QEMU="$(QEMU)" OVMF="$(OVMF)" \
5458
./scripts/run-qemu-ci.sh $(ARTIFACT)
5559

60+
# Deploys every built architecture; 'make artifacts' first covers them all.
5661
install: artifact
57-
USB_MOUNT="$(USB_MOUNT)" ./scripts/install-usb.sh $(ARTIFACT)
62+
USB_MOUNT="$(USB_MOUNT)" ./scripts/install-usb.sh
5863

5964
clean:
6065
$(CARGO) clean --target-dir $(TARGET_DIR)

real-hw-test/README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ written directly to a UART are deliberately short, recognizable test payloads.
1313

1414
## TL;DR
1515

16-
1. Run `make artifact`, then deploy `build/BOOTX64.EFI` with `make install` to
17-
a mounted GPT/FAT32 EFI partition.
16+
1. Run `make artifact` (or `make artifacts` for every architecture), then
17+
deploy the built images with `make install` to a mounted GPT/FAT32 EFI
18+
partition.
1819
2. Boot with a monitor and USB keyboard. Leave the monitor connected: it is the
1920
authoritative diagnostic channel after firmware serial ownership is released.
2021
3. Confirm the firmware baseline, configure the remote to 9600 8N1, and press
@@ -111,7 +112,8 @@ file build/BOOTX64.EFI
111112

112113
The resulting file is `build/BOOTX64.EFI`. `make artifact ARCH=aarch64`
113114
produces `build/BOOTAA64.EFI` instead; every `make` target accepts the same
114-
`ARCH` variable.
115+
`ARCH` variable. `make artifacts` cross-compiles every supported architecture
116+
in one step.
115117

116118
Run all static build checks with:
117119

@@ -133,7 +135,10 @@ lsblk -o NAME,SIZE,TYPE,FSTYPE,FSVER,PTTYPE,MOUNTPOINTS
133135
make install USB_MOUNT=/run/media/$USER/EFI
134136
```
135137

136-
The file is copied to `EFI/BOOT/BOOTX64.EFI`. If the disk is not GPT, the
138+
Every artifact present in `build/` is copied to its removable-media path, so
139+
one stick can boot every architecture built beforehand (for example with
140+
`make artifacts`): `EFI/BOOT/BOOTX64.EFI`, `EFI/BOOT/BOOTAA64.EFI`, and so on.
141+
If the disk is not GPT, the
137142
filesystem is not FAT32, the path is not an exact mount point, or the mount is
138143
not writable, installation stops with a diagnostic. Unmount the partition
139144
cleanly before removing it.

real-hw-test/scripts/install-usb.sh

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
artifact=${1:-build/BOOTX64.EFI}
4+
artifacts=("$@")
55
mount_input=${USB_MOUNT:-}
66

77
fail() {
@@ -13,9 +13,20 @@ for command in findmnt lsblk install readlink sync; do
1313
command -v "$command" >/dev/null 2>&1 || fail "required command is missing: $command"
1414
done
1515

16+
# Without explicit arguments, deploy every architecture that has been built.
17+
if [[ ${#artifacts[@]} -eq 0 ]]; then
18+
for artifact in build/BOOT*.EFI; do
19+
[[ -e "$artifact" ]] && artifacts+=("$artifact")
20+
done
21+
fi
22+
1623
[[ -n "$mount_input" ]] || fail \
1724
"USB_MOUNT is unset; use 'make install USB_MOUNT=/path/to/mounted/efi-partition'"
18-
[[ -r "$artifact" ]] || fail "UEFI artifact is missing: $artifact (run 'make artifact')"
25+
[[ ${#artifacts[@]} -gt 0 ]] || fail \
26+
"no UEFI artifacts in build/ (run 'make artifact' or 'make artifacts')"
27+
for artifact in "${artifacts[@]}"; do
28+
[[ -r "$artifact" ]] || fail "UEFI artifact is missing: $artifact (run 'make artifact')"
29+
done
1930

2031
mount_path=$(readlink -f -- "$mount_input") || fail "cannot resolve USB_MOUNT: $mount_input"
2132
[[ "$mount_path" != / ]] || fail "refusing to install into the root filesystem"
@@ -57,13 +68,15 @@ fat_version=$(lsblk -dnro FSVER "$source_device")
5768
[[ "$fat_version" == FAT32 ]] || fail \
5869
"$source_device reports '${fat_version:-an unknown FAT version}', expected FAT32"
5970

60-
# The artifact already carries its architecture's removable-media file name.
61-
target=$mount_path/EFI/BOOT/$(basename "$artifact")
6271
echo "Installing to validated media:"
6372
echo " disk: $parent_device (GPT)"
6473
echo " partition: $source_device (FAT32)"
6574
echo " mount: $mount_path"
66-
echo " destination: $target"
67-
install -D -m 0644 -- "$artifact" "$target"
68-
sync "$target"
75+
# Each artifact already carries its architecture's removable-media file name.
76+
for artifact in "${artifacts[@]}"; do
77+
target=$mount_path/EFI/BOOT/$(basename "$artifact")
78+
echo " destination: $target"
79+
install -D -m 0644 -- "$artifact" "$target"
80+
sync "$target"
81+
done
6982
echo "Installation complete. Unmount the media cleanly before removing it."

0 commit comments

Comments
 (0)