From patchwork Fri Feb 20 00:19:18 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1912 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=1771546827; bh=7whvtcDwRw4POPLCh3KGu5/3A0xVwnTlR0gjQCp/D+E=; 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=W4irPEwkVYYfmaujH5lBepcPS4+g3IOulSjfoLcQ1jMW54wvwgu0j4GEwm+w8I8oa GgugqJMcrY5n7dPZRXb84cHzhIsYfqzRdPdVZy3bxkFz3nk6kw7kP9IriuaZGv90Ej spiDoB5IhHXKCG+IQmsSZIwLd8Hf8ZbZkrKZKYTss6zjO4Qqh45uIirl0U7TgLJL5M HB4rqBnaa/ZsU1JfkK3jDIPwmShSm1gVaN7dFf2J42wFoae+BDBpSCUNiXqC9p16j6 +PMa2YQmnLVoqgBtX+xMQNLX+UXMlO2FGWlhwHM4kogtWQzrQxgmnX2aPaMLDTMvuV RBiSVUZd9Z/qg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 985FD69C8F for ; Thu, 19 Feb 2026 17:20:27 -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 I0NiXMM13YwQ for ; Thu, 19 Feb 2026 17:20:27 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771546827; bh=7whvtcDwRw4POPLCh3KGu5/3A0xVwnTlR0gjQCp/D+E=; 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=W4irPEwkVYYfmaujH5lBepcPS4+g3IOulSjfoLcQ1jMW54wvwgu0j4GEwm+w8I8oa GgugqJMcrY5n7dPZRXb84cHzhIsYfqzRdPdVZy3bxkFz3nk6kw7kP9IriuaZGv90Ej spiDoB5IhHXKCG+IQmsSZIwLd8Hf8ZbZkrKZKYTss6zjO4Qqh45uIirl0U7TgLJL5M HB4rqBnaa/ZsU1JfkK3jDIPwmShSm1gVaN7dFf2J42wFoae+BDBpSCUNiXqC9p16j6 +PMa2YQmnLVoqgBtX+xMQNLX+UXMlO2FGWlhwHM4kogtWQzrQxgmnX2aPaMLDTMvuV RBiSVUZd9Z/qg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 853E469C87 for ; Thu, 19 Feb 2026 17:20:27 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771546825; bh=dQ9O8zDh4PH6YE3Ol4WDCBTULvaKDVJbDxuz+kj4avk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ezRVIxCh8xJ/n6TwDSdEtazQy9Km+RPgn6W6vuGGc+CKbOOt8heIDRRP9xDbDFJ+o wOrjZLs0NMoit8OegcE9udMkC1YenER/BDEf6dWOt997gtdx8xPQaQLA7r+8vC7DWY okQkJzQ0EKSiLJgkJkXni2b+laRocNu2SVNaNdsLUZJsVEz2qAv/cU3/Qfqc6DsGq0 T1HVxKgWijef0hqrrrvqQmfxJt4JGGDQib3PJV6+TO6jdQa2znuuwTm50VDls0fw5T 6WZjnDFWBmlCZv1OkoIrEl5h2eex2hpAVA8CIRaKB/Q5QT3z5zNctJI1A3cjTZZAQG J9E1dPvX8Y4xQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 88F8F69C87; Thu, 19 Feb 2026 17:20:25 -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 P3Ln1iJGvz8k; Thu, 19 Feb 2026 17:20:25 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771546820; bh=VgaBRSntvrIYr0ZLy0z3ANrV1uGpP/b9sx+VHHmhQmE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=en/uh/3+6BysI9NDRQwKuyEotj/Q12zZ/AD1kJyOGO3phuyBCml0ZivWTgLw/JTpN l1u1PSqn6ZgoMK72roulK3JgJH58mJudBEHtcD6zjR4aPwWYRY7Mezqr0TRYZNBf9t HviTSTic0ngo0zPK1Uam89Wf3JU5WDWkNZDPfrIMok31fdVxBMwWJVImQLD3dN3LMo k0L4/A7cHU3LjtLsKqdQjjjM/ytZGu9N8A4LP08VtMyCEQd7ZU3dzr6UassqGHvwlr tWi9+qWZcl725JwMMlxJsqhWrRLEecokUY2nA4rBqPPTKqd2YBZoRXBV9Vgfd4TglB dJi5q9Tnf3uQA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B3E2869C7C; Thu, 19 Feb 2026 17:20:19 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 19 Feb 2026 17:19:18 -0700 Message-ID: <20260220001926.2366140-11-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260220001926.2366140-1-sjg@u-boot.org> References: <20260220001926.2366140-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: A7OQAUXLVKBKOZESM7GUC3OYB7NKGTUI X-Message-ID-Hash: A7OQAUXLVKBKOZESM7GUC3OYB7NKGTUI 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 Opus 4 . 6" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 10/13] ulib: x86: Enable Rust demo for efi-x86_app64 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 The C demo already builds and runs as an EFI application on x86_64, but the Rust demo is missing. The EFI build pipeline in Makefile.ulib-example already handles the rust-demo entry via the ULIB_EXAMPLES list, and RUST_TARGET_x86_64 is already defined. Enable CONFIG_RUST_EXAMPLES in efi-x86_app64_defconfig and add a QEMU boot test that launches rust-demo-app.efi under OVMF. Add a shared run_efi_rust_demo() helper that mirrors the existing run_efi_demo() but uses the Rust binary and startup script. Co-developed-by: Claude Opus 4.6 Signed-off-by: Simon Glass --- configs/efi-x86_app64_defconfig | 1 + test/py/tests/test_ulib.py | 57 +++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/configs/efi-x86_app64_defconfig b/configs/efi-x86_app64_defconfig index 3f9783faf6f..394bab55f0b 100644 --- a/configs/efi-x86_app64_defconfig +++ b/configs/efi-x86_app64_defconfig @@ -52,4 +52,5 @@ CONFIG_CMD_DHRYSTONE=y CONFIG_TPM=y CONFIG_ULIB=y CONFIG_EXAMPLES=y +CONFIG_RUST_EXAMPLES=y # CONFIG_GZIP is not set diff --git a/test/py/tests/test_ulib.py b/test/py/tests/test_ulib.py index b6fa30bcfd2..8ec5e985b52 100644 --- a/test/py/tests/test_ulib.py +++ b/test/py/tests/test_ulib.py @@ -452,6 +452,54 @@ def run_efi_demo(ubman, qemu_binary, fw_code, fw_vars, extra_qemu_args=None): out = run_qemu_demo(cmd, timeout=15) assert_demo_output(out) +def run_efi_rust_demo(ubman, qemu_binary, fw_code, fw_vars, + extra_qemu_args=None): + """Run a Rust ulib demo EFI application under QEMU with UEFI firmware. + + Writes a startup.nsh script next to rust-demo-app.efi in the build + directory, boots QEMU with the given firmware, and checks for + expected output. + + Args: + ubman (ConsoleBase): Test fixture providing build directory + etc. + qemu_binary (str): QEMU system binary name + (e.g. 'qemu-system-x86_64') + fw_code (str): Path to UEFI firmware code file + fw_vars (str): Path to UEFI firmware variables file (or None) + extra_qemu_args (list): Additional QEMU arguments + """ + build = ubman.config.build_dir + efi_dir = os.path.join(build, 'examples', 'ulib') + demo_efi = os.path.join(efi_dir, 'rust-demo-app.efi') + + assert os.path.exists(demo_efi), \ + 'rust-demo-app.efi not found in build directory' + assert shutil.which(qemu_binary), f'{qemu_binary} not found' + assert os.path.exists(fw_code), f'UEFI firmware not found: {fw_code}' + + with open(os.path.join(efi_dir, 'startup.nsh'), 'w', + encoding='utf-8') as nsh: + nsh.write('fs0:rust-demo-app.efi\n') + + cmd = [qemu_binary] + + # Set up firmware pflash drives + cmd += ['-drive', f'if=pflash,format=raw,file={fw_code},readonly=on'] + if fw_vars: + vars_copy = os.path.join(efi_dir, 'vars.fd') + shutil.copy(fw_vars, vars_copy) + cmd += ['-drive', f'if=pflash,format=raw,file={vars_copy}'] + + if extra_qemu_args: + cmd += extra_qemu_args + + # FAT drive with EFI binary and startup script + cmd += ['-drive', f'file=fat:rw:{efi_dir},format=raw', + '-nographic', '-no-reboot', '-nic', 'none'] + out = run_qemu_demo(cmd, timeout=15) + assert_demo_output(out) + @pytest.mark.localqemu @pytest.mark.boardspec('efi-x86_app64') @pytest.mark.buildconfigspec("examples") @@ -461,6 +509,15 @@ def test_ulib_demo_efi_x86(ubman): '/usr/share/OVMF/OVMF_CODE_4M.fd', '/usr/share/OVMF/OVMF_VARS_4M.fd') +@pytest.mark.localqemu +@pytest.mark.boardspec('efi-x86_app64') +@pytest.mark.buildconfigspec("rust_examples") +def test_ulib_rust_demo_efi_x86(ubman): + """Test the Rust ulib demo EFI app under QEMU x86_64 with OVMF.""" + run_efi_rust_demo(ubman, 'qemu-system-x86_64', + '/usr/share/OVMF/OVMF_CODE_4M.fd', + '/usr/share/OVMF/OVMF_VARS_4M.fd') + @pytest.mark.localqemu @pytest.mark.boardspec('efi-arm_app64') @pytest.mark.buildconfigspec("examples")