All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Milan P. Stanić" <mps@arvanta.net>
To: Anirudh Srinivasan <asrinivasan@oss.tenstorrent.com>
Cc: qemu-devel@nongnu.org, Palmer Dabbelt <palmer@dabbelt.com>,
	Alistair Francis <alistair.francis@wdc.com>,
	Weiwei Li <liwei1518@gmail.com>,
	Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>,
	Liu Zhiwei <zhiwei_liu@linux.alibaba.com>,
	Chao Liu <chao.liu@processmission.com>,
	qemu-riscv@nongnu.org, Jeuk Kim <jeuk20.kim@samsung.com>,
	Alistair Francis <alistair@alistair23.me>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>,
	tgamblin@baylibre.com, w1355457260@gmail.com
Subject: Re: [PATCH v2 9/9] tests/functional/riscv64: Add spacemit-k3 tests
Date: Wed, 2 Dec 2026 16:09:02 +0100	[thread overview]
Message-ID: <20261202150902.GA10491@air> (raw)
In-Reply-To: <20261129-spacemit_k3-v2-9-462c078463e9@oss.tenstorrent.com>

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 <asrinivasan@oss.tenstorrent.com>

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ć <mps@arvanta.net>

> ---
>  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 <joel@jms.id.au>
> 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
> 


  reply	other threads:[~2026-12-02 15:09 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29 17:09 [PATCH v2 0/9] Add Spacemit K3 Machine Anirudh Srinivasan
2026-11-29 17:09 ` [PATCH v2 1/9] target/riscv: Add Spacemit X100 CPU type Anirudh Srinivasan
2026-11-29 17:09 ` [PATCH v2 2/9] hw/ufs: Add Spacemit K3 UFS controller Anirudh Srinivasan
2026-11-30  7:18   ` Jeuk Kim
2026-12-01  9:30   ` Zixin Wang
2026-11-29 17:09 ` [PATCH v2 3/9] hw/ssi: Add Spacemit K3 SPI controller Anirudh Srinivasan
2026-11-29 17:09 ` [PATCH v2 4/9] hw/misc: Add a model for Spacemit K3 syscons Anirudh Srinivasan
2026-11-29 17:09 ` [PATCH v2 5/9] riscv: Add Spacemit K3 machine Anirudh Srinivasan
2026-11-29 17:09 ` [PATCH v2 6/9] hw/riscv/spacemit-k3: Load next stage from boot media if bootrom is not supplied Anirudh Srinivasan
2026-11-29 17:09 ` [PATCH v2 7/9] hw/riscv/spacemit-k3: SMP support for Spacemit K3 machine Anirudh Srinivasan
2026-12-01  9:29   ` Zixin Wang
2026-11-29 17:09 ` [PATCH v2 8/9] docs: Document spacemit-k3 machine Anirudh Srinivasan
2026-11-29 17:09 ` [PATCH v2 9/9] tests/functional/riscv64: Add spacemit-k3 tests Anirudh Srinivasan
2026-12-02 15:09   ` Milan P. Stanić [this message]
2026-12-01  9:29 ` [PATCH v2 0/9] Add Spacemit K3 Machine Zixin Wang
2026-12-01 15:06   ` Anirudh Srinivasan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261202150902.GA10491@air \
    --to=mps@arvanta.net \
    --cc=alistair.francis@wdc.com \
    --cc=alistair@alistair23.me \
    --cc=asrinivasan@oss.tenstorrent.com \
    --cc=chao.liu@processmission.com \
    --cc=daniel.barboza@oss.qualcomm.com \
    --cc=jeuk20.kim@samsung.com \
    --cc=liwei1518@gmail.com \
    --cc=palmer@dabbelt.com \
    --cc=pbonzini@redhat.com \
    --cc=pierrick.bouvier@oss.qualcomm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=tgamblin@baylibre.com \
    --cc=w1355457260@gmail.com \
    --cc=zhiwei_liu@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.