From patchwork Tue Oct 7 17:05:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 551 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=1759856789; bh=I2FXSFVGxigy85JmSWOEqctv8+kFPKxRBTOZxy3lGvg=; 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=gV5BhQiTWc+NoVJw2w+/HIJQi/elOBZZmtsHSqker9s6lpRa+HhMd7cimpxiBMMig AkXaxTRmlO8xLzukZjBtd2UKOty4VYKUL0KKABU8ck4oqOme8qxMSefW4lI7aj7XaT r7A8hiaUT5qdziX7tQy/z92rNzuAzJuaAiaoxks5QaopNISlM37vxkKtpQF23RRdr2 657A/JwdvsFTsNkl7SHP9ofhn1hubpotgjBAsRsAa53xdGizyCUy/Oz8BGR1G79L6e 1txASWilR1XMPyUP6yn+M+yj8QNYGLLVtQfP/B7L1mQm9PN46+LP8Oawavs8e8O3TD fdR9ca1CBu0UA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 81B7367FF8 for ; Tue, 7 Oct 2025 11:06:29 -0600 (MDT) 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 VFz0rJjhs64t for ; Tue, 7 Oct 2025 11:06:29 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856788; bh=I2FXSFVGxigy85JmSWOEqctv8+kFPKxRBTOZxy3lGvg=; 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=E8lxb0HFxa3prFvJOVkQm51sy2r7dKT79GE9DjmFmntQhbqV5Sre9dAWIOPpH2+Ol WVGLorE1hH8Ph+/adlXTE91yyf1L3jrt/voKE29Lk7hENL8ThX1ji18KVBAwn/0adB IsRI6ShvB5rHjqEVG2rThUdlVpEfuhEpVXbfhNwA+AaN1A6pgwDyv99VGQcP5FH44X PT41KKA5Sz9d35/XhjlJ6iIQbDpe1RgTN0dFhV+4iRUQfSYDiOqhW9bZ6k7eF7u2qq qCBN4BdOBgT+5xIAkctIYl4zlvBzbxnieHDG6ue0XlsOrF3ZH2O9Ctpqd09xDOtXDG inSGdx9BJv1ug== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2419767FF9 for ; Tue, 7 Oct 2025 11:06:28 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856785; bh=3zR8OEGrKLcr1oge2ul/k7Jnz6pe8nKn5QZyelZt//I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZFwIUAiARJOJHNxhcpGGyqJnKXYDsfzWMGBieUDrkinNfbJx/MwL9B2mAhtlzCY+D L2nqnoDywfByJRHSWsAKGucrCEszfUfHPleY9zoUjxYudBID39C/kn2l+T0eKg4gpv UuQAIC7ZllW04Lw3JGxjhiTbn6OEmSgDAqoJAkQxJpqgknsJqm1kxiN+h2Wpw78uGK dJkjTw7rrEOYCTmaI1OrXuG2/CmNMpnAubI1jZ0zEiTDlKoIgTTSrJ6vU7U10lgjQ4 yDm4JdIgyZ5Cob8UIHJaslpkwtG/iljlR70wwmJ0o/7/26wcZF0XJwvfrFSQc6w9Q0 eUBXIQi14OryQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6A2FE67F1E; Tue, 7 Oct 2025 11:06:25 -0600 (MDT) 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 sOMHMod4RoLf; Tue, 7 Oct 2025 11:06:25 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856783; bh=9flUfFAockmK0lJrw+QcOlsAXxYHQOHXrnwff+zjeb4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GoJzTTf5dNEtN4tte++p3KTYmfYONFd7XVnrrH4mz9mTzJax1B7U9C2jFNoVv8Qc4 jHIJ8ORhRWZJbDfDw2PvS8tfrFs8K9qN6E6xCfavZ+DjsaoEGCDtQWL/kIK8AwRvv1 oYPE92+WNGcDUA8u52/OisYz/TNz4go4uZnWsbeZEk9AF767vAh/aOcdI/h+CijGAA IYrbuOyFTiYZrUfo71ppQdrtSZVUKXATRvOPC3v8LC3GPZ2/Mt4mQhG8JoeAVBKobB un3FOqrih6ntqK1EIJcO40cUzBMolp5kLS2WfQtHoONwiFo+Ft5qbCKfd22L/wdk36 KsSxZMaDqSjSw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 9CEF667F74; Tue, 7 Oct 2025 11:06:23 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 7 Oct 2025 11:05:18 -0600 Message-ID: <20251007170549.541981-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251007170549.541981-1-sjg@u-boot.org> References: <20251007170549.541981-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: YUAWW6NLL7Z5IDD4VJVUJCJ2VWKQJ5L4 X-Message-ID-Hash: YUAWW6NLL7Z5IDD4VJVUJCJ2VWKQJ5L4 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 04/20] scripts: build-qemu: Add --bootcmd option to pass bootcmd via fw_cfg 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 a --bootcmd option to the build-qemu script that allows passing a boot command to QEMU via fw_cfg. The bootcmd is written to the "opt/u-boot/bootcmd" fw_cfg entry, which can be read by U-Boot's EVT_BOOTCMD handler. Co-developed-by: Claude Signed-off-by: Simon Glass --- (no changes since v1) doc/board/emulation/script.rst | 15 +++++++++++++++ scripts/build-qemu | 7 +++++++ 2 files changed, 22 insertions(+) diff --git a/doc/board/emulation/script.rst b/doc/board/emulation/script.rst index cf718ad41a7..239b1e1718d 100644 --- a/doc/board/emulation/script.rst +++ b/doc/board/emulation/script.rst @@ -64,6 +64,14 @@ Once configured, you can build and run QEMU for arm64 like this:: scripts/build-qemu -rsw +To pass a custom boot command to U-Boot via fw_cfg, use the `--bootcmd` +option:: + + scripts/build-qemu -rsw --bootcmd "echo Hello from QEMU; bootflow scan -lb" + +This will cause U-Boot to execute the specified command instead of the default +autoboot behavior. + Options ~~~~~~~ @@ -107,3 +115,10 @@ Options are available to control the script: -w Use word version (32-bit). By default, 64-bit is used + +--bootcmd BOOTCMD + U-Boot bootcmd to pass via fw_cfg. This allows passing a custom boot + command to U-Boot at runtime through QEMU's firmware configuration + interface. The bootcmd is written to the 'opt/u-boot/bootcmd' fw_cfg + entry and is read by U-Boot's EVT_BOOTCMD handler before the default + autoboot process runs. diff --git a/scripts/build-qemu b/scripts/build-qemu index 522325a8d57..ddaafc7587f 100755 --- a/scripts/build-qemu +++ b/scripts/build-qemu @@ -41,6 +41,8 @@ def parse_args(): description='Build and/or run U-Boot with QEMU', formatter_class=argparse.RawTextHelpFormatter) build_helper.add_common_args(parser) + parser.add_argument('--bootcmd', type=str, + help='U-Boot bootcmd to pass via fw_cfg') parser.add_argument('-e', '--sct-run', action='store_true', help='Run UEFI Self-Certification Test (SCT)') parser.add_argument('-E', '--use-tianocore', action='store_true', @@ -290,6 +292,11 @@ class BuildQemu: # Add other parameters gathered from options qemu_cmd.extend(self.qemu_extra) + # Add bootcmd via fw_cfg if specified + if self.args.bootcmd: + qemu_cmd.extend(['-fw_cfg', + f'name=opt/u-boot/bootcmd,string={self.args.bootcmd}']) + self.helper.setup_share(qemu_cmd) self.helper.run(qemu_cmd)