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 8f7bc7da0SCédric Le Goaterimport time 992f8e8e2SAlex Bennéeimport os 10c3d58a7aSJoel Stanleyimport tempfile 11c3d58a7aSJoel Stanleyimport subprocess 12f7bc7da0SCédric Le Goater 13dd562bbfSThomas Huthfrom avocado_qemu import LinuxSSHMixIn 14438eff63SJamin Linfrom avocado_qemu import QemuSystemTest 15438eff63SJamin Linfrom avocado_qemu import wait_for_console_pattern 16f7bc7da0SCédric Le Goaterfrom avocado_qemu import exec_command 17438eff63SJamin Linfrom avocado_qemu import exec_command_and_wait_for_pattern 18a4b14b46SCédric Le Goaterfrom avocado_qemu import interrupt_interactive_console_until_pattern 19c3d58a7aSJoel Stanleyfrom avocado_qemu import has_cmd 20438eff63SJamin Linfrom avocado.utils import archive 21*9b45cc99SAlex Bennéefrom avocado import skipUnless 22c3d58a7aSJoel Stanleyfrom avocado import skipUnless 23438eff63SJamin Lin 24438eff63SJamin Lin 25438eff63SJamin Linclass AST1030Machine(QemuSystemTest): 26438eff63SJamin Lin """Boots the zephyr os and checks that the console is operational""" 27438eff63SJamin Lin 28438eff63SJamin Lin timeout = 10 29438eff63SJamin Lin 3044055caaSPhilippe Mathieu-Daudé def test_ast1030_zephyros_1_04(self): 31438eff63SJamin Lin """ 32438eff63SJamin Lin :avocado: tags=arch:arm 33438eff63SJamin Lin :avocado: tags=machine:ast1030-evb 3444055caaSPhilippe Mathieu-Daudé :avocado: tags=os:zephyr 35438eff63SJamin Lin """ 36438eff63SJamin Lin tar_url = ('https://github.com/AspeedTech-BMC' 37438eff63SJamin Lin '/zephyr/releases/download/v00.01.04/ast1030-evb-demo.zip') 38438eff63SJamin Lin tar_hash = '4c6a8ce3a8ba76ef1a65dae419ae3409343c4b20' 39438eff63SJamin Lin tar_path = self.fetch_asset(tar_url, asset_hash=tar_hash) 40438eff63SJamin Lin archive.extract(tar_path, self.workdir) 41438eff63SJamin Lin kernel_file = self.workdir + "/ast1030-evb-demo/zephyr.elf" 42438eff63SJamin Lin self.vm.set_console() 43438eff63SJamin Lin self.vm.add_args('-kernel', kernel_file, 44438eff63SJamin Lin '-nographic') 45438eff63SJamin Lin self.vm.launch() 46438eff63SJamin Lin wait_for_console_pattern(self, "Booting Zephyr OS") 47438eff63SJamin Lin exec_command_and_wait_for_pattern(self, "help", 48438eff63SJamin Lin "Available commands") 49341e21faSCédric Le Goater 5044055caaSPhilippe Mathieu-Daudé def test_ast1030_zephyros_1_07(self): 5144055caaSPhilippe Mathieu-Daudé """ 5244055caaSPhilippe Mathieu-Daudé :avocado: tags=arch:arm 5344055caaSPhilippe Mathieu-Daudé :avocado: tags=machine:ast1030-evb 5444055caaSPhilippe Mathieu-Daudé :avocado: tags=os:zephyr 5544055caaSPhilippe Mathieu-Daudé """ 5644055caaSPhilippe Mathieu-Daudé tar_url = ('https://github.com/AspeedTech-BMC' 5744055caaSPhilippe Mathieu-Daudé '/zephyr/releases/download/v00.01.07/ast1030-evb-demo.zip') 5844055caaSPhilippe Mathieu-Daudé tar_hash = '40ac87eabdcd3b3454ce5aad11fedc72a33ecda2' 5944055caaSPhilippe Mathieu-Daudé tar_path = self.fetch_asset(tar_url, asset_hash=tar_hash) 6044055caaSPhilippe Mathieu-Daudé archive.extract(tar_path, self.workdir) 6144055caaSPhilippe Mathieu-Daudé kernel_file = self.workdir + "/ast1030-evb-demo/zephyr.bin" 6244055caaSPhilippe Mathieu-Daudé self.vm.set_console() 6344055caaSPhilippe Mathieu-Daudé self.vm.add_args('-kernel', kernel_file, 6444055caaSPhilippe Mathieu-Daudé '-nographic') 6544055caaSPhilippe Mathieu-Daudé self.vm.launch() 6644055caaSPhilippe Mathieu-Daudé wait_for_console_pattern(self, "Booting Zephyr OS") 6744055caaSPhilippe Mathieu-Daudé for shell_cmd in [ 6844055caaSPhilippe Mathieu-Daudé 'kernel stacks', 6944055caaSPhilippe Mathieu-Daudé 'otp info conf', 7044055caaSPhilippe Mathieu-Daudé 'otp info scu', 7144055caaSPhilippe Mathieu-Daudé 'hwinfo devid', 7244055caaSPhilippe Mathieu-Daudé 'crypto aes256_cbc_vault', 7344055caaSPhilippe Mathieu-Daudé 'random get', 7444055caaSPhilippe Mathieu-Daudé 'jtag JTAG1 sw_xfer high TMS', 7544055caaSPhilippe Mathieu-Daudé 'adc ADC0 resolution 12', 7644055caaSPhilippe Mathieu-Daudé 'adc ADC0 read 42', 7744055caaSPhilippe Mathieu-Daudé 'adc ADC1 read 69', 7844055caaSPhilippe Mathieu-Daudé 'i2c scan I2C_0', 7944055caaSPhilippe Mathieu-Daudé 'i3c attach I3C_0', 8044055caaSPhilippe Mathieu-Daudé 'hash test', 8144055caaSPhilippe Mathieu-Daudé 'kernel uptime', 8244055caaSPhilippe Mathieu-Daudé 'kernel reboot warm', 8344055caaSPhilippe Mathieu-Daudé 'kernel uptime', 8444055caaSPhilippe Mathieu-Daudé 'kernel reboot cold', 8544055caaSPhilippe Mathieu-Daudé 'kernel uptime', 8644055caaSPhilippe Mathieu-Daudé ]: exec_command_and_wait_for_pattern(self, shell_cmd, "uart:~$") 8744055caaSPhilippe Mathieu-Daudé 88341e21faSCédric Le Goaterclass AST2x00Machine(QemuSystemTest): 89341e21faSCédric Le Goater 90b1ceae2fSAlex Bennée timeout = 90 91b1ceae2fSAlex Bennée 92341e21faSCédric Le Goater def wait_for_console_pattern(self, success_message, vm=None): 93341e21faSCédric Le Goater wait_for_console_pattern(self, success_message, 94341e21faSCédric Le Goater failure_message='Kernel panic - not syncing', 95341e21faSCédric Le Goater vm=vm) 96341e21faSCédric Le Goater 97341e21faSCédric Le Goater def do_test_arm_aspeed(self, image): 98341e21faSCédric Le Goater self.vm.set_console() 99341e21faSCédric Le Goater self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw', 100341e21faSCédric Le Goater '-net', 'nic') 101341e21faSCédric Le Goater self.vm.launch() 102341e21faSCédric Le Goater 103341e21faSCédric Le Goater self.wait_for_console_pattern("U-Boot 2016.07") 104341e21faSCédric Le Goater self.wait_for_console_pattern("## Loading kernel from FIT Image at 20080000") 105341e21faSCédric Le Goater self.wait_for_console_pattern("Starting kernel ...") 106341e21faSCédric Le Goater self.wait_for_console_pattern("Booting Linux on physical CPU 0x0") 107341e21faSCédric Le Goater wait_for_console_pattern(self, 108341e21faSCédric Le Goater "aspeed-smc 1e620000.spi: read control register: 203b0641") 109341e21faSCédric Le Goater self.wait_for_console_pattern("ftgmac100 1e660000.ethernet eth0: irq ") 110341e21faSCédric Le Goater self.wait_for_console_pattern("systemd[1]: Set hostname to") 111341e21faSCédric Le Goater 112341e21faSCédric Le Goater def test_arm_ast2400_palmetto_openbmc_v2_9_0(self): 113341e21faSCédric Le Goater """ 114341e21faSCédric Le Goater :avocado: tags=arch:arm 115341e21faSCédric Le Goater :avocado: tags=machine:palmetto-bmc 116341e21faSCédric Le Goater """ 117341e21faSCédric Le Goater 118341e21faSCédric Le Goater image_url = ('https://github.com/openbmc/openbmc/releases/download/2.9.0/' 119341e21faSCédric Le Goater 'obmc-phosphor-image-palmetto.static.mtd') 120341e21faSCédric Le Goater image_hash = ('3e13bbbc28e424865dc42f35ad672b10f2e82cdb11846bb28fa625b48beafd0d') 121341e21faSCédric Le Goater image_path = self.fetch_asset(image_url, asset_hash=image_hash, 122341e21faSCédric Le Goater algorithm='sha256') 123341e21faSCédric Le Goater 124341e21faSCédric Le Goater self.do_test_arm_aspeed(image_path) 125341e21faSCédric Le Goater 126341e21faSCédric Le Goater def test_arm_ast2500_romulus_openbmc_v2_9_0(self): 127341e21faSCédric Le Goater """ 128341e21faSCédric Le Goater :avocado: tags=arch:arm 129341e21faSCédric Le Goater :avocado: tags=machine:romulus-bmc 130341e21faSCédric Le Goater """ 131341e21faSCédric Le Goater 132341e21faSCédric Le Goater image_url = ('https://github.com/openbmc/openbmc/releases/download/2.9.0/' 133341e21faSCédric Le Goater 'obmc-phosphor-image-romulus.static.mtd') 134341e21faSCédric Le Goater image_hash = ('820341076803f1955bc31e647a512c79f9add4f5233d0697678bab4604c7bb25') 135341e21faSCédric Le Goater image_path = self.fetch_asset(image_url, asset_hash=image_hash, 136341e21faSCédric Le Goater algorithm='sha256') 137341e21faSCédric Le Goater 138341e21faSCédric Le Goater self.do_test_arm_aspeed(image_path) 139f7bc7da0SCédric Le Goater 140c3d58a7aSJoel Stanley def do_test_arm_aspeed_buildroot_start(self, image, cpu_id, pattern='Aspeed EVB'): 1410793fe01SPeter Maydell self.require_netdev('user') 1420793fe01SPeter Maydell 143f7bc7da0SCédric Le Goater self.vm.set_console() 144f7bc7da0SCédric Le Goater self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw', 145f7bc7da0SCédric Le Goater '-net', 'nic', '-net', 'user') 146f7bc7da0SCédric Le Goater self.vm.launch() 147f7bc7da0SCédric Le Goater 148f7bc7da0SCédric Le Goater self.wait_for_console_pattern('U-Boot 2019.04') 149f7bc7da0SCédric Le Goater self.wait_for_console_pattern('## Loading kernel from FIT Image') 150f7bc7da0SCédric Le Goater self.wait_for_console_pattern('Starting kernel ...') 151f7bc7da0SCédric Le Goater self.wait_for_console_pattern('Booting Linux on physical CPU ' + cpu_id) 152f7bc7da0SCédric Le Goater self.wait_for_console_pattern('lease of 10.0.2.15') 15365711f9aSAlex Bennée # the line before login: 154c3d58a7aSJoel Stanley self.wait_for_console_pattern(pattern) 15565711f9aSAlex Bennée time.sleep(0.1) 156f7bc7da0SCédric Le Goater exec_command(self, 'root') 157f7bc7da0SCédric Le Goater time.sleep(0.1) 158f7bc7da0SCédric Le Goater 1597b5093b8SCédric Le Goater def do_test_arm_aspeed_buildroot_poweroff(self): 160f7bc7da0SCédric Le Goater exec_command_and_wait_for_pattern(self, 'poweroff', 161f7bc7da0SCédric Le Goater 'reboot: System halted'); 162f7bc7da0SCédric Le Goater 1637b5093b8SCédric Le Goater def test_arm_ast2500_evb_buildroot(self): 164f7bc7da0SCédric Le Goater """ 165f7bc7da0SCédric Le Goater :avocado: tags=arch:arm 166f7bc7da0SCédric Le Goater :avocado: tags=machine:ast2500-evb 167f7bc7da0SCédric Le Goater """ 168f7bc7da0SCédric Le Goater 169f7bc7da0SCédric Le Goater image_url = ('https://github.com/legoater/qemu-aspeed-boot/raw/master/' 170ed1f5ff8SCédric Le Goater 'images/ast2500-evb/buildroot-2022.11-2-g15d3648df9/flash.img') 171ed1f5ff8SCédric Le Goater image_hash = ('f96d11db521fe7a2787745e9e391225deeeec3318ee0fc07c8b799b8833dd474') 172f7bc7da0SCédric Le Goater image_path = self.fetch_asset(image_url, asset_hash=image_hash, 173f7bc7da0SCédric Le Goater algorithm='sha256') 174f7bc7da0SCédric Le Goater 1757a7308eaSCédric Le Goater self.vm.add_args('-device', 1767a7308eaSCédric Le Goater 'tmp105,bus=aspeed.i2c.bus.3,address=0x4d,id=tmp-test'); 1777b5093b8SCédric Le Goater self.do_test_arm_aspeed_buildroot_start(image_path, '0x0') 1787a7308eaSCédric Le Goater 1797a7308eaSCédric Le Goater exec_command_and_wait_for_pattern(self, 1807a7308eaSCédric Le Goater 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-3/device/new_device', 1817a7308eaSCédric Le Goater 'i2c i2c-3: new_device: Instantiated device lm75 at 0x4d'); 1827a7308eaSCédric Le Goater exec_command_and_wait_for_pattern(self, 1837a7308eaSCédric Le Goater 'cat /sys/class/hwmon/hwmon1/temp1_input', '0') 184684750abSVladimir Sementsov-Ogievskiy self.vm.cmd('qom-set', path='/machine/peripheral/tmp-test', 1857a7308eaSCédric Le Goater property='temperature', value=18000); 1867a7308eaSCédric Le Goater exec_command_and_wait_for_pattern(self, 1877a7308eaSCédric Le Goater 'cat /sys/class/hwmon/hwmon1/temp1_input', '18000') 1887a7308eaSCédric Le Goater 1897b5093b8SCédric Le Goater self.do_test_arm_aspeed_buildroot_poweroff() 190f7bc7da0SCédric Le Goater 1917b5093b8SCédric Le Goater def test_arm_ast2600_evb_buildroot(self): 192f7bc7da0SCédric Le Goater """ 193f7bc7da0SCédric Le Goater :avocado: tags=arch:arm 194f7bc7da0SCédric Le Goater :avocado: tags=machine:ast2600-evb 195f7bc7da0SCédric Le Goater """ 196f7bc7da0SCédric Le Goater 197f7bc7da0SCédric Le Goater image_url = ('https://github.com/legoater/qemu-aspeed-boot/raw/master/' 198ed1f5ff8SCédric Le Goater 'images/ast2600-evb/buildroot-2022.11-2-g15d3648df9/flash.img') 199ed1f5ff8SCédric Le Goater image_hash = ('e598d86e5ea79671ca8b59212a326c911bc8bea728dec1a1f5390d717a28bb8b') 200f7bc7da0SCédric Le Goater image_path = self.fetch_asset(image_url, asset_hash=image_hash, 201f7bc7da0SCédric Le Goater algorithm='sha256') 202f7bc7da0SCédric Le Goater 20361cf757dSCédric Le Goater self.vm.add_args('-device', 20461cf757dSCédric Le Goater 'tmp105,bus=aspeed.i2c.bus.3,address=0x4d,id=tmp-test'); 2053302184fSCédric Le Goater self.vm.add_args('-device', 2063302184fSCédric Le Goater 'ds1338,bus=aspeed.i2c.bus.3,address=0x32'); 20782e94da5SCédric Le Goater self.vm.add_args('-device', 20882e94da5SCédric Le Goater 'i2c-echo,bus=aspeed.i2c.bus.3,address=0x42'); 2097b5093b8SCédric Le Goater self.do_test_arm_aspeed_buildroot_start(image_path, '0xf00') 21061cf757dSCédric Le Goater 21161cf757dSCédric Le Goater exec_command_and_wait_for_pattern(self, 21261cf757dSCédric Le Goater 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-3/device/new_device', 21361cf757dSCédric Le Goater 'i2c i2c-3: new_device: Instantiated device lm75 at 0x4d'); 21461cf757dSCédric Le Goater exec_command_and_wait_for_pattern(self, 21561cf757dSCédric Le Goater 'cat /sys/class/hwmon/hwmon0/temp1_input', '0') 216684750abSVladimir Sementsov-Ogievskiy self.vm.cmd('qom-set', path='/machine/peripheral/tmp-test', 21761cf757dSCédric Le Goater property='temperature', value=18000); 21861cf757dSCédric Le Goater exec_command_and_wait_for_pattern(self, 21961cf757dSCédric Le Goater 'cat /sys/class/hwmon/hwmon0/temp1_input', '18000') 22061cf757dSCédric Le Goater 2213302184fSCédric Le Goater exec_command_and_wait_for_pattern(self, 2223302184fSCédric Le Goater 'echo ds1307 0x32 > /sys/class/i2c-dev/i2c-3/device/new_device', 2233302184fSCédric Le Goater 'i2c i2c-3: new_device: Instantiated device ds1307 at 0x32'); 2243302184fSCédric Le Goater year = time.strftime("%Y") 2253302184fSCédric Le Goater exec_command_and_wait_for_pattern(self, 'hwclock -f /dev/rtc1', year); 2263302184fSCédric Le Goater 22782e94da5SCédric Le Goater exec_command_and_wait_for_pattern(self, 22882e94da5SCédric Le Goater 'echo slave-24c02 0x1064 > /sys/bus/i2c/devices/i2c-3/new_device', 22982e94da5SCédric Le Goater 'i2c i2c-3: new_device: Instantiated device slave-24c02 at 0x64'); 23082e94da5SCédric Le Goater exec_command(self, 'i2cset -y 3 0x42 0x64 0x00 0xaa i'); 23182e94da5SCédric Le Goater time.sleep(0.1) 23282e94da5SCédric Le Goater exec_command_and_wait_for_pattern(self, 23382e94da5SCédric Le Goater 'hexdump /sys/bus/i2c/devices/3-1064/slave-eeprom', 23482e94da5SCédric Le Goater '0000000 ffaa ffff ffff ffff ffff ffff ffff ffff'); 2357b5093b8SCédric Le Goater self.do_test_arm_aspeed_buildroot_poweroff() 236bceb4d99SCédric Le Goater 237c3d58a7aSJoel Stanley @skipUnless(*has_cmd('swtpm')) 238c3d58a7aSJoel Stanley def test_arm_ast2600_evb_buildroot_tpm(self): 239c3d58a7aSJoel Stanley """ 240c3d58a7aSJoel Stanley :avocado: tags=arch:arm 241c3d58a7aSJoel Stanley :avocado: tags=machine:ast2600-evb 242c3d58a7aSJoel Stanley """ 243c3d58a7aSJoel Stanley 244c3d58a7aSJoel Stanley image_url = ('https://github.com/legoater/qemu-aspeed-boot/raw/master/' 245c3d58a7aSJoel Stanley 'images/ast2600-evb/buildroot-2023.02-tpm/flash.img') 246c3d58a7aSJoel Stanley image_hash = ('a46009ae8a5403a0826d607215e731a8c68d27c14c41e55331706b8f9c7bd997') 247c3d58a7aSJoel Stanley image_path = self.fetch_asset(image_url, asset_hash=image_hash, 248c3d58a7aSJoel Stanley algorithm='sha256') 249c3d58a7aSJoel Stanley 25046d4747aSJohn Snow # force creation of VM object, which also defines self._sd 25146d4747aSJohn Snow vm = self.vm 25246d4747aSJohn Snow 25346d4747aSJohn Snow socket = os.path.join(self._sd.name, 'swtpm-socket') 254c3d58a7aSJoel Stanley 255c3d58a7aSJoel Stanley subprocess.run(['swtpm', 'socket', '-d', '--tpm2', 256c3d58a7aSJoel Stanley '--tpmstate', f'dir={self.vm.temp_dir}', 257c3d58a7aSJoel Stanley '--ctrl', f'type=unixio,path={socket}']) 258c3d58a7aSJoel Stanley 259c3d58a7aSJoel Stanley self.vm.add_args('-chardev', f'socket,id=chrtpm,path={socket}') 260c3d58a7aSJoel Stanley self.vm.add_args('-tpmdev', 'emulator,id=tpm0,chardev=chrtpm') 261c3d58a7aSJoel Stanley self.vm.add_args('-device', 262c3d58a7aSJoel Stanley 'tpm-tis-i2c,tpmdev=tpm0,bus=aspeed.i2c.bus.12,address=0x2e') 263c3d58a7aSJoel Stanley self.do_test_arm_aspeed_buildroot_start(image_path, '0xf00', 'Aspeed AST2600 EVB') 264c3d58a7aSJoel Stanley exec_command(self, "passw0rd") 265c3d58a7aSJoel Stanley 266c3d58a7aSJoel Stanley exec_command_and_wait_for_pattern(self, 267c3d58a7aSJoel Stanley 'echo tpm_tis_i2c 0x2e > /sys/bus/i2c/devices/i2c-12/new_device', 268c3d58a7aSJoel Stanley 'tpm_tis_i2c 12-002e: 2.0 TPM (device-id 0x1, rev-id 1)'); 269c3d58a7aSJoel Stanley exec_command_and_wait_for_pattern(self, 270c3d58a7aSJoel Stanley 'cat /sys/class/tpm/tpm0/pcr-sha256/0', 271c3d58a7aSJoel Stanley 'B804724EA13F52A9072BA87FE8FDCC497DFC9DF9AA15B9088694639C431688E0'); 272c3d58a7aSJoel Stanley 273c3d58a7aSJoel Stanley self.do_test_arm_aspeed_buildroot_poweroff() 274bceb4d99SCédric Le Goater 275dd562bbfSThomas Huthclass AST2x00MachineSDK(QemuSystemTest, LinuxSSHMixIn): 27692f8e8e2SAlex Bennée 27730d7aac4SCédric Le Goater EXTRA_BOOTARGS = ( 27830d7aac4SCédric Le Goater 'quiet ' 27930d7aac4SCédric Le Goater 'systemd.mask=org.openbmc.HostIpmi.service ' 28030d7aac4SCédric Le Goater 'systemd.mask=xyz.openbmc_project.Chassis.Control.Power@0.service ' 28130d7aac4SCédric Le Goater 'systemd.mask=modprobe@fuse.service ' 28230d7aac4SCédric Le Goater 'systemd.mask=rngd.service ' 28330d7aac4SCédric Le Goater 'systemd.mask=obmc-console@ttyS2.service ' 28430d7aac4SCédric Le Goater ) 285a4b14b46SCédric Le Goater 28692f8e8e2SAlex Bennée # FIXME: Although these tests boot a whole distro they are still 28792f8e8e2SAlex Bennée # slower than comparable machine models. There may be some 28892f8e8e2SAlex Bennée # optimisations which bring down the runtime. In the meantime they 28992f8e8e2SAlex Bennée # have generous timeouts and are disable for CI which aims for all 29092f8e8e2SAlex Bennée # tests to run in less than 60 seconds. 29192f8e8e2SAlex Bennée timeout = 240 29292f8e8e2SAlex Bennée 29392f8e8e2SAlex Bennée def wait_for_console_pattern(self, success_message, vm=None): 29492f8e8e2SAlex Bennée wait_for_console_pattern(self, success_message, 29592f8e8e2SAlex Bennée failure_message='Kernel panic - not syncing', 29692f8e8e2SAlex Bennée vm=vm) 29792f8e8e2SAlex Bennée 298a4b14b46SCédric Le Goater def do_test_arm_aspeed_sdk_start(self, image): 2990793fe01SPeter Maydell self.require_netdev('user') 300bceb4d99SCédric Le Goater self.vm.set_console() 301bceb4d99SCédric Le Goater self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw', 302dd562bbfSThomas Huth '-net', 'nic', '-net', 'user,hostfwd=:127.0.0.1:0-:22') 303bceb4d99SCédric Le Goater self.vm.launch() 304bceb4d99SCédric Le Goater 305bceb4d99SCédric Le Goater self.wait_for_console_pattern('U-Boot 2019.04') 306a4b14b46SCédric Le Goater interrupt_interactive_console_until_pattern( 307a4b14b46SCédric Le Goater self, 'Hit any key to stop autoboot:', 'ast#') 308a4b14b46SCédric Le Goater exec_command_and_wait_for_pattern( 309a4b14b46SCédric Le Goater self, 'setenv bootargs ${bootargs} ' + self.EXTRA_BOOTARGS, 'ast#') 310a4b14b46SCédric Le Goater exec_command_and_wait_for_pattern( 311a4b14b46SCédric Le Goater self, 'boot', '## Loading kernel from FIT Image') 312bceb4d99SCédric Le Goater self.wait_for_console_pattern('Starting kernel ...') 313bceb4d99SCédric Le Goater 314*9b45cc99SAlex Bennée @skipUnless(os.getenv('QEMU_TEST_FLAKY_TESTS'), 'Test is unstable on GitLab') 315*9b45cc99SAlex Bennée 316bceb4d99SCédric Le Goater def test_arm_ast2500_evb_sdk(self): 317bceb4d99SCédric Le Goater """ 318bceb4d99SCédric Le Goater :avocado: tags=arch:arm 319bceb4d99SCédric Le Goater :avocado: tags=machine:ast2500-evb 320bceb4d99SCédric Le Goater """ 321bceb4d99SCédric Le Goater 322bceb4d99SCédric Le Goater image_url = ('https://github.com/AspeedTech-BMC/openbmc/releases/' 3239bf9865cSCédric Le Goater 'download/v08.06/ast2500-default-obmc.tar.gz') 3249bf9865cSCédric Le Goater image_hash = ('e1755f3cadff69190438c688d52dd0f0d399b70a1e14b1d3d5540fc4851d38ca') 325bceb4d99SCédric Le Goater image_path = self.fetch_asset(image_url, asset_hash=image_hash, 326bceb4d99SCédric Le Goater algorithm='sha256') 327bceb4d99SCédric Le Goater archive.extract(image_path, self.workdir) 328bceb4d99SCédric Le Goater 329bceb4d99SCédric Le Goater self.do_test_arm_aspeed_sdk_start( 330a4b14b46SCédric Le Goater self.workdir + '/ast2500-default/image-bmc') 331dd562bbfSThomas Huth self.wait_for_console_pattern('nodistro.0 ast2500-default ttyS4') 332bceb4d99SCédric Le Goater 333*9b45cc99SAlex Bennée @skipUnless(os.getenv('QEMU_TEST_FLAKY_TESTS'), 'Test is unstable on GitLab') 334*9b45cc99SAlex Bennée 335bceb4d99SCédric Le Goater def test_arm_ast2600_evb_sdk(self): 336bceb4d99SCédric Le Goater """ 337bceb4d99SCédric Le Goater :avocado: tags=arch:arm 338bceb4d99SCédric Le Goater :avocado: tags=machine:ast2600-evb 339bceb4d99SCédric Le Goater """ 340bceb4d99SCédric Le Goater 341bceb4d99SCédric Le Goater image_url = ('https://github.com/AspeedTech-BMC/openbmc/releases/' 3429bf9865cSCédric Le Goater 'download/v08.06/ast2600-a2-obmc.tar.gz') 3439bf9865cSCédric Le Goater image_hash = ('9083506135f622d5e7351fcf7d4e1c7125cee5ba16141220c0ba88931f3681a4') 344bceb4d99SCédric Le Goater image_path = self.fetch_asset(image_url, asset_hash=image_hash, 345bceb4d99SCédric Le Goater algorithm='sha256') 346bceb4d99SCédric Le Goater archive.extract(image_path, self.workdir) 347bceb4d99SCédric Le Goater 348bceb4d99SCédric Le Goater self.vm.add_args('-device', 349bceb4d99SCédric Le Goater 'tmp105,bus=aspeed.i2c.bus.5,address=0x4d,id=tmp-test'); 350bceb4d99SCédric Le Goater self.vm.add_args('-device', 351bceb4d99SCédric Le Goater 'ds1338,bus=aspeed.i2c.bus.5,address=0x32'); 352bceb4d99SCédric Le Goater self.do_test_arm_aspeed_sdk_start( 3539bf9865cSCédric Le Goater self.workdir + '/ast2600-a2/image-bmc') 3549bf9865cSCédric Le Goater self.wait_for_console_pattern('nodistro.0 ast2600-a2 ttyS4') 355bceb4d99SCédric Le Goater 356dd562bbfSThomas Huth self.ssh_connect('root', '0penBmc', False) 357dd562bbfSThomas Huth self.ssh_command('dmesg -c > /dev/null') 358dd562bbfSThomas Huth 359dd562bbfSThomas Huth self.ssh_command_output_contains( 360dd562bbfSThomas Huth 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-5/device/new_device ; ' 361dd562bbfSThomas Huth 'dmesg -c', 362bceb4d99SCédric Le Goater 'i2c i2c-5: new_device: Instantiated device lm75 at 0x4d'); 363dd562bbfSThomas Huth self.ssh_command_output_contains( 364bceb4d99SCédric Le Goater 'cat /sys/class/hwmon/hwmon19/temp1_input', '0') 365684750abSVladimir Sementsov-Ogievskiy self.vm.cmd('qom-set', path='/machine/peripheral/tmp-test', 366bceb4d99SCédric Le Goater property='temperature', value=18000); 367dd562bbfSThomas Huth self.ssh_command_output_contains( 368bceb4d99SCédric Le Goater 'cat /sys/class/hwmon/hwmon19/temp1_input', '18000') 369bceb4d99SCédric Le Goater 370dd562bbfSThomas Huth self.ssh_command_output_contains( 371dd562bbfSThomas Huth 'echo ds1307 0x32 > /sys/class/i2c-dev/i2c-5/device/new_device ; ' 372dd562bbfSThomas Huth 'dmesg -c', 373bceb4d99SCédric Le Goater 'i2c i2c-5: new_device: Instantiated device ds1307 at 0x32'); 374bceb4d99SCédric Le Goater year = time.strftime("%Y") 375dd562bbfSThomas Huth self.ssh_command_output_contains('/sbin/hwclock -f /dev/rtc1', year); 376