tests/functional/arm: Add OTP functional test
cover tests/functional/arm: Add OTP functional test
From: Kane-Chen-AS <[email protected]>
Hi all,
During early boot, SoC firmware reads from the OTP region to obtain the chip ID and default configuration. This series adds functional tests that boot with a generated OTP image and verify that the firmware reads these contents correctly during initialization.
Any feedback or suggestions are appreciated.
Best Regards,
Kane
---
Kane-Chen-AS (3):
tests/functional/arm: Add helper to generate OTP images tests/functional/arm: Add AST1030 boot test with prebuilt OTP image tests/functional/arm: Add AST2600 boot test with prebuilt OTP image
tests/functional/arm/test_aspeed_ast1030.py | 20 ++++++++++++++++++-- tests/functional/arm/test_aspeed_ast2600.py | 14 ++++++++++++++ tests/functional/aspeed.py | 7 +++++++ 3 files changed, 39 insertions(+), 2 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/3 tests/functional/arm: Add helper to generate OTP images
From: Kane-Chen-AS <[email protected]>
Add a small helper that generates OTP images at test time. This lets multiple test cases create default OTP contents without shipping prebuilt fixtures and keeps the tests self-contained.
--- tests/functional/aspeed.py | 7 +++++++ 1 file changed, 7 insertions(+)
tests/functional/aspeed.py +7 -0
@@ -61,3 +61,10 @@ def do_test_arm_aspeed_sdk_start(self, image): self.wait_for_console_pattern('U-Boot 2019.04') self.wait_for_console_pattern('## Loading kernel from FIT Image') self.wait_for_console_pattern('Starting kernel ...') + + def generate_otpmem_image(self): + path = self.scratch_file("otpmem.img") + pattern = b'\x00\x00\x00\x00\xff\xff\xff\xff' * (16 * 1024 // 8) + with open(path, "wb") as f: + f.write(pattern) + return path
Signature · 1 line
2.43.0
Re: [SPAM] [PATCH v1 1/3] tests/functional/arm: Add helper to generate OTP images
Hello Kane,
Quoted 17 lines · Kane Chen
From: Kane-Chen-AS <[email protected]>
Add a small helper that generates OTP images at test time. This lets multiple test cases create default OTP contents without shipping prebuilt fixtures and keeps the tests self-contained.
Signed-off-by Kane-Chen-AS <[email protected]>--- tests/functional/aspeed.py | 7 +++++++ 1 file changed, 7 insertions(+)tests/functional/aspeed.py +0
-0@@ -61,3 +61,10 @@ def do_test_arm_aspeed_sdk_start(self, image): self.wait_for_console_pattern('U-Boot 2019.04')
tests/functional/aspeed.py def do_test_arm_aspeed_sdk_start(self, image): · line 70
Quoted 10 lines
tests/functional/aspeed.py +7
-0self.wait_for_console_pattern('## Loading kernel from FIT Image') self.wait_for_console_pattern('Starting kernel ...') + + def generate_otpmem_image(self): + path = self.scratch_file("otpmem.img") + pattern = b'\x00\x00\x00\x00\xff\xff\xff\xff' * (16 * 1024 // 8) + with open(path, "wb") as f: + f.write(pattern) + return path
Please add a new line.
Thanks,
C.
PATCH 2/3 tests/functional/arm: Add AST1030 boot test with generated OTP image
In reply to Kane Chen viaFrom: Kane-Chen-AS <[email protected]>
Add a functional test that boots an AST1030 machine with a generated OTP image. The test verifies that OTP contents are read during early boot and that the system reaches the expected console prompt.
--- tests/functional/arm/test_aspeed_ast1030.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
tests/functional/arm/test_aspeed_ast1030.py +18 -2
@@ -7,10 +7,11 @@ # SPDX-License-Identifier: GPL-2.0-or-later from qemu_test import LinuxKernelTest, Asset +from aspeed import AspeedTest from qemu_test import exec_command_and_wait_for_pattern -class AST1030Machine(LinuxKernelTest): +class AST1030Machine(AspeedTest): ASSET_ZEPHYR_3_02 = Asset( ('https://github.com/AspeedTech-BMC'
@@ -68,6 +69,21 @@ def test_ast1030_zephyros_1_07(self): 'kernel uptime', ]: exec_command_and_wait_for_pattern(self, shell_cmd, "uart:~$") + def test_ast1030_otp_blockdev_device(self): + self.vm.set_machine("ast1030-evb") + + kernel_name = "ast1030-evb-demo-3/zephyr.elf" + kernel_file = self.archive_extract(self.ASSET_ZEPHYR_3_02, member=kernel_name) + otp_img = self.generate_otpmem_image() + + self.vm.set_console() + self.vm.add_args( + "-kernel", kernel_file, + "-blockdev", f"driver=file,filename={otp_img},node-name=otp", + "-global", "aspeed-otp.drive=otp", + ) + self.vm.launch() + self.wait_for_console_pattern("Booting Zephyr OS") if __name__ == '__main__': - LinuxKernelTest.main() + AspeedTest.main()
Signature · 1 line
2.43.0
Re: [SPAM] [PATCH v1 2/3] tests/functional/arm: Add AST1030 boot test with generated OTP image
Quoted 29 lines · Kane Chen
From: Kane-Chen-AS <[email protected]>
Add a functional test that boots an AST1030 machine with a generated OTP image. The test verifies that OTP contents are read during early boot and that the system reaches the expected console prompt.
Signed-off-by Kane-Chen-AS <[email protected]>--- tests/functional/arm/test_aspeed_ast1030.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)tests/functional/arm/test_aspeed_ast1030.py +2
-1@@ -7,10 +7,11 @@ # SPDX-License-Identifier: GPL-2.0-or-later from qemu_test import LinuxKernelTest, Asset +from aspeed import AspeedTest from qemu_test import exec_command_and_wait_for_pattern -class AST1030Machine(LinuxKernelTest): +class AST1030Machine(AspeedTest): ASSET_ZEPHYR_3_02 = Asset( ('https://github.com/AspeedTech-BMC'
tests/functional/arm/test_aspeed_ast1030.py def test_ast1030_zephyros_1_07(self): · line 72
Quoted 4 lines
tests/functional/arm/test_aspeed_ast1030.py +1
-0@@ -68,6 +69,21 @@ def test_ast1030_zephyros_1_07(self): 'kernel uptime', ]: exec_command_and_wait_for_pattern(self, shell_cmd, "uart:~$") + def test_ast1030_otp_blockdev_device(self):
To have a consistent name with the other tests, please use a test_arm_ prefix.
Thanks,
C.
Quoted 18 lines
tests/functional/arm/test_aspeed_ast1030.py +15
-1+ self.vm.set_machine("ast1030-evb") + + kernel_name = "ast1030-evb-demo-3/zephyr.elf" + kernel_file = self.archive_extract(self.ASSET_ZEPHYR_3_02, member=kernel_name) + otp_img = self.generate_otpmem_image() + + self.vm.set_console() + self.vm.add_args( + "-kernel", kernel_file, + "-blockdev", f"driver=file,filename={otp_img},node-name=otp", + "-global", "aspeed-otp.drive=otp", + ) + self.vm.launch() + self.wait_for_console_pattern("Booting Zephyr OS") if __name__ == '__main__': - LinuxKernelTest.main() + AspeedTest.main()
PATCH 3/3 tests/functional/arm: Add AST2600 boot test with generated OTP image
In reply to Kane Chen viaFrom: Kane-Chen-AS <[email protected]>
Add a functional test that boots an AST2600 machine with a generated OTP image. The test verifies that OTP contents are read during early boot and that the system reaches the expected console prompt.
--- tests/functional/arm/test_aspeed_ast2600.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
tests/functional/arm/test_aspeed_ast2600.py +14 -0
@@ -136,5 +136,19 @@ def test_arm_ast2600_evb_sdk(self): exec_command_and_wait_for_pattern(self, '/sbin/hwclock -f /dev/rtc1', year) + def test_ast2600_otp_blockdev_device(self): + self.vm.set_machine("ast2600-evb") + + image_path = self.archive_extract(self.ASSET_SDK_V907_AST2600) + otp_img = self.generate_otpmem_image() + + self.vm.set_console() + self.vm.add_args( + "-blockdev", f"driver=file,filename={otp_img},node-name=otp", + "-global", "aspeed-otp.drive=otp", + ) + self.do_test_arm_aspeed_sdk_start(self.scratch_file("ast2600-default", "image-bmc")) + self.wait_for_console_pattern("ast2600-default login:") + if __name__ == '__main__': AspeedTest.main()
Signature · 1 line
2.43.0
Re: [SPAM] [PATCH v1 3/3] tests/functional/arm: Add AST2600 boot test with generated OTP image
Quoted 16 lines · Kane Chen
From: Kane-Chen-AS <[email protected]>
Add a functional test that boots an AST2600 machine with a generated OTP image. The test verifies that OTP contents are read during early boot and that the system reaches the expected console prompt.
Signed-off-by Kane-Chen-AS <[email protected]>--- tests/functional/arm/test_aspeed_ast2600.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+)tests/functional/arm/test_aspeed_ast2600.py +0
-0
tests/functional/arm/test_aspeed_ast2600.py def test_arm_ast2600_evb_sdk(self): · line 139
Quoted 4 lines
tests/functional/arm/test_aspeed_ast2600.py +1
-0@@ -136,5 +136,19 @@ def test_arm_ast2600_evb_sdk(self): exec_command_and_wait_for_pattern(self, '/sbin/hwclock -f /dev/rtc1', year) + def test_ast2600_otp_blockdev_device(self):
please use a test_arm_ prefix.
Thanks,
C.
Quoted 15 lines
tests/functional/arm/test_aspeed_ast2600.py +13
-0+ self.vm.set_machine("ast2600-evb") + + image_path = self.archive_extract(self.ASSET_SDK_V907_AST2600) + otp_img = self.generate_otpmem_image() + + self.vm.set_console() + self.vm.add_args( + "-blockdev", f"driver=file,filename={otp_img},node-name=otp", + "-global", "aspeed-otp.drive=otp", + ) + self.do_test_arm_aspeed_sdk_start(self.scratch_file("ast2600-default", "image-bmc")) + self.wait_for_console_pattern("ast2600-default login:") + if __name__ == '__main__': AspeedTest.main()
RE: [SPAM] [PATCH v1 3/3] tests/functional/arm: Add AST2600 boot test with generated OTP image
Hi Cédric,
Thanks for the review and feedback. I’ll send a v2 addressing these comments.
Best Regards,
Kane
Quoted 64 lines
-----Original Message-----
From: Cédric Le Goater <[email protected]>
Sent: Tuesday, September 16, 2025 11:58 PM
To: Kane Chen <[email protected]>; Peter Maydell <[email protected]>; Steven Lee <[email protected]>; Troy Lee <[email protected]>; Jamin Lin <[email protected]>; Andrew Jeffery <[email protected]>; Joel Stanley <[email protected]>; open list:ASPEED BMCs <[email protected]>; open list:All patches CC here <[email protected]>
Cc: Troy Lee <[email protected]>; [email protected]
Subject: Re: [SPAM] [PATCH v1 3/3] tests/functional/arm: Add AST2600 boot test with generated OTP imageQuoted 17 lines · Kane Chen
From: Kane-Chen-AS <[email protected]>
Add a functional test that boots an AST2600 machine with a generated OTP image. The test verifies that OTP contents are read during early boot and that the system reaches the expected console prompt.
Signed-off-by Kane-Chen-AS <[email protected]>--- tests/functional/arm/test_aspeed_ast2600.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+)tests/functional/arm/test_aspeed_ast2600.py +0
-0tests/functional/arm/test_aspeed_ast2600.py def test_arm_ast2600_evb_sdk(self): · line 139
Quoted 4 lines
tests/functional/arm/test_aspeed_ast2600.py +1
-0@@ -136,5 +136,19 @@ def test_arm_ast2600_evb_sdk(self): exec_command_and_wait_for_pattern(self, '/sbin/hwclock -f /dev/rtc1', year) + def test_ast2600_otp_blockdev_device(self):please use a
test_arm_prefix.Thanks,
C.
tests/functional/arm/test_aspeed_ast2600.py def test_arm_ast2600_evb_sdk(self):
Quoted 3 lines
tests/functional/arm/test_aspeed_ast2600.py +3
-0+ self.vm.set_machine("ast2600-evb") + + image_path =
self.archive_extract(self.ASSET_SDK_V907_AST2600)tests/functional/arm/test_aspeed_ast2600.py def test_arm_ast2600_evb_sdk(self):
Quoted 5 lines
tests/functional/arm/test_aspeed_ast2600.py +5
-0+ otp_img = self.generate_otpmem_image() + + self.vm.set_console() + self.vm.add_args( + "-blockdev",f"driver=file,filename={otp_img},node-name=otp",
tests/functional/arm/test_aspeed_ast2600.py def test_arm_ast2600_evb_sdk(self): · line 152
Quoted 3 lines
tests/functional/arm/test_aspeed_ast2600.py +3
-0+ "-global", "aspeed-otp.drive=otp", + ) +
self.do_test_arm_aspeed_sdk_start(self.scratch_file("ast2600-default", "image-bmc"))Quoted 4 lines
tests/functional/arm/test_aspeed_ast2600.py +2
-0+ self.wait_for_console_pattern("ast2600-default login:") + if __name__ == '__main__': AspeedTest.main()