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.
13 from avocado_qemu
import LinuxSSHMixIn
14 from avocado_qemu
import QemuSystemTest
15 from avocado_qemu
import wait_for_console_pattern
16 from avocado_qemu
import exec_command
17 from avocado_qemu
import exec_command_and_wait_for_pattern
18 from avocado_qemu
import interrupt_interactive_console_until_pattern
19 from avocado_qemu
import has_cmd
20 from avocado
.utils
import archive
21 from avocado
import skipIf
22 from avocado
import skipUnless
25 class AST1030Machine(QemuSystemTest
):
26 """Boots the zephyr os and checks that the console is operational"""
30 def test_ast1030_zephyros_1_04(self
):
32 :avocado: tags=arch:arm
33 :avocado: tags=machine:ast1030-evb
34 :avocado: tags=os:zephyr
36 tar_url
= ('https://github.com/AspeedTech-BMC'
37 '/zephyr/releases/download/v00.01.04/ast1030-evb-demo.zip')
38 tar_hash
= '4c6a8ce3a8ba76ef1a65dae419ae3409343c4b20'
39 tar_path
= self
.fetch_asset(tar_url
, asset_hash
=tar_hash
)
40 archive
.extract(tar_path
, self
.workdir
)
41 kernel_file
= self
.workdir
+ "/ast1030-evb-demo/zephyr.elf"
43 self
.vm
.add_args('-kernel', kernel_file
,
46 wait_for_console_pattern(self
, "Booting Zephyr OS")
47 exec_command_and_wait_for_pattern(self
, "help",
50 def test_ast1030_zephyros_1_07(self
):
52 :avocado: tags=arch:arm
53 :avocado: tags=machine:ast1030-evb
54 :avocado: tags=os:zephyr
56 tar_url
= ('https://github.com/AspeedTech-BMC'
57 '/zephyr/releases/download/v00.01.07/ast1030-evb-demo.zip')
58 tar_hash
= '40ac87eabdcd3b3454ce5aad11fedc72a33ecda2'
59 tar_path
= self
.fetch_asset(tar_url
, asset_hash
=tar_hash
)
60 archive
.extract(tar_path
, self
.workdir
)
61 kernel_file
= self
.workdir
+ "/ast1030-evb-demo/zephyr.bin"
63 self
.vm
.add_args('-kernel', kernel_file
,
66 wait_for_console_pattern(self
, "Booting Zephyr OS")
72 'crypto aes256_cbc_vault',
74 'jtag JTAG1 sw_xfer high TMS',
75 'adc ADC0 resolution 12',
86 ]: exec_command_and_wait_for_pattern(self
, shell_cmd
, "uart:~$")
88 class AST2x00Machine(QemuSystemTest
):
92 def wait_for_console_pattern(self
, success_message
, vm
=None):
93 wait_for_console_pattern(self
, success_message
,
94 failure_message
='Kernel panic - not syncing',
97 def do_test_arm_aspeed(self
, image
):
99 self
.vm
.add_args('-drive', 'file=' + image
+ ',if=mtd,format=raw',
103 self
.wait_for_console_pattern("U-Boot 2016.07")
104 self
.wait_for_console_pattern("## Loading kernel from FIT Image at 20080000")
105 self
.wait_for_console_pattern("Starting kernel ...")
106 self
.wait_for_console_pattern("Booting Linux on physical CPU 0x0")
107 wait_for_console_pattern(self
,
108 "aspeed-smc 1e620000.spi: read control register: 203b0641")
109 self
.wait_for_console_pattern("ftgmac100 1e660000.ethernet eth0: irq ")
110 self
.wait_for_console_pattern("systemd[1]: Set hostname to")
112 def test_arm_ast2400_palmetto_openbmc_v2_9_0(self
):
114 :avocado: tags=arch:arm
115 :avocado: tags=machine:palmetto-bmc
118 image_url
= ('https://github.com/openbmc/openbmc/releases/download/2.9.0/'
119 'obmc-phosphor-image-palmetto.static.mtd')
120 image_hash
= ('3e13bbbc28e424865dc42f35ad672b10f2e82cdb11846bb28fa625b48beafd0d')
121 image_path
= self
.fetch_asset(image_url
, asset_hash
=image_hash
,
124 self
.do_test_arm_aspeed(image_path
)
126 def test_arm_ast2500_romulus_openbmc_v2_9_0(self
):
128 :avocado: tags=arch:arm
129 :avocado: tags=machine:romulus-bmc
132 image_url
= ('https://github.com/openbmc/openbmc/releases/download/2.9.0/'
133 'obmc-phosphor-image-romulus.static.mtd')
134 image_hash
= ('820341076803f1955bc31e647a512c79f9add4f5233d0697678bab4604c7bb25')
135 image_path
= self
.fetch_asset(image_url
, asset_hash
=image_hash
,
138 self
.do_test_arm_aspeed(image_path
)
140 def do_test_arm_aspeed_buildroot_start(self
, image
, cpu_id
, pattern
='Aspeed EVB'):
141 self
.require_netdev('user')
143 self
.vm
.set_console()
144 self
.vm
.add_args('-drive', 'file=' + image
+ ',if=mtd,format=raw',
145 '-net', 'nic', '-net', 'user')
148 self
.wait_for_console_pattern('U-Boot 2019.04')
149 self
.wait_for_console_pattern('## Loading kernel from FIT Image')
150 self
.wait_for_console_pattern('Starting kernel ...')
151 self
.wait_for_console_pattern('Booting Linux on physical CPU ' + cpu_id
)
152 self
.wait_for_console_pattern('lease of 10.0.2.15')
153 # the line before login:
154 self
.wait_for_console_pattern(pattern
)
156 exec_command(self
, 'root')
159 def do_test_arm_aspeed_buildroot_poweroff(self
):
160 exec_command_and_wait_for_pattern(self
, 'poweroff',
161 'reboot: System halted');
163 def test_arm_ast2500_evb_buildroot(self
):
165 :avocado: tags=arch:arm
166 :avocado: tags=machine:ast2500-evb
169 image_url
= ('https://github.com/legoater/qemu-aspeed-boot/raw/master/'
170 'images/ast2500-evb/buildroot-2022.11-2-g15d3648df9/flash.img')
171 image_hash
= ('f96d11db521fe7a2787745e9e391225deeeec3318ee0fc07c8b799b8833dd474')
172 image_path
= self
.fetch_asset(image_url
, asset_hash
=image_hash
,
175 self
.vm
.add_args('-device',
176 'tmp105,bus=aspeed.i2c.bus.3,address=0x4d,id=tmp-test');
177 self
.do_test_arm_aspeed_buildroot_start(image_path
, '0x0')
179 exec_command_and_wait_for_pattern(self
,
180 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-3/device/new_device',
181 'i2c i2c-3: new_device: Instantiated device lm75 at 0x4d');
182 exec_command_and_wait_for_pattern(self
,
183 'cat /sys/class/hwmon/hwmon1/temp1_input', '0')
184 self
.vm
.cmd('qom-set', path
='/machine/peripheral/tmp-test',
185 property='temperature', value
=18000);
186 exec_command_and_wait_for_pattern(self
,
187 'cat /sys/class/hwmon/hwmon1/temp1_input', '18000')
189 self
.do_test_arm_aspeed_buildroot_poweroff()
191 def test_arm_ast2600_evb_buildroot(self
):
193 :avocado: tags=arch:arm
194 :avocado: tags=machine:ast2600-evb
197 image_url
= ('https://github.com/legoater/qemu-aspeed-boot/raw/master/'
198 'images/ast2600-evb/buildroot-2022.11-2-g15d3648df9/flash.img')
199 image_hash
= ('e598d86e5ea79671ca8b59212a326c911bc8bea728dec1a1f5390d717a28bb8b')
200 image_path
= self
.fetch_asset(image_url
, asset_hash
=image_hash
,
203 self
.vm
.add_args('-device',
204 'tmp105,bus=aspeed.i2c.bus.3,address=0x4d,id=tmp-test');
205 self
.vm
.add_args('-device',
206 'ds1338,bus=aspeed.i2c.bus.3,address=0x32');
207 self
.vm
.add_args('-device',
208 'i2c-echo,bus=aspeed.i2c.bus.3,address=0x42');
209 self
.do_test_arm_aspeed_buildroot_start(image_path
, '0xf00')
211 exec_command_and_wait_for_pattern(self
,
212 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-3/device/new_device',
213 'i2c i2c-3: new_device: Instantiated device lm75 at 0x4d');
214 exec_command_and_wait_for_pattern(self
,
215 'cat /sys/class/hwmon/hwmon0/temp1_input', '0')
216 self
.vm
.cmd('qom-set', path
='/machine/peripheral/tmp-test',
217 property='temperature', value
=18000);
218 exec_command_and_wait_for_pattern(self
,
219 'cat /sys/class/hwmon/hwmon0/temp1_input', '18000')
221 exec_command_and_wait_for_pattern(self
,
222 'echo ds1307 0x32 > /sys/class/i2c-dev/i2c-3/device/new_device',
223 'i2c i2c-3: new_device: Instantiated device ds1307 at 0x32');
224 year
= time
.strftime("%Y")
225 exec_command_and_wait_for_pattern(self
, 'hwclock -f /dev/rtc1', year
);
227 exec_command_and_wait_for_pattern(self
,
228 'echo slave-24c02 0x1064 > /sys/bus/i2c/devices/i2c-3/new_device',
229 'i2c i2c-3: new_device: Instantiated device slave-24c02 at 0x64');
230 exec_command(self
, 'i2cset -y 3 0x42 0x64 0x00 0xaa i');
232 exec_command_and_wait_for_pattern(self
,
233 'hexdump /sys/bus/i2c/devices/3-1064/slave-eeprom',
234 '0000000 ffaa ffff ffff ffff ffff ffff ffff ffff');
235 self
.do_test_arm_aspeed_buildroot_poweroff()
237 @skipUnless(*has_cmd('swtpm'))
238 def test_arm_ast2600_evb_buildroot_tpm(self
):
240 :avocado: tags=arch:arm
241 :avocado: tags=machine:ast2600-evb
244 image_url
= ('https://github.com/legoater/qemu-aspeed-boot/raw/master/'
245 'images/ast2600-evb/buildroot-2023.02-tpm/flash.img')
246 image_hash
= ('a46009ae8a5403a0826d607215e731a8c68d27c14c41e55331706b8f9c7bd997')
247 image_path
= self
.fetch_asset(image_url
, asset_hash
=image_hash
,
250 # force creation of VM object, which also defines self._sd
253 socket
= os
.path
.join(self
._sd
.name
, 'swtpm-socket')
255 subprocess
.run(['swtpm', 'socket', '-d', '--tpm2',
256 '--tpmstate', f
'dir={self.vm.temp_dir}',
257 '--ctrl', f
'type=unixio,path={socket}'])
259 self
.vm
.add_args('-chardev', f
'socket,id=chrtpm,path={socket}')
260 self
.vm
.add_args('-tpmdev', 'emulator,id=tpm0,chardev=chrtpm')
261 self
.vm
.add_args('-device',
262 'tpm-tis-i2c,tpmdev=tpm0,bus=aspeed.i2c.bus.12,address=0x2e')
263 self
.do_test_arm_aspeed_buildroot_start(image_path
, '0xf00', 'Aspeed AST2600 EVB')
264 exec_command(self
, "passw0rd")
266 exec_command_and_wait_for_pattern(self
,
267 'echo tpm_tis_i2c 0x2e > /sys/bus/i2c/devices/i2c-12/new_device',
268 'tpm_tis_i2c 12-002e: 2.0 TPM (device-id 0x1, rev-id 1)');
269 exec_command_and_wait_for_pattern(self
,
270 'cat /sys/class/tpm/tpm0/pcr-sha256/0',
271 'B804724EA13F52A9072BA87FE8FDCC497DFC9DF9AA15B9088694639C431688E0');
273 self
.do_test_arm_aspeed_buildroot_poweroff()
275 class AST2x00MachineSDK(QemuSystemTest
, LinuxSSHMixIn
):
279 'systemd.mask=org.openbmc.HostIpmi.service '
280 'systemd.mask=xyz.openbmc_project.Chassis.Control.Power@0.service '
281 'systemd.mask=modprobe@fuse.service '
282 'systemd.mask=rngd.service '
283 'systemd.mask=obmc-console@ttyS2.service '
286 # FIXME: Although these tests boot a whole distro they are still
287 # slower than comparable machine models. There may be some
288 # optimisations which bring down the runtime. In the meantime they
289 # have generous timeouts and are disable for CI which aims for all
290 # tests to run in less than 60 seconds.
293 def wait_for_console_pattern(self
, success_message
, vm
=None):
294 wait_for_console_pattern(self
, success_message
,
295 failure_message
='Kernel panic - not syncing',
298 def do_test_arm_aspeed_sdk_start(self
, image
):
299 self
.require_netdev('user')
300 self
.vm
.set_console()
301 self
.vm
.add_args('-drive', 'file=' + image
+ ',if=mtd,format=raw',
302 '-net', 'nic', '-net', 'user,hostfwd=:127.0.0.1:0-:22')
305 self
.wait_for_console_pattern('U-Boot 2019.04')
306 interrupt_interactive_console_until_pattern(
307 self
, 'Hit any key to stop autoboot:', 'ast#')
308 exec_command_and_wait_for_pattern(
309 self
, 'setenv bootargs ${bootargs} ' + self
.EXTRA_BOOTARGS
, 'ast#')
310 exec_command_and_wait_for_pattern(
311 self
, 'boot', '## Loading kernel from FIT Image')
312 self
.wait_for_console_pattern('Starting kernel ...')
314 @skipIf(os
.getenv('GITLAB_CI'), 'Running on GitLab')
315 def test_arm_ast2500_evb_sdk(self
):
317 :avocado: tags=arch:arm
318 :avocado: tags=machine:ast2500-evb
321 image_url
= ('https://github.com/AspeedTech-BMC/openbmc/releases/'
322 'download/v08.06/ast2500-default-obmc.tar.gz')
323 image_hash
= ('e1755f3cadff69190438c688d52dd0f0d399b70a1e14b1d3d5540fc4851d38ca')
324 image_path
= self
.fetch_asset(image_url
, asset_hash
=image_hash
,
326 archive
.extract(image_path
, self
.workdir
)
328 self
.do_test_arm_aspeed_sdk_start(
329 self
.workdir
+ '/ast2500-default/image-bmc')
330 self
.wait_for_console_pattern('nodistro.0 ast2500-default ttyS4')
332 @skipIf(os
.getenv('GITLAB_CI'), 'Running on GitLab')
333 def test_arm_ast2600_evb_sdk(self
):
335 :avocado: tags=arch:arm
336 :avocado: tags=machine:ast2600-evb
339 image_url
= ('https://github.com/AspeedTech-BMC/openbmc/releases/'
340 'download/v08.06/ast2600-a2-obmc.tar.gz')
341 image_hash
= ('9083506135f622d5e7351fcf7d4e1c7125cee5ba16141220c0ba88931f3681a4')
342 image_path
= self
.fetch_asset(image_url
, asset_hash
=image_hash
,
344 archive
.extract(image_path
, self
.workdir
)
346 self
.vm
.add_args('-device',
347 'tmp105,bus=aspeed.i2c.bus.5,address=0x4d,id=tmp-test');
348 self
.vm
.add_args('-device',
349 'ds1338,bus=aspeed.i2c.bus.5,address=0x32');
350 self
.do_test_arm_aspeed_sdk_start(
351 self
.workdir
+ '/ast2600-a2/image-bmc')
352 self
.wait_for_console_pattern('nodistro.0 ast2600-a2 ttyS4')
354 self
.ssh_connect('root', '0penBmc', False)
355 self
.ssh_command('dmesg -c > /dev/null')
357 self
.ssh_command_output_contains(
358 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-5/device/new_device ; '
360 'i2c i2c-5: new_device: Instantiated device lm75 at 0x4d');
361 self
.ssh_command_output_contains(
362 'cat /sys/class/hwmon/hwmon19/temp1_input', '0')
363 self
.vm
.cmd('qom-set', path
='/machine/peripheral/tmp-test',
364 property='temperature', value
=18000);
365 self
.ssh_command_output_contains(
366 'cat /sys/class/hwmon/hwmon19/temp1_input', '18000')
368 self
.ssh_command_output_contains(
369 'echo ds1307 0x32 > /sys/class/i2c-dev/i2c-5/device/new_device ; '
371 'i2c i2c-5: new_device: Instantiated device ds1307 at 0x32');
372 year
= time
.strftime("%Y")
373 self
.ssh_command_output_contains('/sbin/hwclock -f /dev/rtc1', year
);