]>
Commit | Line | Data |
---|---|---|
438eff63 JL |
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 | ||
f7bc7da0 | 8 | import time |
92f8e8e2 | 9 | import os |
c3d58a7a JS |
10 | import tempfile |
11 | import subprocess | |
f7bc7da0 | 12 | |
438eff63 JL |
13 | from avocado_qemu import QemuSystemTest |
14 | from avocado_qemu import wait_for_console_pattern | |
f7bc7da0 | 15 | from avocado_qemu import exec_command |
438eff63 | 16 | from avocado_qemu import exec_command_and_wait_for_pattern |
a4b14b46 | 17 | from avocado_qemu import interrupt_interactive_console_until_pattern |
c3d58a7a | 18 | from avocado_qemu import has_cmd |
438eff63 | 19 | from avocado.utils import archive |
92f8e8e2 | 20 | from avocado import skipIf |
c3d58a7a | 21 | from avocado import skipUnless |
438eff63 JL |
22 | |
23 | ||
24 | class AST1030Machine(QemuSystemTest): | |
25 | """Boots the zephyr os and checks that the console is operational""" | |
26 | ||
27 | timeout = 10 | |
28 | ||
44055caa | 29 | def test_ast1030_zephyros_1_04(self): |
438eff63 JL |
30 | """ |
31 | :avocado: tags=arch:arm | |
32 | :avocado: tags=machine:ast1030-evb | |
44055caa | 33 | :avocado: tags=os:zephyr |
438eff63 JL |
34 | """ |
35 | tar_url = ('https://github.com/AspeedTech-BMC' | |
36 | '/zephyr/releases/download/v00.01.04/ast1030-evb-demo.zip') | |
37 | tar_hash = '4c6a8ce3a8ba76ef1a65dae419ae3409343c4b20' | |
38 | tar_path = self.fetch_asset(tar_url, asset_hash=tar_hash) | |
39 | archive.extract(tar_path, self.workdir) | |
40 | kernel_file = self.workdir + "/ast1030-evb-demo/zephyr.elf" | |
41 | self.vm.set_console() | |
42 | self.vm.add_args('-kernel', kernel_file, | |
43 | '-nographic') | |
44 | self.vm.launch() | |
45 | wait_for_console_pattern(self, "Booting Zephyr OS") | |
46 | exec_command_and_wait_for_pattern(self, "help", | |
47 | "Available commands") | |
341e21fa | 48 | |
44055caa PMD |
49 | def test_ast1030_zephyros_1_07(self): |
50 | """ | |
51 | :avocado: tags=arch:arm | |
52 | :avocado: tags=machine:ast1030-evb | |
53 | :avocado: tags=os:zephyr | |
54 | """ | |
55 | tar_url = ('https://github.com/AspeedTech-BMC' | |
56 | '/zephyr/releases/download/v00.01.07/ast1030-evb-demo.zip') | |
57 | tar_hash = '40ac87eabdcd3b3454ce5aad11fedc72a33ecda2' | |
58 | tar_path = self.fetch_asset(tar_url, asset_hash=tar_hash) | |
59 | archive.extract(tar_path, self.workdir) | |
60 | kernel_file = self.workdir + "/ast1030-evb-demo/zephyr.bin" | |
61 | self.vm.set_console() | |
62 | self.vm.add_args('-kernel', kernel_file, | |
63 | '-nographic') | |
64 | self.vm.launch() | |
65 | wait_for_console_pattern(self, "Booting Zephyr OS") | |
66 | for shell_cmd in [ | |
67 | 'kernel stacks', | |
68 | 'otp info conf', | |
69 | 'otp info scu', | |
70 | 'hwinfo devid', | |
71 | 'crypto aes256_cbc_vault', | |
72 | 'random get', | |
73 | 'jtag JTAG1 sw_xfer high TMS', | |
74 | 'adc ADC0 resolution 12', | |
75 | 'adc ADC0 read 42', | |
76 | 'adc ADC1 read 69', | |
77 | 'i2c scan I2C_0', | |
78 | 'i3c attach I3C_0', | |
79 | 'hash test', | |
80 | 'kernel uptime', | |
81 | 'kernel reboot warm', | |
82 | 'kernel uptime', | |
83 | 'kernel reboot cold', | |
84 | 'kernel uptime', | |
85 | ]: exec_command_and_wait_for_pattern(self, shell_cmd, "uart:~$") | |
86 | ||
341e21fa CLG |
87 | class AST2x00Machine(QemuSystemTest): |
88 | ||
b1ceae2f AB |
89 | timeout = 90 |
90 | ||
341e21fa CLG |
91 | def wait_for_console_pattern(self, success_message, vm=None): |
92 | wait_for_console_pattern(self, success_message, | |
93 | failure_message='Kernel panic - not syncing', | |
94 | vm=vm) | |
95 | ||
96 | def do_test_arm_aspeed(self, image): | |
97 | self.vm.set_console() | |
98 | self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw', | |
99 | '-net', 'nic') | |
100 | self.vm.launch() | |
101 | ||
102 | self.wait_for_console_pattern("U-Boot 2016.07") | |
103 | self.wait_for_console_pattern("## Loading kernel from FIT Image at 20080000") | |
104 | self.wait_for_console_pattern("Starting kernel ...") | |
105 | self.wait_for_console_pattern("Booting Linux on physical CPU 0x0") | |
106 | wait_for_console_pattern(self, | |
107 | "aspeed-smc 1e620000.spi: read control register: 203b0641") | |
108 | self.wait_for_console_pattern("ftgmac100 1e660000.ethernet eth0: irq ") | |
109 | self.wait_for_console_pattern("systemd[1]: Set hostname to") | |
110 | ||
111 | def test_arm_ast2400_palmetto_openbmc_v2_9_0(self): | |
112 | """ | |
113 | :avocado: tags=arch:arm | |
114 | :avocado: tags=machine:palmetto-bmc | |
115 | """ | |
116 | ||
117 | image_url = ('https://github.com/openbmc/openbmc/releases/download/2.9.0/' | |
118 | 'obmc-phosphor-image-palmetto.static.mtd') | |
119 | image_hash = ('3e13bbbc28e424865dc42f35ad672b10f2e82cdb11846bb28fa625b48beafd0d') | |
120 | image_path = self.fetch_asset(image_url, asset_hash=image_hash, | |
121 | algorithm='sha256') | |
122 | ||
123 | self.do_test_arm_aspeed(image_path) | |
124 | ||
125 | def test_arm_ast2500_romulus_openbmc_v2_9_0(self): | |
126 | """ | |
127 | :avocado: tags=arch:arm | |
128 | :avocado: tags=machine:romulus-bmc | |
129 | """ | |
130 | ||
131 | image_url = ('https://github.com/openbmc/openbmc/releases/download/2.9.0/' | |
132 | 'obmc-phosphor-image-romulus.static.mtd') | |
133 | image_hash = ('820341076803f1955bc31e647a512c79f9add4f5233d0697678bab4604c7bb25') | |
134 | image_path = self.fetch_asset(image_url, asset_hash=image_hash, | |
135 | algorithm='sha256') | |
136 | ||
137 | self.do_test_arm_aspeed(image_path) | |
f7bc7da0 | 138 | |
c3d58a7a | 139 | def do_test_arm_aspeed_buildroot_start(self, image, cpu_id, pattern='Aspeed EVB'): |
0793fe01 PM |
140 | self.require_netdev('user') |
141 | ||
f7bc7da0 CLG |
142 | self.vm.set_console() |
143 | self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw', | |
144 | '-net', 'nic', '-net', 'user') | |
145 | self.vm.launch() | |
146 | ||
147 | self.wait_for_console_pattern('U-Boot 2019.04') | |
148 | self.wait_for_console_pattern('## Loading kernel from FIT Image') | |
149 | self.wait_for_console_pattern('Starting kernel ...') | |
150 | self.wait_for_console_pattern('Booting Linux on physical CPU ' + cpu_id) | |
151 | self.wait_for_console_pattern('lease of 10.0.2.15') | |
65711f9a | 152 | # the line before login: |
c3d58a7a | 153 | self.wait_for_console_pattern(pattern) |
65711f9a | 154 | time.sleep(0.1) |
f7bc7da0 CLG |
155 | exec_command(self, 'root') |
156 | time.sleep(0.1) | |
157 | ||
7b5093b8 | 158 | def do_test_arm_aspeed_buildroot_poweroff(self): |
f7bc7da0 CLG |
159 | exec_command_and_wait_for_pattern(self, 'poweroff', |
160 | 'reboot: System halted'); | |
161 | ||
7b5093b8 | 162 | def test_arm_ast2500_evb_buildroot(self): |
f7bc7da0 CLG |
163 | """ |
164 | :avocado: tags=arch:arm | |
165 | :avocado: tags=machine:ast2500-evb | |
166 | """ | |
167 | ||
168 | image_url = ('https://github.com/legoater/qemu-aspeed-boot/raw/master/' | |
ed1f5ff8 CLG |
169 | 'images/ast2500-evb/buildroot-2022.11-2-g15d3648df9/flash.img') |
170 | image_hash = ('f96d11db521fe7a2787745e9e391225deeeec3318ee0fc07c8b799b8833dd474') | |
f7bc7da0 CLG |
171 | image_path = self.fetch_asset(image_url, asset_hash=image_hash, |
172 | algorithm='sha256') | |
173 | ||
7a7308ea CLG |
174 | self.vm.add_args('-device', |
175 | 'tmp105,bus=aspeed.i2c.bus.3,address=0x4d,id=tmp-test'); | |
7b5093b8 | 176 | self.do_test_arm_aspeed_buildroot_start(image_path, '0x0') |
7a7308ea CLG |
177 | |
178 | exec_command_and_wait_for_pattern(self, | |
179 | 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-3/device/new_device', | |
180 | 'i2c i2c-3: new_device: Instantiated device lm75 at 0x4d'); | |
181 | exec_command_and_wait_for_pattern(self, | |
182 | 'cat /sys/class/hwmon/hwmon1/temp1_input', '0') | |
183 | self.vm.command('qom-set', path='/machine/peripheral/tmp-test', | |
184 | property='temperature', value=18000); | |
185 | exec_command_and_wait_for_pattern(self, | |
186 | 'cat /sys/class/hwmon/hwmon1/temp1_input', '18000') | |
187 | ||
7b5093b8 | 188 | self.do_test_arm_aspeed_buildroot_poweroff() |
f7bc7da0 | 189 | |
7b5093b8 | 190 | def test_arm_ast2600_evb_buildroot(self): |
f7bc7da0 CLG |
191 | """ |
192 | :avocado: tags=arch:arm | |
193 | :avocado: tags=machine:ast2600-evb | |
194 | """ | |
195 | ||
196 | image_url = ('https://github.com/legoater/qemu-aspeed-boot/raw/master/' | |
ed1f5ff8 CLG |
197 | 'images/ast2600-evb/buildroot-2022.11-2-g15d3648df9/flash.img') |
198 | image_hash = ('e598d86e5ea79671ca8b59212a326c911bc8bea728dec1a1f5390d717a28bb8b') | |
f7bc7da0 CLG |
199 | image_path = self.fetch_asset(image_url, asset_hash=image_hash, |
200 | algorithm='sha256') | |
201 | ||
61cf757d CLG |
202 | self.vm.add_args('-device', |
203 | 'tmp105,bus=aspeed.i2c.bus.3,address=0x4d,id=tmp-test'); | |
3302184f CLG |
204 | self.vm.add_args('-device', |
205 | 'ds1338,bus=aspeed.i2c.bus.3,address=0x32'); | |
82e94da5 CLG |
206 | self.vm.add_args('-device', |
207 | 'i2c-echo,bus=aspeed.i2c.bus.3,address=0x42'); | |
7b5093b8 | 208 | self.do_test_arm_aspeed_buildroot_start(image_path, '0xf00') |
61cf757d CLG |
209 | |
210 | exec_command_and_wait_for_pattern(self, | |
211 | 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-3/device/new_device', | |
212 | 'i2c i2c-3: new_device: Instantiated device lm75 at 0x4d'); | |
213 | exec_command_and_wait_for_pattern(self, | |
214 | 'cat /sys/class/hwmon/hwmon0/temp1_input', '0') | |
215 | self.vm.command('qom-set', path='/machine/peripheral/tmp-test', | |
216 | property='temperature', value=18000); | |
217 | exec_command_and_wait_for_pattern(self, | |
218 | 'cat /sys/class/hwmon/hwmon0/temp1_input', '18000') | |
219 | ||
3302184f CLG |
220 | exec_command_and_wait_for_pattern(self, |
221 | 'echo ds1307 0x32 > /sys/class/i2c-dev/i2c-3/device/new_device', | |
222 | 'i2c i2c-3: new_device: Instantiated device ds1307 at 0x32'); | |
223 | year = time.strftime("%Y") | |
224 | exec_command_and_wait_for_pattern(self, 'hwclock -f /dev/rtc1', year); | |
225 | ||
82e94da5 CLG |
226 | exec_command_and_wait_for_pattern(self, |
227 | 'echo slave-24c02 0x1064 > /sys/bus/i2c/devices/i2c-3/new_device', | |
228 | 'i2c i2c-3: new_device: Instantiated device slave-24c02 at 0x64'); | |
229 | exec_command(self, 'i2cset -y 3 0x42 0x64 0x00 0xaa i'); | |
230 | time.sleep(0.1) | |
231 | exec_command_and_wait_for_pattern(self, | |
232 | 'hexdump /sys/bus/i2c/devices/3-1064/slave-eeprom', | |
233 | '0000000 ffaa ffff ffff ffff ffff ffff ffff ffff'); | |
7b5093b8 | 234 | self.do_test_arm_aspeed_buildroot_poweroff() |
bceb4d99 | 235 | |
c3d58a7a JS |
236 | @skipUnless(*has_cmd('swtpm')) |
237 | def test_arm_ast2600_evb_buildroot_tpm(self): | |
238 | """ | |
239 | :avocado: tags=arch:arm | |
240 | :avocado: tags=machine:ast2600-evb | |
241 | """ | |
242 | ||
243 | image_url = ('https://github.com/legoater/qemu-aspeed-boot/raw/master/' | |
244 | 'images/ast2600-evb/buildroot-2023.02-tpm/flash.img') | |
245 | image_hash = ('a46009ae8a5403a0826d607215e731a8c68d27c14c41e55331706b8f9c7bd997') | |
246 | image_path = self.fetch_asset(image_url, asset_hash=image_hash, | |
247 | algorithm='sha256') | |
248 | ||
249 | socket = os.path.join(self.vm.sock_dir, 'swtpm-socket') | |
250 | ||
251 | subprocess.run(['swtpm', 'socket', '-d', '--tpm2', | |
252 | '--tpmstate', f'dir={self.vm.temp_dir}', | |
253 | '--ctrl', f'type=unixio,path={socket}']) | |
254 | ||
255 | self.vm.add_args('-chardev', f'socket,id=chrtpm,path={socket}') | |
256 | self.vm.add_args('-tpmdev', 'emulator,id=tpm0,chardev=chrtpm') | |
257 | self.vm.add_args('-device', | |
258 | 'tpm-tis-i2c,tpmdev=tpm0,bus=aspeed.i2c.bus.12,address=0x2e') | |
259 | self.do_test_arm_aspeed_buildroot_start(image_path, '0xf00', 'Aspeed AST2600 EVB') | |
260 | exec_command(self, "passw0rd") | |
261 | ||
262 | exec_command_and_wait_for_pattern(self, | |
263 | 'echo tpm_tis_i2c 0x2e > /sys/bus/i2c/devices/i2c-12/new_device', | |
264 | 'tpm_tis_i2c 12-002e: 2.0 TPM (device-id 0x1, rev-id 1)'); | |
265 | exec_command_and_wait_for_pattern(self, | |
266 | 'cat /sys/class/tpm/tpm0/pcr-sha256/0', | |
267 | 'B804724EA13F52A9072BA87FE8FDCC497DFC9DF9AA15B9088694639C431688E0'); | |
268 | ||
269 | self.do_test_arm_aspeed_buildroot_poweroff() | |
bceb4d99 | 270 | |
92f8e8e2 AB |
271 | class AST2x00MachineSDK(QemuSystemTest): |
272 | ||
30d7aac4 CLG |
273 | EXTRA_BOOTARGS = ( |
274 | 'quiet ' | |
275 | 'systemd.mask=org.openbmc.HostIpmi.service ' | |
276 | 'systemd.mask=xyz.openbmc_project.Chassis.Control.Power@0.service ' | |
277 | 'systemd.mask=modprobe@fuse.service ' | |
278 | 'systemd.mask=rngd.service ' | |
279 | 'systemd.mask=obmc-console@ttyS2.service ' | |
280 | ) | |
a4b14b46 | 281 | |
92f8e8e2 AB |
282 | # FIXME: Although these tests boot a whole distro they are still |
283 | # slower than comparable machine models. There may be some | |
284 | # optimisations which bring down the runtime. In the meantime they | |
285 | # have generous timeouts and are disable for CI which aims for all | |
286 | # tests to run in less than 60 seconds. | |
287 | timeout = 240 | |
288 | ||
289 | def wait_for_console_pattern(self, success_message, vm=None): | |
290 | wait_for_console_pattern(self, success_message, | |
291 | failure_message='Kernel panic - not syncing', | |
292 | vm=vm) | |
293 | ||
a4b14b46 | 294 | def do_test_arm_aspeed_sdk_start(self, image): |
0793fe01 | 295 | self.require_netdev('user') |
bceb4d99 CLG |
296 | self.vm.set_console() |
297 | self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw', | |
298 | '-net', 'nic', '-net', 'user') | |
299 | self.vm.launch() | |
300 | ||
301 | self.wait_for_console_pattern('U-Boot 2019.04') | |
a4b14b46 CLG |
302 | interrupt_interactive_console_until_pattern( |
303 | self, 'Hit any key to stop autoboot:', 'ast#') | |
304 | exec_command_and_wait_for_pattern( | |
30d7aac4 | 305 | self, 'setenv bootargs ${bootargs} ' + self.EXTRA_BOOTARGS, 'ast#') |
a4b14b46 CLG |
306 | exec_command_and_wait_for_pattern( |
307 | self, 'boot', '## Loading kernel from FIT Image') | |
bceb4d99 | 308 | self.wait_for_console_pattern('Starting kernel ...') |
bceb4d99 | 309 | |
92f8e8e2 | 310 | @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab') |
bceb4d99 CLG |
311 | def test_arm_ast2500_evb_sdk(self): |
312 | """ | |
313 | :avocado: tags=arch:arm | |
314 | :avocado: tags=machine:ast2500-evb | |
315 | """ | |
316 | ||
317 | image_url = ('https://github.com/AspeedTech-BMC/openbmc/releases/' | |
318 | 'download/v08.01/ast2500-default-obmc.tar.gz') | |
319 | image_hash = ('5375f82b4c43a79427909342a1e18b4e48bd663e38466862145d27bb358796fd') | |
320 | image_path = self.fetch_asset(image_url, asset_hash=image_hash, | |
321 | algorithm='sha256') | |
322 | archive.extract(image_path, self.workdir) | |
323 | ||
324 | self.do_test_arm_aspeed_sdk_start( | |
a4b14b46 | 325 | self.workdir + '/ast2500-default/image-bmc') |
bceb4d99 CLG |
326 | self.wait_for_console_pattern('ast2500-default login:') |
327 | ||
92f8e8e2 | 328 | @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab') |
bceb4d99 CLG |
329 | def test_arm_ast2600_evb_sdk(self): |
330 | """ | |
331 | :avocado: tags=arch:arm | |
332 | :avocado: tags=machine:ast2600-evb | |
333 | """ | |
334 | ||
335 | image_url = ('https://github.com/AspeedTech-BMC/openbmc/releases/' | |
336 | 'download/v08.01/ast2600-default-obmc.tar.gz') | |
337 | image_hash = ('f12ef15e8c1f03a214df3b91c814515c5e2b2f56119021398c1dbdd626817d15') | |
338 | image_path = self.fetch_asset(image_url, asset_hash=image_hash, | |
339 | algorithm='sha256') | |
340 | archive.extract(image_path, self.workdir) | |
341 | ||
342 | self.vm.add_args('-device', | |
343 | 'tmp105,bus=aspeed.i2c.bus.5,address=0x4d,id=tmp-test'); | |
344 | self.vm.add_args('-device', | |
345 | 'ds1338,bus=aspeed.i2c.bus.5,address=0x32'); | |
346 | self.do_test_arm_aspeed_sdk_start( | |
a4b14b46 | 347 | self.workdir + '/ast2600-default/image-bmc') |
bceb4d99 CLG |
348 | self.wait_for_console_pattern('ast2600-default login:') |
349 | exec_command_and_wait_for_pattern(self, 'root', 'Password:') | |
350 | exec_command_and_wait_for_pattern(self, '0penBmc', 'root@ast2600-default:~#') | |
351 | ||
352 | exec_command_and_wait_for_pattern(self, | |
353 | 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-5/device/new_device', | |
354 | 'i2c i2c-5: new_device: Instantiated device lm75 at 0x4d'); | |
355 | exec_command_and_wait_for_pattern(self, | |
356 | 'cat /sys/class/hwmon/hwmon19/temp1_input', '0') | |
357 | self.vm.command('qom-set', path='/machine/peripheral/tmp-test', | |
358 | property='temperature', value=18000); | |
359 | exec_command_and_wait_for_pattern(self, | |
360 | 'cat /sys/class/hwmon/hwmon19/temp1_input', '18000') | |
361 | ||
362 | exec_command_and_wait_for_pattern(self, | |
363 | 'echo ds1307 0x32 > /sys/class/i2c-dev/i2c-5/device/new_device', | |
364 | 'i2c i2c-5: new_device: Instantiated device ds1307 at 0x32'); | |
365 | year = time.strftime("%Y") | |
366 | exec_command_and_wait_for_pattern(self, 'hwclock -f /dev/rtc1', year); |