1#!/usr/bin/env python3 2# 3# Functional test that boots the ASPEED SoCs with firmware 4# 5# Copyright (C) 2022 ASPEED Technology Inc 6# 7# SPDX-License-Identifier: GPL-2.0-or-later 8 9import os 10 11from qemu_test import LinuxKernelTest, Asset 12from qemu_test import exec_command_and_wait_for_pattern 13from zipfile import ZipFile 14 15class AST1030Machine(LinuxKernelTest): 16 17 ASSET_ZEPHYR_1_04 = Asset( 18 ('https://github.com/AspeedTech-BMC' 19 '/zephyr/releases/download/v00.01.04/ast1030-evb-demo.zip'), 20 '4ac6210adcbc61294927918707c6762483fd844dde5e07f3ba834ad1f91434d3') 21 22 def test_ast1030_zephyros_1_04(self): 23 self.set_machine('ast1030-evb') 24 25 zip_file = self.ASSET_ZEPHYR_1_04.fetch() 26 27 kernel_name = "ast1030-evb-demo/zephyr.elf" 28 with ZipFile(zip_file, 'r') as zf: 29 zf.extract(kernel_name, path=self.workdir) 30 kernel_file = os.path.join(self.workdir, kernel_name) 31 32 self.vm.set_console() 33 self.vm.add_args('-kernel', kernel_file, '-nographic') 34 self.vm.launch() 35 self.wait_for_console_pattern("Booting Zephyr OS") 36 exec_command_and_wait_for_pattern(self, "help", 37 "Available commands") 38 39 ASSET_ZEPHYR_1_07 = Asset( 40 ('https://github.com/AspeedTech-BMC' 41 '/zephyr/releases/download/v00.01.07/ast1030-evb-demo.zip'), 42 'ad52e27959746988afaed8429bf4e12ab988c05c4d07c9d90e13ec6f7be4574c') 43 44 def test_ast1030_zephyros_1_07(self): 45 self.set_machine('ast1030-evb') 46 47 zip_file = self.ASSET_ZEPHYR_1_07.fetch() 48 49 kernel_name = "ast1030-evb-demo/zephyr.bin" 50 with ZipFile(zip_file, 'r') as zf: 51 zf.extract(kernel_name, path=self.workdir) 52 kernel_file = os.path.join(self.workdir, kernel_name) 53 54 self.vm.set_console() 55 self.vm.add_args('-kernel', kernel_file, '-nographic') 56 self.vm.launch() 57 self.wait_for_console_pattern("Booting Zephyr OS") 58 for shell_cmd in [ 59 'kernel stacks', 60 'otp info conf', 61 'otp info scu', 62 'hwinfo devid', 63 'crypto aes256_cbc_vault', 64 'random get', 65 'jtag JTAG1 sw_xfer high TMS', 66 'adc ADC0 resolution 12', 67 'adc ADC0 read 42', 68 'adc ADC1 read 69', 69 'i2c scan I2C_0', 70 'i3c attach I3C_0', 71 'hash test', 72 'kernel uptime', 73 'kernel reboot warm', 74 'kernel uptime', 75 'kernel reboot cold', 76 'kernel uptime', 77 ]: exec_command_and_wait_for_pattern(self, shell_cmd, "uart:~$") 78 79 80if __name__ == '__main__': 81 LinuxKernelTest.main() 82