From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id A93B6740049 for ; Fri, 17 May 2024 07:17:38 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=C5cmYBCUzQiulCedx6ahSgKHrZlrSl3oqzdctNq3zA4=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20240206; t=1715930257; v=1; b=Tp3bTlgX5Ja6dZoSXtTA5JU7jLAVC0QEn69EbBkYuk3iRm1Iap89k0UeUl7FwmL6GLXJc6Fx FJ3sCy28q1Y1l6ju6tSl4dY0EMACN6zm9JqFGeedktj2q0/QGP9bRREzInAXwNC20nuwqN8Nz04 +eU5KJw9T2ucGzbGVPR3DeXVCJibeCaedzIMfG3u44trBjrA2Jduc/t2FLEqZMFeaNgY1MtUoz/ Sqe68X7+uT5jr4t0wbRb1wijGWJVzxcPBHkHFXo2Cm+UaXZpst6D6YYLpz0rSwuQ6DjzaO5iuWW RniO/ipRR3cT8TzPA2ShGftTQdDpB+iuzH5Nu7ciA0/1A== X-Received: by 127.0.0.2 with SMTP id zxxyYY7687511xqWkIgEzyeQ; Fri, 17 May 2024 00:17:37 -0700 X-Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by mx.groups.io with SMTP id smtpd.web10.34417.1715930255602519498 for ; Fri, 17 May 2024 00:17:36 -0700 X-Received: from loongson.cn (unknown [10.2.9.245]) by gateway (Coremail) with SMTP id _____8Dx_+uNBEdmhN0NAA--.33476S3; Fri, 17 May 2024 15:17:33 +0800 (CST) X-Received: from code-server.gen (unknown [10.2.9.245]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxFleMBEdmVxskAA--.4549S2; Fri, 17 May 2024 15:17:32 +0800 (CST) From: "Chao Li" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm , Sami Mujawar , Gerd Hoffmann , Jiewen Yao Subject: [edk2-devel] [PATCH v1 0/2] Add a new FdtNorFalshQemuLib and enable it in Date: Fri, 17 May 2024 15:17:29 +0800 Message-Id: <20240517071729.188409-1-lichao@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8BxFleMBEdmVxskAA--.4549S2 X-CM-SenderInfo: xolfxt3r6o00pqjv00gofq/1tbiAQAACGZGxZUDpQAKsV X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Fri, 17 May 2024 00:17:36 -0700 Resent-From: lichao@loongson.cn Reply-To: devel@edk2.groups.io,lichao@loongson.cn List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 76S6k5QGreiwjHfli8baGdrwx7686176AA= Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=Tp3bTlgX; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io Patch1: Added a new library called FdtNorFlashQemuLib in OvmfPkg/Library which is non-hardcode dependency. Patch2: Enable the new library in ArmVirtQemu.dsc and ArmVirtQemuKernel.dsc. BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4770 I have verified on both of the two platforms: Prepare: install libvirt, virt-manager, qemu-systemaarch64. Step 1: Built the two platforms with ArmVirtQemu.dsc and ArmVirtQemuKernel.dsc, and then using the command create the pflash files: Build the two platforms firmware using ArmVirtQemu.dsc and ArmVirtQemuKernel.dsc, and then create the pflash files using following command: cat QEMU_EFI.fd /dev/zero | head -c 64m > ./QEMU_EFI-pflash.raw cat QEMU_VARS.fd /dev/zero | head -c 64m > ./vars-template-pflash.raw qemu-img convert -f raw -O qcow2 -o cluster_size=4096 -S 4096 QEMU_EFI-pflash.raw QEMU_EFI-pflash.qcow2 qemu-img convert -f raw -O qcow2 -o cluster_size=4096 -S 4096 vars-template-pflash.raw vars-template-pflash.qcow2 Download a AARCH64 QCOW2 image. Copy them into /usr/share/edk2/aarch64/. Step 2: Verification the pflash working: ArmVirtQemu: Run the QEMU ARM virt machine using the following command: qemu-system-aarch64 \ -blockdev '{"driver":"file","filename":"/usr/share/edk2/aarch64/QEMU_EFI-pflash.qcow2","node-name":"libvirt-pflash0-storage","auto-read-only":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-pflash0-format","read-only":true,"driver":"qcow2","file":"libvirt-pflash0-storage"}' \ -blockdev '{"driver":"file","filename":"/usr/share/edk2/aarch64/vars-template-pflash.qcow2","node-name":"libvirt-pflash1-storage","auto-read-only":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-pflash1-format","read-only":false,"driver":"qcow2","file":"libvirt-pflash1-storage"}' \ -machine virt,pflash0=libvirt-pflash0-format,pflash1=libvirt-pflash1-format,acpi=on \ -cpu cortex-a57 \ -m size=2097152k \ -serial stdio \ -net none \ -device ramfb \ -device nec-usb-xhci \ -device usb-mouse \ -device usb-kbd ArmVirtQemuKernel: Run the QEMU kernel ARM virt machine using the following command: qemu-system-aarch64 \ -blockdev '{"driver":"file","filename":"/usr/share/edk2/aarch64/vars-template-pflash.raw","node-name":"libvirt-pflash1-storage","auto-read-only":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-pflash1-format","read-only":false,"driver":"raw","file":"libvirt-pflash1-storage"}' \ -machine virt,usb=off,dump-guest-core=off,gic-version=3,pflash1=libvirt-pflash1-format \ -cpu cortex-a57 \ -m 4096 \ -smp 1,sockets=1,cores=1,threads=1 \ -no-user-config \ -nodefaults \ -device virtio-gpu-pci \ -kernel /usr/share/edk2/aarch64/QEMU_EFI-pflash.raw \ -serial stdio \ -device nec-usb-xhci \ -device usb-mouse \ -device usb-kbd \ -hda /usr/share/edk2/aarch64/openEuler-22.03-LTS-SP3-aarch64.qcow2 \ -monitor tcp::3333,server,nowait Step 3: After the virt-machines starts, enter "F2" to enter the setup UI, try to change the boot order or some ther variables stored in the flash, then enter "F10" to save the changes and reboot it. After restarting, enter "F2" to enter the setup UI and check whether the changes before the restart operation have been saved. Using the above three steps, both platforms will works fine. I have not created the PR in github yet, I will create it once the edk2 merge window reopens. Cc: Ard Biesheuvel Cc: Leif Lindholm Cc: Sami Mujawar Cc: Gerd Hoffmann Cc: Jiewen Yao Chao Li (2): OvmfPkg: Add no hardcode version of FtdNorFlashQemuLib ArmVirtPkg: Enable the non-hardcode version FtdNorFlashQemuLib ArmVirtPkg/ArmVirtQemu.dsc | 21 ++- ArmVirtPkg/ArmVirtQemuKernel.dsc | 20 ++- ArmVirtPkg/VarStore.fdf.inc | 5 +- .../FdtNorFlashQemuLib/FdtNorFlashQemuLib.c | 165 ++++++++++++++++++ .../FdtNorFlashQemuLib/FdtNorFlashQemuLib.inf | 46 +++++ 5 files changed, 249 insertions(+), 8 deletions(-) create mode 100644 OvmfPkg/Library/FdtNorFlashQemuLib/FdtNorFlashQemuLib.c create mode 100644 OvmfPkg/Library/FdtNorFlashQemuLib/FdtNorFlashQemuLib.inf -- 2.27.0 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#118987): https://edk2.groups.io/g/devel/message/118987 Mute This Topic: https://groups.io/mt/106149594/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-