master
py 48 lines 1.65 KB
Raw
1 #!/usr/bin/env python3
2 #
3 # Functional test that checks the max78000fthr machine.
4 # Tests ICC, GCR, TRNG, AES, and UART
5 #
6 # SPDX-License-Identifier: GPL-2.0-or-later
7
8 from qemu_test import QemuSystemTest, Asset, exec_command_and_wait_for_pattern
9 from qemu_test import wait_for_console_pattern
10
11
12 class Max78000Machine(QemuSystemTest):
13
14 ASSET_FW = Asset(
15 'https://github.com/JacksonDonaldson/max78000Test/raw/main/build/max78000.bin',
16 '86940b4bf60931bc6a8aa5db4b9f7f3cf8f64dbbd7ac534647980e536cf3adf7')
17
18 def test_fthr(self):
19 self.set_machine('max78000fthr')
20 fw_path = self.ASSET_FW.fetch()
21 self.vm.set_console()
22 self.vm.add_args('-kernel', fw_path)
23 self.vm.add_args('-device', "loader,file=" + fw_path + ",addr=0x10000000")
24 self.vm.launch()
25
26 wait_for_console_pattern(self, 'started')
27
28 # i -> prints instruction cache values
29 exec_command_and_wait_for_pattern(self, 'i', 'CTRL: 00010001')
30
31 # r -> gcr resets the machine
32 exec_command_and_wait_for_pattern(self, 'r', 'started')
33
34 # z -> sets some memory, then has gcr zero it
35 exec_command_and_wait_for_pattern(self, 'z', 'initial value: 12345678')
36 wait_for_console_pattern(self, "after memz: 00000000")
37
38 # t -> runs trng
39 exec_command_and_wait_for_pattern(self, 't', 'random data:')
40
41 # a -> runs aes
42 exec_command_and_wait_for_pattern(self, 'a',
43 'encrypted to : a47ca9dd e0df4c86 a070af6e 91710dec')
44 wait_for_console_pattern(self,
45 'encrypted to : cab7a28e bf456751 9049fcea 8960494b')
46
47 if __name__ == '__main__':
48 QemuSystemTest.main()