icount: Take iothread lock when running QEMU timers
[qemu/ar7.git] / tests / avocado / machine_aspeed.py
blobb4e35a3d0743d5c71c8018c694920bfc90ebf270
1 # Functional test that boots the ASPEED SoCs with firmware
3 # Copyright (C) 2022 ASPEED Technology Inc
5 # This work is licensed under the terms of the GNU GPL, version 2 or
6 # later. See the COPYING file in the top-level directory.
8 import time
10 from avocado_qemu import QemuSystemTest
11 from avocado_qemu import wait_for_console_pattern
12 from avocado_qemu import exec_command
13 from avocado_qemu import exec_command_and_wait_for_pattern
14 from avocado.utils import archive
17 class AST1030Machine(QemuSystemTest):
18 """Boots the zephyr os and checks that the console is operational"""
20 timeout = 10
22 def test_ast1030_zephyros(self):
23 """
24 :avocado: tags=arch:arm
25 :avocado: tags=machine:ast1030-evb
26 """
27 tar_url = ('https://github.com/AspeedTech-BMC'
28 '/zephyr/releases/download/v00.01.04/ast1030-evb-demo.zip')
29 tar_hash = '4c6a8ce3a8ba76ef1a65dae419ae3409343c4b20'
30 tar_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
31 archive.extract(tar_path, self.workdir)
32 kernel_file = self.workdir + "/ast1030-evb-demo/zephyr.elf"
33 self.vm.set_console()
34 self.vm.add_args('-kernel', kernel_file,
35 '-nographic')
36 self.vm.launch()
37 wait_for_console_pattern(self, "Booting Zephyr OS")
38 exec_command_and_wait_for_pattern(self, "help",
39 "Available commands")
41 class AST2x00Machine(QemuSystemTest):
43 def wait_for_console_pattern(self, success_message, vm=None):
44 wait_for_console_pattern(self, success_message,
45 failure_message='Kernel panic - not syncing',
46 vm=vm)
48 def do_test_arm_aspeed(self, image):
49 self.vm.set_console()
50 self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw',
51 '-net', 'nic')
52 self.vm.launch()
54 self.wait_for_console_pattern("U-Boot 2016.07")
55 self.wait_for_console_pattern("## Loading kernel from FIT Image at 20080000")
56 self.wait_for_console_pattern("Starting kernel ...")
57 self.wait_for_console_pattern("Booting Linux on physical CPU 0x0")
58 wait_for_console_pattern(self,
59 "aspeed-smc 1e620000.spi: read control register: 203b0641")
60 self.wait_for_console_pattern("ftgmac100 1e660000.ethernet eth0: irq ")
61 self.wait_for_console_pattern("systemd[1]: Set hostname to")
63 def test_arm_ast2400_palmetto_openbmc_v2_9_0(self):
64 """
65 :avocado: tags=arch:arm
66 :avocado: tags=machine:palmetto-bmc
67 """
69 image_url = ('https://github.com/openbmc/openbmc/releases/download/2.9.0/'
70 'obmc-phosphor-image-palmetto.static.mtd')
71 image_hash = ('3e13bbbc28e424865dc42f35ad672b10f2e82cdb11846bb28fa625b48beafd0d')
72 image_path = self.fetch_asset(image_url, asset_hash=image_hash,
73 algorithm='sha256')
75 self.do_test_arm_aspeed(image_path)
77 def test_arm_ast2500_romulus_openbmc_v2_9_0(self):
78 """
79 :avocado: tags=arch:arm
80 :avocado: tags=machine:romulus-bmc
81 """
83 image_url = ('https://github.com/openbmc/openbmc/releases/download/2.9.0/'
84 'obmc-phosphor-image-romulus.static.mtd')
85 image_hash = ('820341076803f1955bc31e647a512c79f9add4f5233d0697678bab4604c7bb25')
86 image_path = self.fetch_asset(image_url, asset_hash=image_hash,
87 algorithm='sha256')
89 self.do_test_arm_aspeed(image_path)
91 def do_test_arm_aspeed_buidroot_start(self, image, cpu_id):
92 self.vm.set_console()
93 self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw',
94 '-net', 'nic', '-net', 'user')
95 self.vm.launch()
97 self.wait_for_console_pattern('U-Boot 2019.04')
98 self.wait_for_console_pattern('## Loading kernel from FIT Image')
99 self.wait_for_console_pattern('Starting kernel ...')
100 self.wait_for_console_pattern('Booting Linux on physical CPU ' + cpu_id)
101 self.wait_for_console_pattern('lease of 10.0.2.15')
102 self.wait_for_console_pattern('Aspeed EVB')
103 exec_command(self, 'root')
104 time.sleep(0.1)
106 def do_test_arm_aspeed_buidroot_poweroff(self):
107 exec_command_and_wait_for_pattern(self, 'poweroff',
108 'reboot: System halted');
110 def test_arm_ast2500_evb_builroot(self):
112 :avocado: tags=arch:arm
113 :avocado: tags=machine:ast2500-evb
116 image_url = ('https://github.com/legoater/qemu-aspeed-boot/raw/master/'
117 'images/ast2500-evb/buildroot-2022.05/flash.img')
118 image_hash = ('549db6e9d8cdaf4367af21c36385a68bb465779c18b5e37094fc7343decccd3f')
119 image_path = self.fetch_asset(image_url, asset_hash=image_hash,
120 algorithm='sha256')
122 self.vm.add_args('-device',
123 'tmp105,bus=aspeed.i2c.bus.3,address=0x4d,id=tmp-test');
124 self.do_test_arm_aspeed_buidroot_start(image_path, '0x0')
126 exec_command_and_wait_for_pattern(self,
127 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-3/device/new_device',
128 'i2c i2c-3: new_device: Instantiated device lm75 at 0x4d');
129 exec_command_and_wait_for_pattern(self,
130 'cat /sys/class/hwmon/hwmon1/temp1_input', '0')
131 self.vm.command('qom-set', path='/machine/peripheral/tmp-test',
132 property='temperature', value=18000);
133 exec_command_and_wait_for_pattern(self,
134 'cat /sys/class/hwmon/hwmon1/temp1_input', '18000')
136 self.do_test_arm_aspeed_buidroot_poweroff()
138 def test_arm_ast2600_evb_builroot(self):
140 :avocado: tags=arch:arm
141 :avocado: tags=machine:ast2600-evb
144 image_url = ('https://github.com/legoater/qemu-aspeed-boot/raw/master/'
145 'images/ast2600-evb/buildroot-2022.05/flash.img')
146 image_hash = ('6cc9e7d128fd4fa1fd01c883af67593cae8072c3239a0b8b6ace857f3538a92d')
147 image_path = self.fetch_asset(image_url, asset_hash=image_hash,
148 algorithm='sha256')
150 self.vm.add_args('-device',
151 'tmp105,bus=aspeed.i2c.bus.3,address=0x4d,id=tmp-test');
152 self.vm.add_args('-device',
153 'ds1338,bus=aspeed.i2c.bus.3,address=0x32');
154 self.do_test_arm_aspeed_buidroot_start(image_path, '0xf00')
156 exec_command_and_wait_for_pattern(self,
157 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-3/device/new_device',
158 'i2c i2c-3: new_device: Instantiated device lm75 at 0x4d');
159 exec_command_and_wait_for_pattern(self,
160 'cat /sys/class/hwmon/hwmon0/temp1_input', '0')
161 self.vm.command('qom-set', path='/machine/peripheral/tmp-test',
162 property='temperature', value=18000);
163 exec_command_and_wait_for_pattern(self,
164 'cat /sys/class/hwmon/hwmon0/temp1_input', '18000')
166 exec_command_and_wait_for_pattern(self,
167 'echo ds1307 0x32 > /sys/class/i2c-dev/i2c-3/device/new_device',
168 'i2c i2c-3: new_device: Instantiated device ds1307 at 0x32');
169 year = time.strftime("%Y")
170 exec_command_and_wait_for_pattern(self, 'hwclock -f /dev/rtc1', year);
172 self.do_test_arm_aspeed_buidroot_poweroff()
175 def do_test_arm_aspeed_sdk_start(self, image, cpu_id):
176 self.vm.set_console()
177 self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw',
178 '-net', 'nic', '-net', 'user')
179 self.vm.launch()
181 self.wait_for_console_pattern('U-Boot 2019.04')
182 self.wait_for_console_pattern('## Loading kernel from FIT Image')
183 self.wait_for_console_pattern('Starting kernel ...')
184 self.wait_for_console_pattern('Booting Linux on physical CPU ' + cpu_id)
186 def test_arm_ast2500_evb_sdk(self):
188 :avocado: tags=arch:arm
189 :avocado: tags=machine:ast2500-evb
192 image_url = ('https://github.com/AspeedTech-BMC/openbmc/releases/'
193 'download/v08.01/ast2500-default-obmc.tar.gz')
194 image_hash = ('5375f82b4c43a79427909342a1e18b4e48bd663e38466862145d27bb358796fd')
195 image_path = self.fetch_asset(image_url, asset_hash=image_hash,
196 algorithm='sha256')
197 archive.extract(image_path, self.workdir)
199 self.do_test_arm_aspeed_sdk_start(
200 self.workdir + '/ast2500-default/image-bmc', '0x0')
201 self.wait_for_console_pattern('ast2500-default login:')
203 def test_arm_ast2600_evb_sdk(self):
205 :avocado: tags=arch:arm
206 :avocado: tags=machine:ast2600-evb
209 image_url = ('https://github.com/AspeedTech-BMC/openbmc/releases/'
210 'download/v08.01/ast2600-default-obmc.tar.gz')
211 image_hash = ('f12ef15e8c1f03a214df3b91c814515c5e2b2f56119021398c1dbdd626817d15')
212 image_path = self.fetch_asset(image_url, asset_hash=image_hash,
213 algorithm='sha256')
214 archive.extract(image_path, self.workdir)
216 self.vm.add_args('-device',
217 'tmp105,bus=aspeed.i2c.bus.5,address=0x4d,id=tmp-test');
218 self.vm.add_args('-device',
219 'ds1338,bus=aspeed.i2c.bus.5,address=0x32');
220 self.do_test_arm_aspeed_sdk_start(
221 self.workdir + '/ast2600-default/image-bmc', '0xf00')
222 self.wait_for_console_pattern('ast2600-default login:')
223 exec_command_and_wait_for_pattern(self, 'root', 'Password:')
224 exec_command_and_wait_for_pattern(self, '0penBmc', 'root@ast2600-default:~#')
226 exec_command_and_wait_for_pattern(self,
227 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-5/device/new_device',
228 'i2c i2c-5: new_device: Instantiated device lm75 at 0x4d');
229 exec_command_and_wait_for_pattern(self,
230 'cat /sys/class/hwmon/hwmon19/temp1_input', '0')
231 self.vm.command('qom-set', path='/machine/peripheral/tmp-test',
232 property='temperature', value=18000);
233 exec_command_and_wait_for_pattern(self,
234 'cat /sys/class/hwmon/hwmon19/temp1_input', '18000')
236 exec_command_and_wait_for_pattern(self,
237 'echo ds1307 0x32 > /sys/class/i2c-dev/i2c-5/device/new_device',
238 'i2c i2c-5: new_device: Instantiated device ds1307 at 0x32');
239 year = time.strftime("%Y")
240 exec_command_and_wait_for_pattern(self, 'hwclock -f /dev/rtc1', year);