Skip to content

Commit 6fba9fa

Browse files
committed
freebsd: Build UEFI QEMU image
Signed-off-by: Daniel Schaefer <[email protected]>
1 parent e4892be commit 6fba9fa

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed

framework_uefi/Makefile

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,36 @@ BUILD=build/$(TARGET)
33

44
SRC_DIR=.
55

6-
MKFS=mkfs.vfat
7-
6+
# sudo pkg install qemu edk2-qemu-x64
87
QEMU?=qemu-system-x86_64
8+
OVMF_FD?=/usr/local/share/edk2-qemu/QEMU_UEFI-x86_64.fd
99
QEMU_FLAGS=\
1010
-M q35 \
1111
-m 1024 \
1212
-net none \
1313
-vga std \
14-
-bios /usr/share/OVMF/OVMF_CODE.fd
14+
-bios /usr/local/share/edk2-qemu/QEMU_UEFI-x86_64.fd
1515

1616
.PHONY: qemu clean
1717

1818
all: $(BUILD)/boot.img
1919

20+
$(BUILD)/boot.img: $(BUILD)/boot.efi
21+
mkdir -p temp/EFI/BOOT
22+
cp $(BUILD)/boot.efi temp/EFI/BOOT/bootx64.efi
23+
makefs -t msdos \
24+
-o fat_type=16 \
25+
-o sectors_per_cluster=1 \
26+
-s 10000k \
27+
$(BUILD)/boot.img temp
28+
rm -rf temp
29+
2030
clean:
2131
rm -r $(BUILD)
2232

2333
qemu: $(BUILD)/boot.img
2434
$(QEMU) $(QEMU_FLAGS) $<
2535

26-
# Create ESP partition and filesystem
27-
$(BUILD)/boot.img: $(BUILD)/efi.img
28-
dd if=/dev/zero of=$@.tmp bs=512 count=100352
29-
parted $@.tmp -s -a minimal mklabel gpt
30-
parted $@.tmp -s -a minimal mkpart EFI FAT16 2048s 93716s
31-
parted $@.tmp -s -a minimal toggle 1 boot
32-
dd if=$< of=$@.tmp bs=512 count=98304 seek=2048 conv=notrunc
33-
mv $@.tmp $@
34-
35-
# Create filesystem with updater (bootx64.efi)
36-
$(BUILD)/efi.img: $(BUILD)/boot.efi
37-
dd if=/dev/zero of=$@.tmp bs=512 count=98304
38-
$(MKFS) $@.tmp
39-
mmd -i $@.tmp efi
40-
mmd -i $@.tmp efi/boot
41-
mcopy -i $@.tmp $< ::efi/boot/bootx64.efi
42-
mv $@.tmp $@
43-
4436
$(BUILD)/boot.efi: ../Cargo.lock $(SRC_DIR)/Cargo.toml $(SRC_DIR)/src/*
4537
mkdir -p $(BUILD)
4638
cargo rustc \

0 commit comments

Comments
 (0)