1438eff63SJamin Lin# Functional test that boots the ASPEED SoCs with firmware 2438eff63SJamin Lin# 3438eff63SJamin Lin# Copyright (C) 2022 ASPEED Technology Inc 4438eff63SJamin Lin# 5438eff63SJamin Lin# This work is licensed under the terms of the GNU GPL, version 2 or 6438eff63SJamin Lin# later. See the COPYING file in the top-level directory. 7438eff63SJamin Lin 8438eff63SJamin Linfrom avocado_qemu import QemuSystemTest 9438eff63SJamin Linfrom avocado_qemu import wait_for_console_pattern 10438eff63SJamin Linfrom avocado_qemu import exec_command_and_wait_for_pattern 11438eff63SJamin Linfrom avocado.utils import archive 12438eff63SJamin Lin 13438eff63SJamin Lin 14438eff63SJamin Linclass AST1030Machine(QemuSystemTest): 15438eff63SJamin Lin """Boots the zephyr os and checks that the console is operational""" 16438eff63SJamin Lin 17438eff63SJamin Lin timeout = 10 18438eff63SJamin Lin 19438eff63SJamin Lin def test_ast1030_zephyros(self): 20438eff63SJamin Lin """ 21438eff63SJamin Lin :avocado: tags=arch:arm 22438eff63SJamin Lin :avocado: tags=machine:ast1030-evb 23438eff63SJamin Lin """ 24438eff63SJamin Lin tar_url = ('https://github.com/AspeedTech-BMC' 25438eff63SJamin Lin '/zephyr/releases/download/v00.01.04/ast1030-evb-demo.zip') 26438eff63SJamin Lin tar_hash = '4c6a8ce3a8ba76ef1a65dae419ae3409343c4b20' 27438eff63SJamin Lin tar_path = self.fetch_asset(tar_url, asset_hash=tar_hash) 28438eff63SJamin Lin archive.extract(tar_path, self.workdir) 29438eff63SJamin Lin kernel_file = self.workdir + "/ast1030-evb-demo/zephyr.elf" 30438eff63SJamin Lin self.vm.set_console() 31438eff63SJamin Lin self.vm.add_args('-kernel', kernel_file, 32438eff63SJamin Lin '-nographic') 33438eff63SJamin Lin self.vm.launch() 34438eff63SJamin Lin wait_for_console_pattern(self, "Booting Zephyr OS") 35438eff63SJamin Lin exec_command_and_wait_for_pattern(self, "help", 36438eff63SJamin Lin "Available commands") 37*341e21faSCédric Le Goater 38*341e21faSCédric Le Goaterclass AST2x00Machine(QemuSystemTest): 39*341e21faSCédric Le Goater 40*341e21faSCédric Le Goater def wait_for_console_pattern(self, success_message, vm=None): 41*341e21faSCédric Le Goater wait_for_console_pattern(self, success_message, 42*341e21faSCédric Le Goater failure_message='Kernel panic - not syncing', 43*341e21faSCédric Le Goater vm=vm) 44*341e21faSCédric Le Goater 45*341e21faSCédric Le Goater def do_test_arm_aspeed(self, image): 46*341e21faSCédric Le Goater self.vm.set_console() 47*341e21faSCédric Le Goater self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw', 48*341e21faSCédric Le Goater '-net', 'nic') 49*341e21faSCédric Le Goater self.vm.launch() 50*341e21faSCédric Le Goater 51*341e21faSCédric Le Goater self.wait_for_console_pattern("U-Boot 2016.07") 52*341e21faSCédric Le Goater self.wait_for_console_pattern("## Loading kernel from FIT Image at 20080000") 53*341e21faSCédric Le Goater self.wait_for_console_pattern("Starting kernel ...") 54*341e21faSCédric Le Goater self.wait_for_console_pattern("Booting Linux on physical CPU 0x0") 55*341e21faSCédric Le Goater wait_for_console_pattern(self, 56*341e21faSCédric Le Goater "aspeed-smc 1e620000.spi: read control register: 203b0641") 57*341e21faSCédric Le Goater self.wait_for_console_pattern("ftgmac100 1e660000.ethernet eth0: irq ") 58*341e21faSCédric Le Goater self.wait_for_console_pattern("systemd[1]: Set hostname to") 59*341e21faSCédric Le Goater 60*341e21faSCédric Le Goater def test_arm_ast2400_palmetto_openbmc_v2_9_0(self): 61*341e21faSCédric Le Goater """ 62*341e21faSCédric Le Goater :avocado: tags=arch:arm 63*341e21faSCédric Le Goater :avocado: tags=machine:palmetto-bmc 64*341e21faSCédric Le Goater """ 65*341e21faSCédric Le Goater 66*341e21faSCédric Le Goater image_url = ('https://github.com/openbmc/openbmc/releases/download/2.9.0/' 67*341e21faSCédric Le Goater 'obmc-phosphor-image-palmetto.static.mtd') 68*341e21faSCédric Le Goater image_hash = ('3e13bbbc28e424865dc42f35ad672b10f2e82cdb11846bb28fa625b48beafd0d') 69*341e21faSCédric Le Goater image_path = self.fetch_asset(image_url, asset_hash=image_hash, 70*341e21faSCédric Le Goater algorithm='sha256') 71*341e21faSCédric Le Goater 72*341e21faSCédric Le Goater self.do_test_arm_aspeed(image_path) 73*341e21faSCédric Le Goater 74*341e21faSCédric Le Goater def test_arm_ast2500_romulus_openbmc_v2_9_0(self): 75*341e21faSCédric Le Goater """ 76*341e21faSCédric Le Goater :avocado: tags=arch:arm 77*341e21faSCédric Le Goater :avocado: tags=machine:romulus-bmc 78*341e21faSCédric Le Goater """ 79*341e21faSCédric Le Goater 80*341e21faSCédric Le Goater image_url = ('https://github.com/openbmc/openbmc/releases/download/2.9.0/' 81*341e21faSCédric Le Goater 'obmc-phosphor-image-romulus.static.mtd') 82*341e21faSCédric Le Goater image_hash = ('820341076803f1955bc31e647a512c79f9add4f5233d0697678bab4604c7bb25') 83*341e21faSCédric Le Goater image_path = self.fetch_asset(image_url, asset_hash=image_hash, 84*341e21faSCédric Le Goater algorithm='sha256') 85*341e21faSCédric Le Goater 86*341e21faSCédric Le Goater self.do_test_arm_aspeed(image_path) 87