From 40deb4bce07304fd0a7bb3ebf73dd7c654a6e3a3 Mon Sep 17 00:00:00 2001 From: Albrecht Lohofener Date: Mon, 20 Jan 2025 20:36:33 +0100 Subject: [PATCH] Switch x86_64 to EFI boot mode --- Dockerfile | 4 ++++ src/migrate_openwrt_rootfs.sh | 5 +++-- src/run_openwrt.sh | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index fe73538..faa0273 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,8 +46,10 @@ ARG OPENWRT_ROOTFS_TAR RUN echo "Building for platform '$TARGETPLATFORM'" \ && if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ CPU_ARCH="x86_64"; \ + APK_EXTRA="ovmf"; \ elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ CPU_ARCH="aarch64"; \ + APK_EXTRA=""; \ else \ echo "Error: CPU architecture $TARGETPLATFORM is not supported"; \ exit 1; \ @@ -69,6 +71,7 @@ RUN echo "Building for platform '$TARGETPLATFORM'" \ openssh-client \ util-linux-misc \ iproute2 \ + "$APK_EXTRA" \ # It seems that PROFINET packages are not forwarded correctly without the package iproute2. The reason is unknown. \ && mkdir -p /usr/share/novnc \ && wget https://github.com/novnc/noVNC/archive/refs/tags/v${NOVNC_VERSION}.tar.gz -O /tmp/novnc.tar.gz -q \ @@ -117,6 +120,7 @@ RUN echo "Building for platform '$TARGETPLATFORM'" \ && if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ SSH_PORT=1022; \ qemu-system-x86_64 -M pc -nographic -nodefaults -m 256 \ + -bios /usr/share/ovmf/bios.bin \ -blockdev driver=raw,node-name=hd0,cache.direct=on,file.driver=file,file.filename=/var/vm/squashfs-combined-${OPENWRT_VERSION}.img \ -device virtio-blk-pci,drive=hd0 \ -device virtio-net,netdev=qlan0 -netdev user,id=qlan0,net=192.168.1.0/24,hostfwd=tcp::$SSH_PORT-192.168.1.1:22 \ diff --git a/src/migrate_openwrt_rootfs.sh b/src/migrate_openwrt_rootfs.sh index 001653f..fa89d5c 100644 --- a/src/migrate_openwrt_rootfs.sh +++ b/src/migrate_openwrt_rootfs.sh @@ -23,7 +23,7 @@ if [[ $DISABLE_OPENWRT_AUTO_UPGRADE != "true" ]]; then if [ $CPU_ARCH = "aarch64" ]; then qemu_command="qemu-system-aarch64 -M virt -bios /usr/share/qemu/edk2-aarch64-code.fd" else - qemu_command="qemu-system-x86_64 -M pc" + qemu_command="qemu-system-x86_64 -M pc -bios /usr/share/ovmf/bios.bin" fi # Boot a temporary OpenWrt @@ -105,5 +105,6 @@ if [[ $DISABLE_OPENWRT_AUTO_UPGRADE != "true" ]]; then info "squashfs-combined-${OPENWRT_IMAGE_ID}.img is up to date. Nothing to do." fi else - info "OpenWrt upgrade check is disabled. Using squashfs-combined-${OPENWRT_IMAGE_ID}.img. Nothing to do." + OLD_SQUASHFS_COMBINED=`cat /storage/old_version` + info "OpenWrt upgrade check is disabled. Using "$OLD_SQUASHFS_COMBINED". Nothing to do." fi \ No newline at end of file diff --git a/src/run_openwrt.sh b/src/run_openwrt.sh index 182bfdd..2d206be 100755 --- a/src/run_openwrt.sh +++ b/src/run_openwrt.sh @@ -175,7 +175,7 @@ attach_pci_device () { if [ $CPU_ARCH = "aarch64" ]; then CPU_ARGS="-M virt -bios /usr/share/qemu/edk2-aarch64-code.fd -vga none -device ramfb" else - CPU_ARGS="-M pc -vga std" + CPU_ARGS="-M pc -bios /usr/share/ovmf/bios.bin -vga std" fi # Check KVM