diff --git a/MAINTAINERS b/MAINTAINERS index 0be68396e9..ecb8cfdc41 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1760,8 +1760,10 @@ F: target/riscv/xlrbr.decode F: tests/tcg/riscv64/test-crc32.S Microchip PolarFire SoC Icicle Kit +M: Conor Dooley +M: Sebastian Huber L: qemu-riscv@nongnu.org -S: Supported +S: Odd Fixes F: docs/system/riscv/microchip-icicle-kit.rst F: hw/riscv/microchip_pfsoc.c F: hw/char/mchp_pfsoc_mmuart.c @@ -1828,6 +1830,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() diff --git a/tests/functional/riscv64/test_sifive_u.py b/tests/functional/riscv64/test_sifive_u.py index 847f709da1..54a0f9c648 100755 --- a/tests/functional/riscv64/test_sifive_u.py +++ b/tests/functional/riscv64/test_sifive_u.py @@ -35,9 +35,6 @@ def do_test_riscv64_sifive_u_mmc_spi(self, connect_card): kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + 'earlycon=sbi console=ttySIF0 ' 'root=/dev/mmcblk0 ') - self.vm.add_args('-kernel', kernel_path, - '-append', kernel_command_line, - '-no-reboot') if connect_card: kernel_command_line += 'panic=-1 noreboot rootwait ' self.vm.add_args('-drive', f'file={rootfs_path},if=sd,format=raw') @@ -46,6 +43,9 @@ def do_test_riscv64_sifive_u_mmc_spi(self, connect_card): kernel_command_line += 'panic=0 noreboot ' pattern = 'Cannot open root device "mmcblk0" or unknown-block(0,0)' + self.vm.add_args('-kernel', kernel_path, + '-append', kernel_command_line, + '-no-reboot') self.vm.launch() self.wait_for_console_pattern(pattern)