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