]>
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 |
f7bc7da0 | 10 | |
438eff63 JL |
11 | from avocado_qemu import QemuSystemTest |
12 | from avocado_qemu import wait_for_console_pattern | |
f7bc7da0 | 13 | from avocado_qemu import exec_command |
438eff63 | 14 | from avocado_qemu import exec_command_and_wait_for_pattern |
a4b14b46 | 15 | from avocado_qemu import interrupt_interactive_console_until_pattern |
438eff63 | 16 | from avocado.utils import archive |
92f8e8e2 | 17 | from avocado import skipIf |
438eff63 JL |
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") | |
341e21fa CLG |
43 | |
44 | class AST2x00Machine(QemuSystemTest): | |
45 | ||
b1ceae2f AB |
46 | timeout = 90 |
47 | ||
341e21fa CLG |
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) | |
f7bc7da0 | 95 | |
7b5093b8 | 96 | def do_test_arm_aspeed_buildroot_start(self, image, cpu_id): |
0793fe01 PM |
97 | self.require_netdev('user') |
98 | ||
f7bc7da0 CLG |
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') | |
65711f9a | 109 | # the line before login: |
f7bc7da0 | 110 | self.wait_for_console_pattern('Aspeed EVB') |
65711f9a | 111 | time.sleep(0.1) |
f7bc7da0 CLG |
112 | exec_command(self, 'root') |
113 | time.sleep(0.1) | |
114 | ||
7b5093b8 | 115 | def do_test_arm_aspeed_buildroot_poweroff(self): |
f7bc7da0 CLG |
116 | exec_command_and_wait_for_pattern(self, 'poweroff', |
117 | 'reboot: System halted'); | |
118 | ||
7b5093b8 | 119 | def test_arm_ast2500_evb_buildroot(self): |
f7bc7da0 CLG |
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/' | |
ed1f5ff8 CLG |
126 | 'images/ast2500-evb/buildroot-2022.11-2-g15d3648df9/flash.img') |
127 | image_hash = ('f96d11db521fe7a2787745e9e391225deeeec3318ee0fc07c8b799b8833dd474') | |
f7bc7da0 CLG |
128 | image_path = self.fetch_asset(image_url, asset_hash=image_hash, |
129 | algorithm='sha256') | |
130 | ||
7a7308ea CLG |
131 | self.vm.add_args('-device', |
132 | 'tmp105,bus=aspeed.i2c.bus.3,address=0x4d,id=tmp-test'); | |
7b5093b8 | 133 | self.do_test_arm_aspeed_buildroot_start(image_path, '0x0') |
7a7308ea CLG |
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 | ||
7b5093b8 | 145 | self.do_test_arm_aspeed_buildroot_poweroff() |
f7bc7da0 | 146 | |
7b5093b8 | 147 | def test_arm_ast2600_evb_buildroot(self): |
f7bc7da0 CLG |
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/' | |
ed1f5ff8 CLG |
154 | 'images/ast2600-evb/buildroot-2022.11-2-g15d3648df9/flash.img') |
155 | image_hash = ('e598d86e5ea79671ca8b59212a326c911bc8bea728dec1a1f5390d717a28bb8b') | |
f7bc7da0 CLG |
156 | image_path = self.fetch_asset(image_url, asset_hash=image_hash, |
157 | algorithm='sha256') | |
158 | ||
61cf757d CLG |
159 | self.vm.add_args('-device', |
160 | 'tmp105,bus=aspeed.i2c.bus.3,address=0x4d,id=tmp-test'); | |
3302184f CLG |
161 | self.vm.add_args('-device', |
162 | 'ds1338,bus=aspeed.i2c.bus.3,address=0x32'); | |
7b5093b8 | 163 | self.do_test_arm_aspeed_buildroot_start(image_path, '0xf00') |
61cf757d CLG |
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 | ||
3302184f CLG |
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 | ||
7b5093b8 | 181 | self.do_test_arm_aspeed_buildroot_poweroff() |
bceb4d99 CLG |
182 | |
183 | ||
92f8e8e2 AB |
184 | class AST2x00MachineSDK(QemuSystemTest): |
185 | ||
a4b14b46 CLG |
186 | EXTRA_BOOTARGS = ' quiet' |
187 | ||
92f8e8e2 AB |
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 | ||
a4b14b46 | 200 | def do_test_arm_aspeed_sdk_start(self, image): |
0793fe01 | 201 | self.require_netdev('user') |
bceb4d99 CLG |
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') | |
a4b14b46 CLG |
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') | |
bceb4d99 | 214 | self.wait_for_console_pattern('Starting kernel ...') |
bceb4d99 | 215 | |
92f8e8e2 | 216 | @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab') |
bceb4d99 CLG |
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( | |
a4b14b46 | 231 | self.workdir + '/ast2500-default/image-bmc') |
bceb4d99 CLG |
232 | self.wait_for_console_pattern('ast2500-default login:') |
233 | ||
92f8e8e2 | 234 | @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab') |
bceb4d99 CLG |
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( | |
a4b14b46 | 253 | self.workdir + '/ast2600-default/image-bmc') |
bceb4d99 CLG |
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); |