From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B105606A323 for ; Wed, 2 Dec 2026 15:09:20 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xYlxI-0002Ot-MZ; Wed, 02 Dec 2026 10:09:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xYlxF-0002OZ-CV; Wed, 02 Dec 2026 10:09:10 -0500 Received: from 93-87-244-166.static.isp.telekom.rs ([93.87.244.166] helo=fx.arvanta.net) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xYlxC-0005wg-Tn; Wed, 02 Dec 2026 10:09:08 -0500 Received: from air (m1pro.arvanta.net [10.5.1.11]) by fx.arvanta.net (Postfix) with ESMTP id 59358409; Wed, 02 Dec 2026 16:09:02 +0100 (CET) Date: Wed, 2 Dec 2026 16:09:02 +0100 From: Milan =?utf-8?Q?P=2E_Stani=C4=87?= To: Anirudh Srinivasan Cc: qemu-devel@nongnu.org, Palmer Dabbelt , Alistair Francis , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Chao Liu , qemu-riscv@nongnu.org, Jeuk Kim , Alistair Francis , Paolo Bonzini , Pierrick Bouvier , tgamblin@baylibre.com, w1355457260@gmail.com Subject: Re: [PATCH v2 9/9] tests/functional/riscv64: Add spacemit-k3 tests Message-ID: <20261202150902.GA10491@air> References: <20261129-spacemit_k3-v2-0-462c078463e9@oss.tenstorrent.com> <20261129-spacemit_k3-v2-9-462c078463e9@oss.tenstorrent.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20261129-spacemit_k3-v2-9-462c078463e9@oss.tenstorrent.com> Received-SPF: pass client-ip=93.87.244.166; envelope-from=mps@arvanta.net; helo=fx.arvanta.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, TVD_RCVD_IP=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Sun, 2026-11-29 at 11:09, Anirudh Srinivasan wrote: > Add tests for the spacemit-k3 machine that test SD/NOR boot, Linux boot > with SMP and the UFS controller. > > Signed-off-by: Anirudh Srinivasan Applied patches on top of qemu 11.2.0 rc2 and build vendor opensbi-spacemit-k3-1.0.10 and u-boot-spacemit-k3-1.0.10 (patched to have extlinux.conf). Build riscv64 UFS image (with script) and tested on Alpine Linux aarch64 edge (development branch) host. Boots fine to the shell and can run all commands fine. Tested-by: Milan P. Stanić > --- > MAINTAINERS | 1 + > tests/functional/riscv64/meson.build | 1 + > tests/functional/riscv64/test_spacemit_k3.py | 137 +++++++++++++++++++++++++++ > 3 files changed, 139 insertions(+) > > diff --git a/MAINTAINERS b/MAINTAINERS > index 5c2ce76516..4610880857 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -1867,6 +1867,7 @@ F: include/hw/misc/spacemit_*.h > F: include/hw/riscv/spacemit_*.h > F: include/hw/ssi/spacemit_*.h > F: target/riscv/tcg/spacemit_csr.c > +F: tests/functional/riscv64/test_spacemit_*.py > > Tenstorrent Machines > M: Joel Stanley > diff --git a/tests/functional/riscv64/meson.build b/tests/functional/riscv64/meson.build > index 211ea9acfc..8bb89763fe 100644 > --- a/tests/functional/riscv64/meson.build > +++ b/tests/functional/riscv64/meson.build > @@ -18,6 +18,7 @@ tests_riscv64_system_thorough = [ > 'k230', > 'server_ref', > 'sifive_u', > + 'spacemit_k3', > 'tt_atlantis', > 'tuxrun', > 'milkv_duo', > diff --git a/tests/functional/riscv64/test_spacemit_k3.py b/tests/functional/riscv64/test_spacemit_k3.py > new file mode 100755 > index 0000000000..662db3d6d2 > --- /dev/null > +++ b/tests/functional/riscv64/test_spacemit_k3.py > @@ -0,0 +1,137 @@ > +#!/usr/bin/env python3 > +# > +# Functional tests for the Spacemit K3 machine that test > +# boot media, linux boot and the UFS controller > +# > +# Copyright 2026 Anirudh Srinivasan > +# SPDX-License-Identifier: GPL-2.0-or-later > + > +from qemu_test import Asset, QemuSystemTest > +from qemu_test import wait_for_console_pattern > +from qemu_test import exec_command_and_wait_for_pattern > +import os > + > + > +class SpacemitK3Machine(QemuSystemTest): > + timeout = 180 > + > + ASSET_NOR = Asset( > + "https://github.com/asrinivasanTT/k3-firmware-images/releases/download/v0.0.1/nor.img", > + "fec3889477304369047853a2d8a86c2104b4ee9314c810bbff738276756101b9", > + ) > + ASSET_SD = Asset( > + "https://github.com/asrinivasanTT/k3-firmware-images/releases/download/v0.0.1/sd.img", > + "2bc4f2623a22fa63241ec7a9486e381484028c7d18e1ca7a58a1df1ff7e03050", > + ) > + ASSET_UFS = Asset( > + "https://github.com/asrinivasanTT/k3-firmware-images/releases/download/v0.0.1/ufs.img", > + "5d31fb66468c77a8301b826b1a09c111cc6e59738b2345bbc2dbf450ad8eca01", > + ) > + # Update Kernel and DTB to use tuxboot kernels once a newer version is > + # available there > + ASSET_KERNEL = Asset( > + "https://github.com/asrinivasanTT/k3-firmware-images/releases/download/v0.0.1/Image", > + "15afb7dec149320352a5bb5e4c6cc038f413a68f658634f501f8d17490f1f615", > + ) > + ASSET_DTB = Asset( > + "https://github.com/asrinivasanTT/k3-firmware-images/releases/download/v0.0.1/k3-pico-itx.dtb", > + "44dfd45e10c42e87326654a5b3b1704da82b32bc9d93514da8b719f8859249a6", > + ) > + ASSET_ROOTFS = Asset( > + "https://storage.kernelci.org/images/rootfs/buildroot/buildroot-baseline/20260915.0/riscv/rootfs.cpio.gz", > + "6c5716ac36b3bc60bcb9d933c1743c3382dde0d3b45a362776172095a4d4ffc9", > + ) > + > + NOR_DRIVE = "if=mtd,format=raw,snapshot=on" > + SD_DRIVE = "if=sd,format=raw,index=0,snapshot=on" > + > + def boot_linux(self, firmware_drive): > + """ > + Boot the firmware stack (U-Boot SPL, OpenSBI, U-Boot) from specified > + boot media and then boot into Linux that has been sideloaded into > + memory. > + """ > + self.set_machine("spacemit-k3") > + self.vm.set_console() > + kernel_path = self.ASSET_KERNEL.fetch() > + dtb_path = self.ASSET_DTB.fetch() > + initrd_path = self.ASSET_ROOTFS.fetch() > + initrd_size = os.path.getsize(initrd_path) > + > + self.vm.add_args( > + "-drive", > + firmware_drive, > + "-device", > + f"loader,file={kernel_path},addr=0x180000000", > + "-device", > + f"loader,file={dtb_path},addr=0x160000000", > + "-device", > + f"loader,file={initrd_path},addr=0x170000000", > + ) > + self.vm.launch() > + > + wait_for_console_pattern(self, "U-Boot SPL") > + wait_for_console_pattern(self, "OpenSBI") > + wait_for_console_pattern(self, "U-Boot 2022") > + wait_for_console_pattern(self, "=>") > + > + exec_command_and_wait_for_pattern( > + self, 'setenv bootargs "earlycon=sbi console=ttyS0,115200"', "=>" > + ) > + exec_command_and_wait_for_pattern( > + self, > + f"booti 0x180000000 0x170000000:{initrd_size:#x} 0x160000000", > + "Starting kernel", > + ) > + wait_for_console_pattern(self, "Linux version") > + wait_for_console_pattern(self, "smp: Brought up 1 node, 8 CPUs") > + wait_for_console_pattern(self, "Run /init") > + wait_for_console_pattern(self, "~ #") > + > + def scan_ufs(self, firmware_drive): > + """ > + Boot the firmware stack from the specified boot media up till U-Boot, > + attach a UFS image, and verify that U-Boot can scan the UFS controller > + and list the ext4 partition contents. > + """ > + self.set_machine("spacemit-k3") > + self.vm.set_console() > + ufs_path = self.ASSET_UFS.fetch() > + > + self.vm.add_args( > + "-drive", > + firmware_drive, > + "-drive", > + f"file={ufs_path},if=scsi,format=raw,snapshot=on", > + ) > + self.vm.launch() > + > + wait_for_console_pattern(self, "U-Boot SPL") > + wait_for_console_pattern(self, "OpenSBI") > + wait_for_console_pattern(self, "U-Boot 2022") > + wait_for_console_pattern(self, "=>") > + > + exec_command_and_wait_for_pattern(self, "scsi scan", "=>") > + > + exec_command_and_wait_for_pattern(self, "ext4ls scsi 0:1 /", > + "hello.txt") > + > + def test_spacemit_k3_nor_linux(self): > + nor_path = self.ASSET_NOR.fetch() > + self.boot_linux(f"file={nor_path},{self.NOR_DRIVE}") > + > + def test_spacemit_k3_sd_linux(self): > + sd_path = self.ASSET_SD.fetch() > + self.boot_linux(f"file={sd_path},{self.SD_DRIVE}") > + > + def test_spacemit_k3_nor_ufs(self): > + nor_path = self.ASSET_NOR.fetch() > + self.scan_ufs(f"file={nor_path},{self.NOR_DRIVE}") > + > + def test_spacemit_k3_sd_ufs(self): > + sd_path = self.ASSET_SD.fetch() > + self.scan_ufs(f"file={sd_path},{self.SD_DRIVE}") > + > + > +if __name__ == "__main__": > + QemuSystemTest.main() > > -- > 2.43.0 >