master
py 62 lines 1.99 KB
Raw
1 #!/usr/bin/env python3
2 #
3 # Functional test that boots a Linux kernel on a Sifive U machine
4 # and checks the console
5 #
6 # Copyright (c) Linaro Ltd.
7 #
8 # Author:
9 # Philippe Mathieu-Daudé
10 #
11 # SPDX-License-Identifier: GPL-2.0-or-later
12
13 import os
14
15 from qemu_test import Asset, LinuxKernelTest
16
17
18 class SifiveU(LinuxKernelTest):
19
20 ASSET_KERNEL = Asset(
21 'https://storage.tuxboot.com/buildroot/20241119/riscv64/Image',
22 '2bd8132a3bf21570290042324fff48c987f42f2a00c08de979f43f0662ebadba')
23 ASSET_ROOTFS = Asset(
24 ('https://github.com/groeck/linux-build-test/raw/'
25 '9819da19e6eef291686fdd7b029ea00e764dc62f/rootfs/riscv64/'
26 'rootfs.ext2.gz'),
27 'b6ed95610310b7956f9bf20c4c9c0c05fea647900df441da9dfe767d24e8b28b')
28
29 def do_test_riscv64_sifive_u_mmc_spi(self, connect_card):
30 self.set_machine('sifive_u')
31 kernel_path = self.ASSET_KERNEL.fetch()
32 rootfs_path = self.uncompress(self.ASSET_ROOTFS)
33
34 self.vm.set_console()
35 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
36 'earlycon=sbi console=ttySIF0 '
37 'root=/dev/mmcblk0 ')
38 if connect_card:
39 kernel_command_line += 'panic=-1 noreboot rootwait '
40 self.vm.add_args('-drive', f'file={rootfs_path},if=sd,format=raw')
41 pattern = 'Boot successful.'
42 else:
43 kernel_command_line += 'panic=0 noreboot '
44 pattern = 'Cannot open root device "mmcblk0" or unknown-block(0,0)'
45
46 self.vm.add_args('-kernel', kernel_path,
47 '-append', kernel_command_line,
48 '-no-reboot')
49 self.vm.launch()
50 self.wait_for_console_pattern(pattern)
51
52 os.remove(rootfs_path)
53
54 def test_riscv64_sifive_u_nommc_spi(self):
55 self.do_test_riscv64_sifive_u_mmc_spi(False)
56
57 def test_riscv64_sifive_u_mmc_spi(self):
58 self.do_test_riscv64_sifive_u_mmc_spi(True)
59
60
61 if __name__ == '__main__':
62 LinuxKernelTest.main()