From patchwork Wed Oct 29 06:16:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 648 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=1761718660; bh=uwywFB+7h6MfBxcLVoccLpqIz1eMO6pwlJWyJhmrr/g=; 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=W1izcvurotX8NeyQvFmRf7yGCrXlAsfsaotWuCStQDRXHhnZss0YBhQ2yL9f1I7EC HmcS0l+1fOEHaWf7/Ew1dlzveCG1lnPSXBBabPDK9O8Mvs15/l0lhRkF9AzxDlUfAQ 2Aqelen8Xmmwf22qlqrDX7eayO1gH/nRvAM8E/yBF76oFgPfIMW+6WNZYGsL3TH2qG a842AdV6yxqUPTefJqQMLUTzI++uAR4mjG88PyiUV7sGPguOJU6TUJcpKuWhbK3cdo o5G6y2AYueVDw/U4eijg8WNXnRclUqSn3urddWEdDM79DS9Ewh559lnsQljZl6KuEg yBJG8V1Bmgzfg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EAB1468318 for ; Wed, 29 Oct 2025 00:17:40 -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 WG7s6gGt_owf for ; Wed, 29 Oct 2025 00:17:40 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1761718660; bh=uwywFB+7h6MfBxcLVoccLpqIz1eMO6pwlJWyJhmrr/g=; 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=W1izcvurotX8NeyQvFmRf7yGCrXlAsfsaotWuCStQDRXHhnZss0YBhQ2yL9f1I7EC HmcS0l+1fOEHaWf7/Ew1dlzveCG1lnPSXBBabPDK9O8Mvs15/l0lhRkF9AzxDlUfAQ 2Aqelen8Xmmwf22qlqrDX7eayO1gH/nRvAM8E/yBF76oFgPfIMW+6WNZYGsL3TH2qG a842AdV6yxqUPTefJqQMLUTzI++uAR4mjG88PyiUV7sGPguOJU6TUJcpKuWhbK3cdo o5G6y2AYueVDw/U4eijg8WNXnRclUqSn3urddWEdDM79DS9Ewh559lnsQljZl6KuEg yBJG8V1Bmgzfg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CD8936830C for ; Wed, 29 Oct 2025 00:17:40 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1761718658; bh=Oyd9ZhCFdM735UENOyzyCVQtPQR2F87V24rHsCfqRGA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ewLeA1OdZBbxW9jGmDYy9xzS2p6k6sQVFxQ1bH3EYuf9VlY+x28k161lWke5Cuz/E NCxezqEbxzfH8pbjuOQBbwSESqYvFBn/Q6oW4nr80QC5UuXqm0e2c1jvsOydpOuYqJ yR4rdy+FFZAtEr7/n6T5XLDOst/d/2vZiAI4nlkEQEghtuG308dT6EdmDoWBzb65Zk QbOMD6uNWJWE9xCz2yA/e8G9riqRwsjhwCmpZaJs5bb5pJw0ifVKdPJDtlnB88GKFJ ysrifOjstXxcn44vjHmtqR3LXpu7w69O4FQXg4iAj0xHJqqOKrsM57jkju0O9reohh BNH6x/JrrP2HA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AECED682B7; Wed, 29 Oct 2025 00:17:38 -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 rI_y8HhqyMHc; Wed, 29 Oct 2025 00:17:38 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1761718653; bh=9ADWNEookD1SSkIMe8MiUHtxpI71XCwsm03Cd0r3iUA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nSstT4dk3Z/BMNVUWOhQXEjjKYWZjqp/wxS9gtaJ+URtfaNQ3DRi6MLGEdIUcu5P5 737r52cdAmyTObSyx+qh02qf9HisQvZHlHju8DUXNHQ+VWl+cSnqnsu9RpW4n51C2g mhcv0tEIXiwNidOzzCvJirqMcPEIa9Gxi/uQcy8f0vjTyg9RvBPE6OMbxVRWjwnIV9 CwFHqtmCU0EXL7doL0Eg81fBiWNz4JBIaTBUXDEKveY5LrU+62Gs9lGfEjYaQaWKfJ 2cxwVr80HpZFHznRSRDqJ4Vm1dj+rzYoF6wPnt0WPKQwpeOo340sTizAVajCOjaEC/ MHdufzyqWlO9A== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 60D416826B; Wed, 29 Oct 2025 00:17:33 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 29 Oct 2025 00:16:47 -0600 Message-ID: <20251029061657.1456910-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251029061657.1456910-1-sjg@u-boot.org> References: <20251029061657.1456910-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: OLWBA23NE5H4GRQDJJAJMXWLPONLBQGC X-Message-ID-Hash: OLWBA23NE5H4GRQDJJAJMXWLPONLBQGC 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: Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 5/7] scripts: build-efi: Write uboot.env file for bootcmd 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 When running U-Boot as an EFI application under EDK2/OVMF, U-Boot doesn't have direct access to QEMU's fw_cfg interface. To support the --bootcmd option, write a uboot.env file to the EFI partition containing the boot command. Co-developed-by: Claude Signed-off-by: Simon Glass --- scripts/build-efi | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/scripts/build-efi b/scripts/build-efi index 95a8f456097..6c3b7a274f3 100755 --- a/scripts/build-efi +++ b/scripts/build-efi @@ -13,6 +13,13 @@ OVMF-pure-efi.x64.fd at https://drive.google.com/file/d/1c39YI9QtpByGQ4V0UNNQtGqttEzS-eFV/view?usp=sharing Use ~/.build-efi to configure the various paths used by this script. + +When --bootcmd is specified, a uboot.env file is created on the EFI partition +containing the boot command. U-Boot needs to be configured to import this file +on startup, for example by adding to CONFIG_PREBOOT or the default bootcmd: + + load ${devtype} ${devnum}:${distro_bootpart} ${loadaddr} uboot.env; \ + env import -t ${loadaddr} ${filesize} """ from argparse import ArgumentParser @@ -20,6 +27,7 @@ import os from pathlib import Path import shutil import sys +import tempfile import build_helper @@ -169,6 +177,32 @@ class BuildEfi: tools.write_file(f'{dst}/startup.nsh', f'fs0:{fname}', binary=False) shutil.copy(f'{self.build_dir}/{fname}', dst) + # Write U-Boot environment file if bootcmd is specified + if self.args.bootcmd: + # Check if mkenvimage is available (local build or system-wide) + mkenvimage = 'tools/mkenvimage' + if not os.path.exists(mkenvimage): + mkenvimage = 'mkenvimage' + if not shutil.which(mkenvimage): + tout.error('Please install u-boot-tools package:') + tout.error(' sudo apt install u-boot-tools') + raise FileNotFoundError('mkenvimage not found') + + # Create text environment file + env_content = f'bootcmd={self.args.bootcmd}\n' + with tempfile.NamedTemporaryFile(mode='w', delete=False, + suffix='.txt') as outf: + outf.write(env_content) + env_fname = outf.name + + try: + # Convert to binary format with CRC using mkenvimage + command.run(mkenvimage, '-s', '0x1000', + '-o', f'{dst}/uboot.env', env_fname) + print(f'Created uboot.env with bootcmd: {self.args.bootcmd}') + finally: + os.unlink(env_fname) + def do_build(self, build): """Build U-Boot for the selected board""" extra = ['-a', '~CONSOLE_PAGER'] if self.args.no_pager else []