]> Git Repo - qemu.git/blob - tests/avocado/machine_aspeed.py
works with less than base ISA qemu-system-riscv32 -M virt -bios none -kernel output...
[qemu.git] / tests / avocado / machine_aspeed.py
1 # Functional test that boots the ASPEED SoCs with firmware
2 #
3 # Copyright (C) 2022 ASPEED Technology Inc
4 #
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.
7
8 import time
9 import os
10
11 from avocado_qemu import QemuSystemTest
12 from avocado_qemu import wait_for_console_pattern
13 from avocado_qemu import exec_command
14 from avocado_qemu import exec_command_and_wait_for_pattern
15 from avocado_qemu import interrupt_interactive_console_until_pattern
16 from avocado.utils import archive
17 from avocado import skipIf
18
19
20 class AST1030Machine(QemuSystemTest):
21     """Boots the zephyr os and checks that the console is operational"""
22
23     timeout = 10
24
25     def test_ast1030_zephyros(self):
26         """
27         :avocado: tags=arch:arm
28         :avocado: tags=machine:ast1030-evb
29         """
30         tar_url = ('https://github.com/AspeedTech-BMC'
31                    '/zephyr/releases/download/v00.01.04/ast1030-evb-demo.zip')
32         tar_hash = '4c6a8ce3a8ba76ef1a65dae419ae3409343c4b20'
33         tar_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
34         archive.extract(tar_path, self.workdir)
35         kernel_file = self.workdir + "/ast1030-evb-demo/zephyr.elf"
36         self.vm.set_console()
37         self.vm.add_args('-kernel', kernel_file,
38                          '-nographic')
39         self.vm.launch()
40         wait_for_console_pattern(self, "Booting Zephyr OS")
41         exec_command_and_wait_for_pattern(self, "help",
42                                           "Available commands")
43
44 class AST2x00Machine(QemuSystemTest):
45
46     timeout = 90
47
48     def wait_for_console_pattern(self, success_message, vm=None):
49         wait_for_console_pattern(self, success_message,
50                                  failure_message='Kernel panic - not syncing',
51                                  vm=vm)
52
53     def do_test_arm_aspeed(self, image):
54         self.vm.set_console()
55         self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw',
56                          '-net', 'nic')
57         self.vm.launch()
58
59         self.wait_for_console_pattern("U-Boot 2016.07")
60         self.wait_for_console_pattern("## Loading kernel from FIT Image at 20080000")
61         self.wait_for_console_pattern("Starting kernel ...")
62         self.wait_for_console_pattern("Booting Linux on physical CPU 0x0")
63         wait_for_console_pattern(self,
64                 "aspeed-smc 1e620000.spi: read control register: 203b0641")
65         self.wait_for_console_pattern("ftgmac100 1e660000.ethernet eth0: irq ")
66         self.wait_for_console_pattern("systemd[1]: Set hostname to")
67
68     def test_arm_ast2400_palmetto_openbmc_v2_9_0(self):
69         """
70         :avocado: tags=arch:arm
71         :avocado: tags=machine:palmetto-bmc
72         """
73
74         image_url = ('https://github.com/openbmc/openbmc/releases/download/2.9.0/'
75                      'obmc-phosphor-image-palmetto.static.mtd')
76         image_hash = ('3e13bbbc28e424865dc42f35ad672b10f2e82cdb11846bb28fa625b48beafd0d')
77         image_path = self.fetch_asset(image_url, asset_hash=image_hash,
78                                       algorithm='sha256')
79
80         self.do_test_arm_aspeed(image_path)
81
82     def test_arm_ast2500_romulus_openbmc_v2_9_0(self):
83         """
84         :avocado: tags=arch:arm
85         :avocado: tags=machine:romulus-bmc
86         """
87
88         image_url = ('https://github.com/openbmc/openbmc/releases/download/2.9.0/'
89                      'obmc-phosphor-image-romulus.static.mtd')
90         image_hash = ('820341076803f1955bc31e647a512c79f9add4f5233d0697678bab4604c7bb25')
91         image_path = self.fetch_asset(image_url, asset_hash=image_hash,
92                                       algorithm='sha256')
93
94         self.do_test_arm_aspeed(image_path)
95
96     def do_test_arm_aspeed_buildroot_start(self, image, cpu_id):
97         self.require_netdev('user')
98
99         self.vm.set_console()
100         self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw',
101                          '-net', 'nic', '-net', 'user')
102         self.vm.launch()
103
104         self.wait_for_console_pattern('U-Boot 2019.04')
105         self.wait_for_console_pattern('## Loading kernel from FIT Image')
106         self.wait_for_console_pattern('Starting kernel ...')
107         self.wait_for_console_pattern('Booting Linux on physical CPU ' + cpu_id)
108         self.wait_for_console_pattern('lease of 10.0.2.15')
109         # the line before login:
110         self.wait_for_console_pattern('Aspeed EVB')
111         time.sleep(0.1)
112         exec_command(self, 'root')
113         time.sleep(0.1)
114
115     def do_test_arm_aspeed_buildroot_poweroff(self):
116         exec_command_and_wait_for_pattern(self, 'poweroff',
117                                           'reboot: System halted');
118
119     def test_arm_ast2500_evb_buildroot(self):
120         """
121         :avocado: tags=arch:arm
122         :avocado: tags=machine:ast2500-evb
123         """
124
125         image_url = ('https://github.com/legoater/qemu-aspeed-boot/raw/master/'
126                      'images/ast2500-evb/buildroot-2022.05/flash.img')
127         image_hash = ('549db6e9d8cdaf4367af21c36385a68bb465779c18b5e37094fc7343decccd3f')
128         image_path = self.fetch_asset(image_url, asset_hash=image_hash,
129                                       algorithm='sha256')
130
131         self.vm.add_args('-device',
132                          'tmp105,bus=aspeed.i2c.bus.3,address=0x4d,id=tmp-test');
133         self.do_test_arm_aspeed_buildroot_start(image_path, '0x0')
134
135         exec_command_and_wait_for_pattern(self,
136              'echo lm75 0x4d > /sys/class/i2c-dev/i2c-3/device/new_device',
137              'i2c i2c-3: new_device: Instantiated device lm75 at 0x4d');
138         exec_command_and_wait_for_pattern(self,
139                              'cat /sys/class/hwmon/hwmon1/temp1_input', '0')
140         self.vm.command('qom-set', path='/machine/peripheral/tmp-test',
141                         property='temperature', value=18000);
142         exec_command_and_wait_for_pattern(self,
143                              'cat /sys/class/hwmon/hwmon1/temp1_input', '18000')
144
145         self.do_test_arm_aspeed_buildroot_poweroff()
146
147     def test_arm_ast2600_evb_buildroot(self):
148         """
149         :avocado: tags=arch:arm
150         :avocado: tags=machine:ast2600-evb
151         """
152
153         image_url = ('https://github.com/legoater/qemu-aspeed-boot/raw/master/'
154                      'images/ast2600-evb/buildroot-2022.05/flash.img')
155         image_hash = ('6cc9e7d128fd4fa1fd01c883af67593cae8072c3239a0b8b6ace857f3538a92d')
156         image_path = self.fetch_asset(image_url, asset_hash=image_hash,
157                                       algorithm='sha256')
158
159         self.vm.add_args('-device',
160                          'tmp105,bus=aspeed.i2c.bus.3,address=0x4d,id=tmp-test');
161         self.vm.add_args('-device',
162                          'ds1338,bus=aspeed.i2c.bus.3,address=0x32');
163         self.do_test_arm_aspeed_buildroot_start(image_path, '0xf00')
164
165         exec_command_and_wait_for_pattern(self,
166              'echo lm75 0x4d > /sys/class/i2c-dev/i2c-3/device/new_device',
167              'i2c i2c-3: new_device: Instantiated device lm75 at 0x4d');
168         exec_command_and_wait_for_pattern(self,
169                              'cat /sys/class/hwmon/hwmon0/temp1_input', '0')
170         self.vm.command('qom-set', path='/machine/peripheral/tmp-test',
171                         property='temperature', value=18000);
172         exec_command_and_wait_for_pattern(self,
173                              'cat /sys/class/hwmon/hwmon0/temp1_input', '18000')
174
175         exec_command_and_wait_for_pattern(self,
176              'echo ds1307 0x32 > /sys/class/i2c-dev/i2c-3/device/new_device',
177              'i2c i2c-3: new_device: Instantiated device ds1307 at 0x32');
178         year = time.strftime("%Y")
179         exec_command_and_wait_for_pattern(self, 'hwclock -f /dev/rtc1', year);
180
181         self.do_test_arm_aspeed_buildroot_poweroff()
182
183
184 class AST2x00MachineSDK(QemuSystemTest):
185
186     EXTRA_BOOTARGS = ' quiet'
187
188     # FIXME: Although these tests boot a whole distro they are still
189     # slower than comparable machine models. There may be some
190     # optimisations which bring down the runtime. In the meantime they
191     # have generous timeouts and are disable for CI which aims for all
192     # tests to run in less than 60 seconds.
193     timeout = 240
194
195     def wait_for_console_pattern(self, success_message, vm=None):
196         wait_for_console_pattern(self, success_message,
197                                  failure_message='Kernel panic - not syncing',
198                                  vm=vm)
199
200     def do_test_arm_aspeed_sdk_start(self, image):
201         self.require_netdev('user')
202         self.vm.set_console()
203         self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw',
204                          '-net', 'nic', '-net', 'user')
205         self.vm.launch()
206
207         self.wait_for_console_pattern('U-Boot 2019.04')
208         interrupt_interactive_console_until_pattern(
209             self, 'Hit any key to stop autoboot:', 'ast#')
210         exec_command_and_wait_for_pattern(
211             self, 'setenv bootargs ${bootargs}' + self.EXTRA_BOOTARGS, 'ast#')
212         exec_command_and_wait_for_pattern(
213             self, 'boot', '## Loading kernel from FIT Image')
214         self.wait_for_console_pattern('Starting kernel ...')
215
216     @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
217     def test_arm_ast2500_evb_sdk(self):
218         """
219         :avocado: tags=arch:arm
220         :avocado: tags=machine:ast2500-evb
221         """
222
223         image_url = ('https://github.com/AspeedTech-BMC/openbmc/releases/'
224                      'download/v08.01/ast2500-default-obmc.tar.gz')
225         image_hash = ('5375f82b4c43a79427909342a1e18b4e48bd663e38466862145d27bb358796fd')
226         image_path = self.fetch_asset(image_url, asset_hash=image_hash,
227                                       algorithm='sha256')
228         archive.extract(image_path, self.workdir)
229
230         self.do_test_arm_aspeed_sdk_start(
231             self.workdir + '/ast2500-default/image-bmc')
232         self.wait_for_console_pattern('ast2500-default login:')
233
234     @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
235     def test_arm_ast2600_evb_sdk(self):
236         """
237         :avocado: tags=arch:arm
238         :avocado: tags=machine:ast2600-evb
239         """
240
241         image_url = ('https://github.com/AspeedTech-BMC/openbmc/releases/'
242                      'download/v08.01/ast2600-default-obmc.tar.gz')
243         image_hash = ('f12ef15e8c1f03a214df3b91c814515c5e2b2f56119021398c1dbdd626817d15')
244         image_path = self.fetch_asset(image_url, asset_hash=image_hash,
245                                       algorithm='sha256')
246         archive.extract(image_path, self.workdir)
247
248         self.vm.add_args('-device',
249                          'tmp105,bus=aspeed.i2c.bus.5,address=0x4d,id=tmp-test');
250         self.vm.add_args('-device',
251                          'ds1338,bus=aspeed.i2c.bus.5,address=0x32');
252         self.do_test_arm_aspeed_sdk_start(
253             self.workdir + '/ast2600-default/image-bmc')
254         self.wait_for_console_pattern('ast2600-default login:')
255         exec_command_and_wait_for_pattern(self, 'root', 'Password:')
256         exec_command_and_wait_for_pattern(self, '0penBmc', 'root@ast2600-default:~#')
257
258         exec_command_and_wait_for_pattern(self,
259              'echo lm75 0x4d > /sys/class/i2c-dev/i2c-5/device/new_device',
260              'i2c i2c-5: new_device: Instantiated device lm75 at 0x4d');
261         exec_command_and_wait_for_pattern(self,
262                              'cat /sys/class/hwmon/hwmon19/temp1_input', '0')
263         self.vm.command('qom-set', path='/machine/peripheral/tmp-test',
264                         property='temperature', value=18000);
265         exec_command_and_wait_for_pattern(self,
266                              'cat /sys/class/hwmon/hwmon19/temp1_input', '18000')
267
268         exec_command_and_wait_for_pattern(self,
269              'echo ds1307 0x32 > /sys/class/i2c-dev/i2c-5/device/new_device',
270              'i2c i2c-5: new_device: Instantiated device ds1307 at 0x32');
271         year = time.strftime("%Y")
272         exec_command_and_wait_for_pattern(self, 'hwclock -f /dev/rtc1', year);
This page took 0.057826 seconds and 4 git commands to generate.