From patchwork Thu Feb 12 00:14:06 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1838 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770855318; bh=eKJ54wyWX2+bpAV9SN3Zy7cjIeU3p+/TBa6XKVTv3a0=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=UiKWXQOkUF3oXWQVsuXJSWN+GDp293f2jNec7ViC5BONK181eyvTqUAZdgaVBYZcz 0FqoXlBxP5Jk8bkIZegqZ1tUmDof/HcyOqHw1V1tXn3f2wYqw0thOlzD+9/6fQ8TGd 0q+PuS0TxeHudH7VxmUBhVoTkpnL7C3wj5e2AoI4/V76dQ6Gi4fydd63cJ+RlCaCXs k9ZzEJeH4C/+wDTgHH9xu07WN6A2VAADRBV2DaoQ4YNO5BRdTOEzdiIg3qb8WtD1De /+3aByVkfbFCXQZxBN6/QXCnkT+VI9j/YZNlJZr++mGa70caWQKwdGwuTuOzChYWKU JuSTnFS7Gcjcg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 264C8699C6 for ; Wed, 11 Feb 2026 17:15:18 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id PJnAtf4TjNa6 for ; Wed, 11 Feb 2026 17:15:18 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770855318; bh=eKJ54wyWX2+bpAV9SN3Zy7cjIeU3p+/TBa6XKVTv3a0=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=UiKWXQOkUF3oXWQVsuXJSWN+GDp293f2jNec7ViC5BONK181eyvTqUAZdgaVBYZcz 0FqoXlBxP5Jk8bkIZegqZ1tUmDof/HcyOqHw1V1tXn3f2wYqw0thOlzD+9/6fQ8TGd 0q+PuS0TxeHudH7VxmUBhVoTkpnL7C3wj5e2AoI4/V76dQ6Gi4fydd63cJ+RlCaCXs k9ZzEJeH4C/+wDTgHH9xu07WN6A2VAADRBV2DaoQ4YNO5BRdTOEzdiIg3qb8WtD1De /+3aByVkfbFCXQZxBN6/QXCnkT+VI9j/YZNlJZr++mGa70caWQKwdGwuTuOzChYWKU JuSTnFS7Gcjcg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 13EBC69A90 for ; Wed, 11 Feb 2026 17:15:18 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770855316; bh=GUJprwIxVTdgwaAH0H5hLvVNbA9Y+YJCihwENmWOjC4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ci23tmZDBwqjzvzcvfp+XhxE1O508JyPOcMVAORtP4KRmHE87jB/Kr65JMMj7iqjh RCJ+1SRTxL/AdarWq4W9deXrz01HDicOiE3emZLNZ544xNaiukIX4j6Ss2ahjEwr13 aeBPR2qRyUnkWEfMujMzgkIoHRW5GP+j3EYN2bebRi5tj+5K6EUjofQ6KLpL0lSKPL z4BQ5lNOWdw+U5AWqEUwUjojcFCXSZABjvf8Hq8bfV4MabaJAlNB3024kBbwGjbtGW B8BwRAOJSMlS3EGIjyLFdknMUc+Wiv3wBeLuKhax6by1RhIhIYRMlzG8lSURs/S61I VC2tNWah/jpJg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DF9BA699DD; Wed, 11 Feb 2026 17:15:16 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id eaqQYZLHB3OH; Wed, 11 Feb 2026 17:15:16 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770855312; bh=8MCWdpi2lbRE0KxpbSbYhytJJu0oxexKFI5c5CZCByo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wSdEuv2u0HLIWt80psVFuLl/gfKfhLP/p+JrITAIkd9tLAsnfjhjbRKLCC9WfRWKc 16sw2xJQhUV6nhAOy/ZYdMWAkiYlz4OadYA1rMYzK2gUQXU1/Or/lzD7VymU1oNeqm UblRwh161x2wACOGFf69ahecAoEEGZwZLL8WeZSbX29I1oukQsh5l4JIaw5YHVGCsc Qyw5Gb+/3J3W3Tu/FJNFDGc3tO2FkSiS7SLGEOsLuKwmfoHJT96REwTAS/mzG714FO qW+c38qONaX0+qnsnYmFA/thV8di9bPlCW+ICGBwEO2SnWfMnJiGoWTqH2VBUFfCiu u5c2bbYj3CxEQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 80B51699C6; Wed, 11 Feb 2026 17:15:12 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 11 Feb 2026 17:14:06 -0700 Message-ID: <20260212001410.1919749-16-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260212001410.1919749-1-sjg@u-boot.org> References: <20260212001410.1919749-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: R7JHJA5VRAYDPW4PM2GCZQJ7BEBTFRIZ X-Message-ID-Hash: R7JHJA5VRAYDPW4PM2GCZQJ7BEBTFRIZ X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , "Claude Opus 4 . 6" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 15/15] scripts: build-efi: Add RISC-V architecture support List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add RISC-V as a supported architecture for the build-efi script. This configures QEMU with the riscv-virt machine, EDK2 firmware (RISCV_VIRT pflash images) and a virtio disk. The RISCV_VIRT_VARS.fd file is copied from the system directory on first use since QEMU needs it to be writable. Co-developed-by: Claude Opus 4.6 Signed-off-by: Simon Glass --- scripts/build-efi | 25 +++++++++++++++++++++++-- scripts/build_helper.py | 7 +++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/scripts/build-efi b/scripts/build-efi index e23d81bd9b1..a6c8614562b 100755 --- a/scripts/build-efi +++ b/scripts/build-efi @@ -101,6 +101,22 @@ class BuildEfi: ] extra += ['-drive', f'if=virtio,file={self.img},format=raw,id=hd0'] + elif self.args.arch == 'riscv': + qemu_arch = 'riscv64' + extra += ['--machine', 'virt'] + bios = os.path.join(efi_dir, 'RISCV_VIRT_CODE.fd') + if not os.path.exists(bios): + bios = '/usr/share/qemu-efi-riscv64/RISCV_VIRT_CODE.fd' + var_store = os.path.join(efi_dir, 'RISCV_VIRT_VARS.fd') + if not os.path.exists(var_store): + sys_var = '/usr/share/qemu-efi-riscv64/RISCV_VIRT_VARS.fd' + shutil.copy(sys_var, var_store) + extra += [ + '-drive', f'if=pflash,format=raw,file={bios},readonly=on', + '-drive', f'if=pflash,format=raw,file={var_store}' + ] + extra += ['-drive', + f'if=virtio,file={self.img},format=raw,id=hd0'] else: # x86 if self.helper.bitness == 64: qemu_arch = 'x86_64' @@ -122,7 +138,7 @@ class BuildEfi: extra += ['-display', 'none', '-serial', 'mon:stdio'] serial_msg = ' (Ctrl-a x to quit)' else: - if self.args.arch == 'arm': + if self.args.arch in ('arm', 'riscv'): extra += ['-device', 'virtio-gpu-pci'] extra += ['-device', 'qemu-xhci', '-device', 'usb-kbd', '-device', 'usb-tablet'] @@ -239,7 +255,12 @@ class BuildEfi: def start(self): """This does all the work""" args = self.args - arch = 'arm' if self.args.arch == 'arm' else 'x86' + if self.args.arch == 'arm': + arch = 'arm' + elif self.args.arch == 'riscv': + arch = 'riscv' + else: + arch = 'x86' build_type = 'payload' if args.payload else 'app' build = f'efi-{arch}_{build_type}{self.helper.bitness}' diff --git a/scripts/build_helper.py b/scripts/build_helper.py index d3e951fc220..bb55daaf84b 100644 --- a/scripts/build_helper.py +++ b/scripts/build_helper.py @@ -45,6 +45,8 @@ class Helper: self.os_arch = 'arm64' else: self.os_arch = 'arm' + elif self.args.arch == 'riscv': + self.os_arch = 'riscv64' else: # x86 if self.bitness == 64: self.os_arch = 'amd64' @@ -288,8 +290,9 @@ def add_common_args(parser): Args: parser (argparse.ArgumentParser): Parser to modify """ - parser.add_argument('-a', '--arch', default='arm', choices=['arm', 'x86'], - help='Select architecture (arm, x86) Default: arm') + parser.add_argument('-a', '--arch', default='arm', + choices=['arm', 'riscv', 'x86'], + help='Select architecture (arm, riscv, x86) Default: arm') parser.add_argument('-b', '--bootcmd', type=str, help='U-Boot bootcmd to pass via fw_cfg') parser.add_argument('-B', '--no-build', action='store_true',