From patchwork Mon Feb 16 01:34:56 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1888 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=1771205758; bh=yOt9SaKWw4HyOO1DN7h8g56ZjTqsv6dZ9+7gpPEJ/6o=; 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=Q/drknxcngrMsMl7u0DYOOwP4oqdJw/De5eD2XUHpw7a8V5vw5n+o5Pdmp/P7BY2v rOiGR+PCMa/HG+n2wd1q+yKz3hEiCTAyqx/1OdkPQkgc5B8mR2OQweHi+GH+72Shja vlMSfQ8T8nSjay3mKLlC6iPDP1fC5rX5ByfsVpynFOowoCZwh32wpZ3o8fXbVQGAOp 7/hSPBmP6CTn7wukAWbLl/VxPPbrhIZLgxoTZXUGOqa4YJotTEVugHoPY01naEljwA JREsjNc+29uiPDlXmpXv4jHU4FVNy2OZcdWdq1mtU6UEJTdVJHVbssbRIJCIT2ioam 1z3D+Q+MiGdww== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7939A69B01 for ; Sun, 15 Feb 2026 18:35:58 -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 sDo0Juyl8t_f for ; Sun, 15 Feb 2026 18:35:58 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771205758; bh=yOt9SaKWw4HyOO1DN7h8g56ZjTqsv6dZ9+7gpPEJ/6o=; 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=Q/drknxcngrMsMl7u0DYOOwP4oqdJw/De5eD2XUHpw7a8V5vw5n+o5Pdmp/P7BY2v rOiGR+PCMa/HG+n2wd1q+yKz3hEiCTAyqx/1OdkPQkgc5B8mR2OQweHi+GH+72Shja vlMSfQ8T8nSjay3mKLlC6iPDP1fC5rX5ByfsVpynFOowoCZwh32wpZ3o8fXbVQGAOp 7/hSPBmP6CTn7wukAWbLl/VxPPbrhIZLgxoTZXUGOqa4YJotTEVugHoPY01naEljwA JREsjNc+29uiPDlXmpXv4jHU4FVNy2OZcdWdq1mtU6UEJTdVJHVbssbRIJCIT2ioam 1z3D+Q+MiGdww== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 659C469BDB for ; Sun, 15 Feb 2026 18:35:58 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771205755; bh=9yYWNYVRp6XWBs4xJKffYObcrz0C7txLZiNQFXsUcpE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uIub3iCMciP1qZ4+e72BCoEYfw5TEgtuA6hhjzEdCPWHaIW1XlczYor264KHqclNL Pr3+NhMhRIEjpejvPtzL+WNZclxgNt7P87i3s/fDc/K6A8+C50m9A8wQgvsc5bjC2t 2UY7SdyGBGZFvEjJB6hDwp4a9JHryVWbLJy0ZY8YbUqD0EE1uGXnN0aEZH9hqumZsG 72GYdm/luWSAPWMOoQA2lAxlsqrMDVuKQL0/trMH0pnpEovqDSdXV5EEA95Law19qo e1tX6v/atlF6aukOIXe8SWpOAzowCM4XLluGpnW5gRX+9bFkuIYvtOdQH2zcuygqzF Ajd4XMAwLOSVA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A50FC69BDB; Sun, 15 Feb 2026 18:35:55 -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 2LD_z1rnpk5a; Sun, 15 Feb 2026 18:35:55 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771205750; bh=bZ5AD7r6XWawSYy+XBNB1RE4Y2FFxC+rudM1itgs6AU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sk8shJOAmrnV0hxWiMGSFqTuz6r3EUzD+dCppJJialx8XHWj/pZLiyG/DzFB1/DOI fD50zBIXTtsgJGuDbtCtMPvuPuwab5gYOnwgosJ38CbGMLJTfDIDrFIqLenAdhv2tU sudTok0hc58BDGz6FlScabJ7T0wcom1P9dFLPWd8+kpeEzFziltpGS2lsWrAn1xPXS zzSpqWHpJFtn1xVH/nn2GWs5uq1LdEPEqavwTK89AYBRNGCkXpPjaT6W9++D7UKhkV 1/92ONJR/H6k60eXyHJuiLOhr0dJlUkqjSOnK5hT3A3TLFAxu0ds5nC0b+wC9/jChF RB/gPVyMtXWPA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 8F8F869AD9; Sun, 15 Feb 2026 18:35:50 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sun, 15 Feb 2026 18:34:56 -0700 Message-ID: <20260216013511.4079770-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260216013511.4079770-1-sjg@u-boot.org> References: <20260216013511.4079770-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 3RPB3VB2SAOMJNQ3UPLYH24LIVIU5XEJ X-Message-ID-Hash: 3RPB3VB2SAOMJNQ3UPLYH24LIVIU5XEJ 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 08/17] ulib: riscv: Add demo binary and examples for qemu-riscv64 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 riscv64 example following the same pattern as ARM64. The demo binary is re-linked with the example objects and then run through prelink-riscv to resolve GOT entries, which is required for RISC-V static PIE binaries. Enable CONFIG_ULIB and CONFIG_EXAMPLES in qemu-riscv64_defconfig and add a pytest for the demo. Co-developed-by: Claude Opus 4.6 Signed-off-by: Simon Glass --- arch/riscv/Makefile | 7 ++++++ configs/qemu-riscv64_defconfig | 2 ++ test/py/tests/test_ulib.py | 42 +++++++++++++++++++++++++++------- 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile index aaa5a02e17c..afae33812e4 100644 --- a/arch/riscv/Makefile +++ b/arch/riscv/Makefile @@ -62,3 +62,10 @@ endif libs-y += arch/riscv/cpu/ libs-y += arch/riscv/cpu/$(CPU)/ libs-y += arch/riscv/lib/ + +ifdef CONFIG_EXAMPLES +EXAMPLE_ARCH := riscv +EXAMPLE_APPEND_DTB := y +EXAMPLE_POST_LINK = @tools/prelink-riscv $@ +include scripts/Makefile.ulib-example +endif diff --git a/configs/qemu-riscv64_defconfig b/configs/qemu-riscv64_defconfig index 6b2fed4ad16..4423d36b782 100644 --- a/configs/qemu-riscv64_defconfig +++ b/configs/qemu-riscv64_defconfig @@ -22,3 +22,5 @@ CONFIG_FLASH_SHOW_PROGRESS=0 CONFIG_SYS_MAX_FLASH_BANKS=2 CONFIG_UTHREAD=y CONFIG_UNIT_TEST=y +CONFIG_ULIB=y +CONFIG_EXAMPLES=y diff --git a/test/py/tests/test_ulib.py b/test/py/tests/test_ulib.py index 94d40256c59..71fe751efc9 100644 --- a/test/py/tests/test_ulib.py +++ b/test/py/tests/test_ulib.py @@ -290,18 +290,44 @@ def test_ulib_demo_rom_64(ubman): """Test the ulib demo ROM image under QEMU x86_64.""" run_x86_rom_demo(ubman, 'qemu-system-x86_64') -@pytest.mark.localqemu -@pytest.mark.boardspec('qemu_arm64') -@pytest.mark.buildconfigspec("examples") -def test_ulib_demo_arm64(ubman): - """Test the ulib demo binary under QEMU ARM64.""" +def run_bios_demo(ubman, qemu_binary, extra_qemu_args=None): + """Boot the demo.bin binary under QEMU and check for expected output. + + Locates demo.bin in the build directory, launches the given QEMU + binary with it as -bios, and asserts that the expected demo output + is present. + + Args: + ubman (ConsoleBase): Test fixture providing build directory + etc. + qemu_binary (str): QEMU system binary + (e.g. 'qemu-system-aarch64') + extra_qemu_args (list): Additional QEMU arguments + (e.g. ['-cpu', 'cortex-a57']) + """ build = ubman.config.build_dir demo_bin = os.path.join(build, 'examples', 'ulib', 'demo.bin') assert os.path.exists(demo_bin), 'demo.bin not found in build directory' - assert shutil.which('qemu-system-aarch64'), 'qemu-system-aarch64 not found' + assert shutil.which(qemu_binary), f'{qemu_binary} not found' - cmd = ['qemu-system-aarch64', '-machine', 'virt', '-cpu', 'cortex-a57', - '-nographic', '-no-reboot', '-bios', demo_bin] + cmd = [qemu_binary, '-machine', 'virt', '-nographic', '-no-reboot', + '-bios', demo_bin] + if extra_qemu_args: + cmd += extra_qemu_args out = run_qemu_demo(cmd) assert_demo_output(out) + +@pytest.mark.localqemu +@pytest.mark.boardspec('qemu_arm64') +@pytest.mark.buildconfigspec("examples") +def test_ulib_demo_arm64(ubman): + """Test the ulib demo binary under QEMU ARM64.""" + run_bios_demo(ubman, 'qemu-system-aarch64', ['-cpu', 'cortex-a57']) + +@pytest.mark.localqemu +@pytest.mark.boardspec('qemu-riscv64') +@pytest.mark.buildconfigspec("examples") +def test_ulib_demo_riscv64(ubman): + """Test the ulib demo binary under QEMU RISC-V 64.""" + run_bios_demo(ubman, 'qemu-system-riscv64')