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 QemuSystemTest, Asset 12from qemu_test import wait_for_console_pattern 13from qemu_test import exec_command_and_wait_for_pattern 14 15 16class AST2x00MachineSDK(QemuSystemTest): 17 18 def do_test_aarch64_aspeed_sdk_start(self, image): 19 self.require_netdev('user') 20 self.vm.set_console() 21 self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw', 22 '-net', 'nic', '-net', 'user', '-snapshot') 23 24 self.vm.launch() 25 26 wait_for_console_pattern(self, 'U-Boot 2023.10') 27 wait_for_console_pattern(self, '## Loading kernel from FIT Image') 28 wait_for_console_pattern(self, 'Starting kernel ...') 29 30 ASSET_SDK_V903_AST2700 = Asset( 31 'https://github.com/AspeedTech-BMC/openbmc/releases/download/v09.03/ast2700-default-obmc.tar.gz', 32 '91225f50d255e2905ba8d8e0c80b71b9d157c3609770c7a740cd786370d85a77') 33 34 def test_aarch64_ast2700_evb_sdk_v09_03(self): 35 self.set_machine('ast2700-evb') 36 37 self.archive_extract(self.ASSET_SDK_V903_AST2700) 38 39 num_cpu = 4 40 uboot_size = os.path.getsize(self.scratch_file('ast2700-default', 41 'u-boot-nodtb.bin')) 42 uboot_dtb_load_addr = hex(0x400000000 + uboot_size) 43 44 load_images_list = [ 45 { 46 'addr': '0x400000000', 47 'file': self.scratch_file('ast2700-default', 48 'u-boot-nodtb.bin') 49 }, 50 { 51 'addr': str(uboot_dtb_load_addr), 52 'file': self.scratch_file('ast2700-default', 'u-boot.dtb') 53 }, 54 { 55 'addr': '0x430000000', 56 'file': self.scratch_file('ast2700-default', 'bl31.bin') 57 }, 58 { 59 'addr': '0x430080000', 60 'file': self.scratch_file('ast2700-default', 'optee', 61 'tee-raw.bin') 62 } 63 ] 64 65 for load_image in load_images_list: 66 addr = load_image['addr'] 67 file = load_image['file'] 68 self.vm.add_args('-device', 69 f'loader,force-raw=on,addr={addr},file={file}') 70 71 for i in range(num_cpu): 72 self.vm.add_args('-device', 73 f'loader,addr=0x430000000,cpu-num={i}') 74 75 self.vm.add_args('-smp', str(num_cpu)) 76 self.vm.add_args('-device', 77 'tmp105,bus=aspeed.i2c.bus.1,address=0x4d,id=tmp-test') 78 self.do_test_aarch64_aspeed_sdk_start( 79 self.scratch_file('ast2700-default', 'image-bmc')) 80 81 wait_for_console_pattern(self, 'ast2700-default login:') 82 83 exec_command_and_wait_for_pattern(self, 'root', 'Password:') 84 exec_command_and_wait_for_pattern(self, 85 '0penBmc', 'root@ast2700-default:~#') 86 87 exec_command_and_wait_for_pattern(self, 88 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-1/device/new_device ', 89 'i2c i2c-1: new_device: Instantiated device lm75 at 0x4d'); 90 exec_command_and_wait_for_pattern(self, 91 'cat /sys/class/hwmon/hwmon20/temp1_input', '0') 92 self.vm.cmd('qom-set', path='/machine/peripheral/tmp-test', 93 property='temperature', value=18000) 94 exec_command_and_wait_for_pattern(self, 95 'cat /sys/class/hwmon/hwmon20/temp1_input', '18000') 96 97 98if __name__ == '__main__': 99 QemuSystemTest.main() 100