| 1 | #!/usr/bin/env python3 |
| 2 | # |
| 3 | # Functional test that boots the ASPEED machines |
| 4 | # |
| 5 | # SPDX-License-Identifier: GPL-2.0-or-later |
| 6 | |
| 7 | import os |
| 8 | import time |
| 9 | import tempfile |
| 10 | import subprocess |
| 11 | |
| 12 | from aspeed import AspeedTest |
| 13 | from qemu_test import Asset |
| 14 | from qemu_test import exec_command_and_wait_for_pattern |
| 15 | |
| 16 | |
| 17 | class AST2600Machine(AspeedTest): |
| 18 | |
| 19 | ASSET_BR2_202511_AST2600_FLASH = Asset( |
| 20 | ('https://github.com/legoater/qemu-aspeed-boot/raw/master/' |
| 21 | 'images/ast2600-evb/buildroot-2025.11/flash.img'), |
| 22 | 'c64a0755501393d570ca318e326e1e9f8372edc5a6452cdccc3649bc9fd2c138') |
| 23 | |
| 24 | def test_arm_ast2600_evb_buildroot(self): |
| 25 | self.set_machine('ast2600-evb') |
| 26 | |
| 27 | image_path = self.ASSET_BR2_202511_AST2600_FLASH.fetch() |
| 28 | |
| 29 | self.vm.add_args('-device', |
| 30 | 'tmp105,bus=aspeed.i2c.bus.3,address=0x4d,id=tmp-test') |
| 31 | self.vm.add_args('-device', |
| 32 | 'ds1338,bus=aspeed.i2c.bus.3,address=0x32') |
| 33 | self.vm.add_args('-device', |
| 34 | 'i2c-echo,bus=aspeed.i2c.bus.3,address=0x42') |
| 35 | self.do_test_arm_aspeed_buildroot_start(image_path, '0xf00', |
| 36 | 'ast2600-evb login:') |
| 37 | |
| 38 | exec_command_and_wait_for_pattern(self, |
| 39 | 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-3/device/new_device', |
| 40 | 'i2c i2c-3: new_device: Instantiated device lm75 at 0x4d') |
| 41 | exec_command_and_wait_for_pattern(self, |
| 42 | 'cat /sys/class/hwmon/hwmon1/temp1_input', '0') |
| 43 | self.vm.cmd('qom-set', path='/machine/peripheral/tmp-test', |
| 44 | property='temperature', value=18000) |
| 45 | exec_command_and_wait_for_pattern(self, |
| 46 | 'cat /sys/class/hwmon/hwmon1/temp1_input', '18000') |
| 47 | |
| 48 | exec_command_and_wait_for_pattern(self, |
| 49 | 'echo ds1307 0x32 > /sys/class/i2c-dev/i2c-3/device/new_device', |
| 50 | 'i2c i2c-3: new_device: Instantiated device ds1307 at 0x32') |
| 51 | year = time.strftime("%Y") |
| 52 | exec_command_and_wait_for_pattern(self, 'hwclock -f /dev/rtc1', year) |
| 53 | |
| 54 | exec_command_and_wait_for_pattern(self, |
| 55 | 'echo slave-24c02 0x1064 > /sys/bus/i2c/devices/i2c-3/new_device', |
| 56 | 'i2c i2c-3: new_device: Instantiated device slave-24c02 at 0x64') |
| 57 | exec_command_and_wait_for_pattern(self, |
| 58 | 'i2cset -y 3 0x42 0x64 0x00 0xaa i', '#') |
| 59 | exec_command_and_wait_for_pattern(self, |
| 60 | 'hexdump /sys/bus/i2c/devices/3-1064/slave-eeprom', |
| 61 | '0000000 ffaa ffff ffff ffff ffff ffff ffff ffff') |
| 62 | self.do_test_arm_aspeed_buildroot_poweroff() |
| 63 | |
| 64 | |
| 65 | if __name__ == '__main__': |
| 66 | AspeedTest.main() |