From patchwork Mon Oct 6 23:21:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 535 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=1759792989; bh=MEmPyj8iDv4Yu/oTpkKjn0GcxiOb90pBgqoE01TSj7k=; 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=uebqgwozfUKUfnrXxuoyjLGaxe5vyVgtJvOGBD7/gxFuNJqkJPpF4RIrRKfUU+I/G CFUGltsKRi7WNvL3wNGJ8V2+2eEcuaspjcqNsGmwaxPfEzJJhMXFtN3btA52/4rEJD s3quCKJj5MKJtmGpnsk47LWfG4CP3SwENnuZTu21j4KyQyqLHrSlLOWRF71Opd5BF+ 1Rsa9ivanqKnKOFKZ6yuYm3PPPM+AvPCNMhBUEi0lirkvTR4SRV9gLo6/GyKDLjNAR 7Ir+V9oxFw/WjegpFtQ2y1HfvFFXCOy+AklifGlt+XsLyu7aBIMZOOZWxFDwLEz//B +fBJ95tN3agoQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7C7E567DB4 for ; Mon, 6 Oct 2025 17:23:09 -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 HJ2w31cAQTsL for ; Mon, 6 Oct 2025 17:23:09 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759792988; bh=MEmPyj8iDv4Yu/oTpkKjn0GcxiOb90pBgqoE01TSj7k=; 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=fhpJpDa5cxpd9XJ2hcu4KWwwh2yc32OpiR9qYMGneMHW5bV6GP4DV/G7/vPsiZ1hT rweQ/HioJzSp4Wwe4C+ef8yhGPtn65IXADBboQljyiBGKX08qrJUunRfkAQSgX/rPB zQKAH5d0JdwDxEoy3zvHKkpuGmN5qAaUn4iCtPm+RnZY9i66liFpPX7jI3JtA6bmr9 UwWTG23D2FdZ0kuGXuXwReqhboD5RqngRIvy4UdsM2h1buhZ2d3t10EjwjhRMvdJdb +0/bm+gz3vIjqeiLRN3xpQaCMm/dzbX5CWUB+ioVA9pgipWuXCyVKndh8HV51B/lMr YBuoLnQ+aJP4A== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 77A6967F3F for ; Mon, 6 Oct 2025 17:23:08 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759792986; bh=Ba5osKn7uajNr9rzUc1spB4vwMJEGleuvbHYhp5Q4Po=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=djA3YUGhoBl9m98ksW56x2woA+hpRAAvQCa7C4ByPRgn8DrHTaARerMSMCkLCG90I UjmKqWyB3yiDlIZ2pyfVrXB4wjNvjxrxUnq/o24FFah+V5VatpMRUoMY+jNi902nZC 5CsxyxWr/aEeDaWizO+t6Q5tm/UzeSCXlkGsTT9iUt2ByuONQpRhdmWiFJYgSCeRby bNBDiJ/N77mMK/1/0XGzMcnMMImnk7eD7FWkAfrEJD4XJUSQpjAxpJOknkghX/zvoV l0hlZ0ZAWXgOApNUJRDUu6pivuWpCo8yW4YJ+LINuM87eeLrdYNtdBaDUAYqsO0gST cZjCB+e3BX4HA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CDA1867F3F; Mon, 6 Oct 2025 17:23:06 -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 Vd_I6mtCfYP0; Mon, 6 Oct 2025 17:23:06 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759792985; bh=Nw17fOSInk82GsdjEbTBgc+LYRXAePAxSE78hPUti/A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rZ5t7hSLKe7Meiih80zk87qIsXRR4KoymGzOQjkYeNJBRMY0Gj3+ZM7afYoOmANNl J0tGcY368lAKkI1o24avZkRdkY+LLnDePCUJBkMIIluwHYO+P1bJAeSoMT3JSUCqlK Wp1uWqOMYJemShQRo2Exgm/vyHTEoCdA380Zp4FdCWTH346zy4UANsaWV8840bRMVC SszYlIPkKr0/K9cNImeA1/gUR+dMq+T36Pj1VXDfG/gV6lcsp1Te0x67Ek2A9bJ69k hHDt7hV1YKh821xzZfSf2O7zu7tJGNGeJovgPw5agNeWaHeV2I8vPo7PGUQL/JTQwl 3WiCN6yR4npHQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 068CF67DB4; Mon, 6 Oct 2025 17:23:04 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 6 Oct 2025 17:21:46 -0600 Message-ID: <20251006232236.2091941-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251006232236.2091941-1-sjg@u-boot.org> References: <20251006232236.2091941-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 2FX6ZYF6BQ5NMVRVRPO625OVV2BBCJQU X-Message-ID-Hash: 2FX6ZYF6BQ5NMVRVRPO625OVV2BBCJQU 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 04/17] 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 --- 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)