All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chao Liu <chao.liu@processmission.com>
To: Junze Cao <caojunze424@gmail.com>
Cc: qemu-devel@nongnu.org, qemu-riscv@nongnu.org,
	alistair.francis@wdc.com,  th.huth+qemu@posteo.eu
Subject: Re: [PATCH] tests/functional/riscv64: Add K230 Linux boot tests
Date: Mon, 13 Jul 2026 13:09:07 +0800	[thread overview]
Message-ID: <alRyubVpxE1MCoyW@ChaodeMacBook-Pro.local> (raw)
In-Reply-To: <20260711131834.98422-1-caojunze424@gmail.com>

On Sat, Jul 11, 2026 at 09:18:34PM +0800, Junze Cao wrote:
> The K230 machine supports direct Linux boot and firmware boot through
> the SDK U-Boot, but neither path has functional test coverage.
> 
> Add one test for each boot path. Both tests use the Yocto initramfs
> assets and wait for the shell prompt to confirm a successful boot.
> 
> Fetch the boot assets from the k230-boot-assets repository maintained
> by Chao Liu. Pin the URLs to a repository commit and verify each asset
> with its SHA-256 digest.
> 
> Signed-off-by: Junze Cao <caojunze424@gmail.com>
Reviewed-by: Chao Liu <chao.liu@processmission.com>

Thanks,
Chao
> ---
>  MAINTAINERS                           |   1 +
>  tests/functional/riscv64/meson.build  |   2 +
>  tests/functional/riscv64/test_k230.py | 108 ++++++++++++++++++++++++++
>  3 files changed, 111 insertions(+)
>  create mode 100755 tests/functional/riscv64/test_k230.py
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 6171cc7494..fcf87609cb 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1828,6 +1828,7 @@ F: hw/riscv/k230.c
>  F: hw/watchdog/k230_wdt.c
>  F: include/hw/riscv/k230.h
>  F: include/hw/watchdog/k230_wdt.h
> +F: tests/functional/riscv64/test_k230.py
>  F: tests/qtest/k230-wdt-test.c
>  
>  RX Machines
> diff --git a/tests/functional/riscv64/meson.build b/tests/functional/riscv64/meson.build
> index c9d4c090fb..d1a3e6c2bf 100644
> --- a/tests/functional/riscv64/meson.build
> +++ b/tests/functional/riscv64/meson.build
> @@ -2,6 +2,7 @@
>  
>  test_riscv64_timeouts = {
>    'boston' : 120,
> +  'k230' : 120,
>    'tuxrun' : 120,
>  }
>  
> @@ -13,6 +14,7 @@ tests_riscv64_system_quick = [
>  tests_riscv64_system_thorough = [
>    'endianness',
>    'boston',
> +  'k230',
>    'sifive_u',
>    'tt_atlantis',
>    'tuxrun',
> diff --git a/tests/functional/riscv64/test_k230.py b/tests/functional/riscv64/test_k230.py
> new file mode 100755
> index 0000000000..6ccbf2d581
> --- /dev/null
> +++ b/tests/functional/riscv64/test_k230.py
> @@ -0,0 +1,108 @@
> +#!/usr/bin/env python3
> +#
> +# Functional tests that boot Linux on a Kendryte K230 machine.
> +#
> +# The direct boot test lets QEMU load OpenSBI, Linux, the device tree, and the
> +# initramfs.  The firmware boot test starts the K230 SDK U-Boot and uses bootm
> +# to launch OpenSBI and Linux from images preloaded into RAM.
> +#
> +# Author:
> +#  Junze Cao
> +#
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +
> +import os
> +
> +from qemu_test import Asset, LinuxKernelTest
> +from qemu_test import exec_command_and_wait_for_pattern
> +from qemu_test import interrupt_interactive_console_until_pattern
> +
> +
> +class K230Machine(LinuxKernelTest):
> +
> +    ASSET_KERNEL = Asset(
> +        ('https://raw.githubusercontent.com/zevorn/k230-boot-assets/'
> +         'c3c32fb46e8307c5063f13e8f367c98bf9273cd1/'
> +         'yocto/direct-boot/Image'),
> +        '3a44970213fa68ad318d308518adfc0bf4bee72ed1b2926f9b468f82ef7d7829')
> +    ASSET_DTB = Asset(
> +        ('https://raw.githubusercontent.com/zevorn/k230-boot-assets/'
> +         'c3c32fb46e8307c5063f13e8f367c98bf9273cd1/'
> +         'yocto/direct-boot/k230-canmv.dtb'),
> +        '5050240b48ce0988c73eaefa73e4945a40abca503cf488d22a3adf6ef50bbe4c')
> +    ASSET_INITRD = Asset(
> +        ('https://raw.githubusercontent.com/zevorn/k230-boot-assets/'
> +         'c3c32fb46e8307c5063f13e8f367c98bf9273cd1/'
> +         'yocto/direct-boot/rootfs.cpio.gz'),
> +        '4e1869a99a232ee60324f71f3a9e84a79b03ccabb5b73f8a727c5ff5be5c0914')
> +    ASSET_UBOOT = Asset(
> +        ('https://raw.githubusercontent.com/zevorn/k230-boot-assets/'
> +         'c3c32fb46e8307c5063f13e8f367c98bf9273cd1/common/u-boot'),
> +        '0915b9a92a7c911846a8cf691866ef14ef050a51d04209f884ae8e9ec33f36d2')
> +    ASSET_FW_JUMP = Asset(
> +        ('https://raw.githubusercontent.com/zevorn/k230-boot-assets/'
> +         'c3c32fb46e8307c5063f13e8f367c98bf9273cd1/'
> +         'common/fw_jump.uImage'),
> +        'cf7788e470f1d6e8c85491ecdc2705518db1b6af54080e8c7a3464bad0d902b7')
> +
> +    def wait_for_linux_shell(self):
> +        self.wait_for_console_pattern('meta-k230 initramfs starting...')
> +        self.wait_for_console_pattern('~ #')
> +
> +    def test_k230_direct_boot(self):
> +        self.set_machine('k230')
> +        kernel_path = self.ASSET_KERNEL.fetch()
> +        dtb_path = self.ASSET_DTB.fetch()
> +        initrd_path = self.ASSET_INITRD.fetch()
> +
> +        self.vm.set_console()
> +        self.vm.add_args('-kernel', kernel_path,
> +                         '-dtb', dtb_path,
> +                         '-initrd', initrd_path,
> +                         '-append', 'console=ttyS0,115200 earlycon=sbi',
> +                         '-no-reboot')
> +        self.vm.launch()
> +        self.wait_for_linux_shell()
> +
> +    def test_k230_uboot_boot(self):
> +        self.set_machine('k230')
> +        kernel_path = self.ASSET_KERNEL.fetch()
> +        dtb_path = self.ASSET_DTB.fetch()
> +        initrd_path = self.ASSET_INITRD.fetch()
> +        uboot_path = self.ASSET_UBOOT.fetch()
> +        fw_jump_path = self.ASSET_FW_JUMP.fetch()
> +        initrd_end = 0x0a100000 + os.path.getsize(initrd_path)
> +
> +        self.vm.set_console()
> +        self.vm.add_args(
> +            '-bios', uboot_path,
> +            '-device',
> +            f'loader,file={fw_jump_path},addr=0xc100000,force-raw=on',
> +            '-device',
> +            f'loader,file={kernel_path},addr=0x8200000,force-raw=on',
> +            '-device',
> +            f'loader,file={initrd_path},addr=0xa100000,force-raw=on',
> +            '-device',
> +            f'loader,file={dtb_path},addr=0xa000000,force-raw=on',
> +            '-no-reboot')
> +        self.vm.launch()
> +
> +        interrupt_interactive_console_until_pattern(self, 'K230#')
> +        commands = (
> +            'setenv bootargs console=ttyS0,115200 earlycon=sbi',
> +            'fdt addr 0xa000000',
> +            'fdt resize 8192',
> +            'fdt set /chosen linux,initrd-start <0x0 0xa100000>',
> +            f'fdt set /chosen linux,initrd-end <0x0 0x{initrd_end:x}>',
> +        )
> +        for command in commands:
> +            exec_command_and_wait_for_pattern(self, command, 'K230#')
> +
> +        exec_command_and_wait_for_pattern(
> +            self, 'bootm 0xc100000 - 0xa000000',
> +            'Starting kernel ...', failure_message='ERROR')
> +        self.wait_for_linux_shell()
> +
> +
> +if __name__ == '__main__':
> +    LinuxKernelTest.main()
> -- 
> 2.53.0
> 


       reply	other threads:[~2026-07-13  5:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260711131834.98422-1-caojunze424@gmail.com>
2026-07-13  5:09 ` Chao Liu [this message]
2026-07-11 12:53 [PATCH] tests/functional/riscv64: Add K230 Linux boot tests Junze Cao
2026-07-13  1:06 ` Alistair Francis

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=alRyubVpxE1MCoyW@ChaodeMacBook-Pro.local \
    --to=chao.liu@processmission.com \
    --cc=alistair.francis@wdc.com \
    --cc=caojunze424@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=th.huth+qemu@posteo.eu \
    /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.