From 58fd275ad99591f883d435b16003dead1458d8b1 Mon Sep 17 00:00:00 2001 From: Wildan Mubarok Date: Tue, 24 Jun 2025 10:16:01 +0000 Subject: [PATCH 1/2] Dynamically search UEFI firmware --- mk/qemu.mk | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/mk/qemu.mk b/mk/qemu.mk index b91923f7b..7b21ba142 100644 --- a/mk/qemu.mk +++ b/mk/qemu.mk @@ -23,11 +23,20 @@ else ifeq ($(ARCH),x86_64) QEMU_CPU?=core2duo QEMU_SMP?=4 QEMU_MEM?=2048 + uefi?=yes ifeq ($(uefi),yes) - FIRMWARE=/usr/share/OVMF/OVMF_CODE.fd + FIRMWARE=$(firstword \ + $(wildcard /usr/share/OVMF/OVMF_CODE.fd) \ + ) + ifeq ($(FIRMWARE),) + PFLASH0=$(firstword \ + $(wildcard /usr/share/qemu/edk2-x86_64-code.fd) \ + $(wildcard /opt/homebrew/opt/qemu/share/qemu/edk2s-x86_64-code.fd) \ + ) + endif endif ifneq ($(usb),no) - QEMUFLAGS+=-device nec-usb-xhci,id=xhci + QEMUFLAGS+=-usb -device usb-kbd -device usb-tablet endif else ifeq ($(ARCH),aarch64) # Default to UEFI as U-Boot doesn't set up a framebuffer for us and we don't yet support @@ -52,7 +61,15 @@ else ifeq ($(ARCH),aarch64) endif else ifeq ($(uefi),yes) - FIRMWARE=/usr/share/AAVMF/AAVMF_CODE.fd + FIRMWARE=$(firstword \ + $(wildcard /usr/share/AAVMF/AAVMF_CODE.fd) \ + ) + ifeq ($(FIRMWARE),) + PFLASH0=$(firstword \ + $(wildcard /usr/share/qemu/edk2-aarch64-code.fd) \ + $(wildcard /opt/homebrew/opt/qemu/share/qemu/edk2-aarch64-code.fd) \ + ) + endif else FIRMWARE=$(BUILD)/qemu_uboot.rom endif @@ -79,8 +96,16 @@ else ifeq ($(ARCH),riscv64gc) QEMU_MEM?=2048 QEMU_CPU=max disk?=nvme - PFLASH0=/usr/share/qemu-efi-riscv64/RISCV_VIRT_CODE.fd - PFLASH1=/usr/share/qemu-efi-riscv64/RISCV_VIRT_VARS.fd + PFLASH0=$(firstword \ + $(wildcard /usr/share/qemu-efi-riscv64/RISCV_VIRT_CODE.fd) \ + $(wildcard /usr/share/qemu/edk2-riscv-code.fd) \ + $(wildcard /opt/homebrew/opt/qemu/share/qemu/edk2-riscv-code.fd) \ + ) + PFLASH1=$(firstword \ + $(wildcard /usr/share/qemu-efi-riscv64/RISCV_VIRT_VARS.fd) \ + $(wildcard /usr/share/qemu/edk2-riscv-vars.fd) \ + $(wildcard /opt/homebrew/opt/qemu/share/qemu/edk2-riscv-vars.fd) \ + ) ifneq ($(vga),no) QEMUFLAGS+=-device ramfb endif @@ -265,16 +290,6 @@ $(BUILD)/raspi3bp_uboot.rom: $(BUILD)/qemu_uboot.rom: wget -O $@ https://gitlab.redox-os.org/Ivan/redox_firmware/-/raw/main/platform/qemu/qemu_arm64/u-boot-qemu-arm64.bin -/usr/share/AAVMF/AAVMF_CODE.fd: - echo "\n\n\nMissing /usr/share/AAVMF/AAVMF_CODE.fd UEFI firmware file.\n\ -Please install the qemu-efi-aarch64 package or use efi=no to download U-Boot instead.\n" \ - && exit 1 - -/usr/share/qemu-efi-riscv64/RISCV_VIRT_CODE.fd /usr/share/qemu-efi-riscv64/RISCV_VIRT_VARS.fd: - echo "\n\n\nMissing $@ UEFI firmware file.\n\ -Please install the qemu-efi-riscv64 package.\n" - && exit 1 - qemu: qemu-deps $(QEMU) $(QEMUFLAGS) From 1e4abd216c6fe68261c9215bf7f0d458cba2a409 Mon Sep 17 00:00:00 2001 From: Wildan Mubarok Date: Tue, 24 Jun 2025 10:51:39 +0000 Subject: [PATCH 2/2] Revert --- mk/qemu.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mk/qemu.mk b/mk/qemu.mk index 7b21ba142..08f4421c1 100644 --- a/mk/qemu.mk +++ b/mk/qemu.mk @@ -36,7 +36,7 @@ else ifeq ($(ARCH),x86_64) endif endif ifneq ($(usb),no) - QEMUFLAGS+=-usb -device usb-kbd -device usb-tablet + QEMUFLAGS+=-device nec-usb-xhci,id=xhci endif else ifeq ($(ARCH),aarch64) # Default to UEFI as U-Boot doesn't set up a framebuffer for us and we don't yet support