Skip to contentSkip to conversation

tests/functional/arm: Add OTP functional test

PATCH Applied Kane Chen via 3 participants 7 messages Sep 17, 2025 Arm/Aspeed machine support

lore
Share & tools
lore
#0 lore raw

v2 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
---
Change log:
v2: Fine-tune test scripts

v1: Initial version
---
Kane-Chen-AS (3):
tests/functional/arm: Add helper to generate OTP images tests/functional/arm: Add AST1030 boot test with generated OTP image tests/functional/arm: Add AST2600 boot test with generated OTP image

 tests/functional/arm/test_aspeed_ast1030.py | 24 +++++++++++++++++----
 tests/functional/arm/test_aspeed_ast2600.py | 14 ++++++++++++
 tests/functional/aspeed.py                  |  8 +++++++
 3 files changed, 42 insertions(+), 4 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 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 | 8 ++++++++
 1 file changed, 8 insertions(+)
tests/functional/aspeed.py +8 -0
index b131703c52..47e84e035b 100644
@@ -61,3 +61,11 @@ 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
#2 lore raw

PATCH v2 2/3 tests/functional/arm: Add AST1030 boot test with generated OTP image

In reply to Kane Chen via

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.

---
 tests/functional/arm/test_aspeed_ast1030.py | 24 +++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)
tests/functional/arm/test_aspeed_ast1030.py +20 -4
index 42126b514f..e47b597d0b 100755
@@ -7,17 +7,18 @@
 # 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'
          '/zephyr/releases/download/v00.03.02/ast1030-evb-demo.zip'),
         '1ec83caab3ddd5d09481772801be7210e222cb015ce22ec6fffb8a76956dcd4f')
 
-    def test_ast1030_zephyros_3_02(self):
+    def test_arm_ast1030_zephyros_3_02(self):
         self.set_machine('ast1030-evb')
 
         kernel_name = "ast1030-evb-demo-3/zephyr.elf"
@@ -36,7 +37,7 @@ def test_ast1030_zephyros_3_02(self):
          '/zephyr/releases/download/v00.01.07/ast1030-evb-demo.zip'),
         'ad52e27959746988afaed8429bf4e12ab988c05c4d07c9d90e13ec6f7be4574c')
 
-    def test_ast1030_zephyros_1_07(self):
+    def test_arm_ast1030_zephyros_1_07(self):
         self.set_machine('ast1030-evb')
 
         kernel_name = "ast1030-evb-demo/zephyr.bin"
@@ -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_arm_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
#3 lore raw

PATCH v2 3/3 tests/functional/arm: Add AST2600 boot test with generated OTP image

In reply to Kane Chen via

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.

---
 tests/functional/arm/test_aspeed_ast2600.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
tests/functional/arm/test_aspeed_ast2600.py +14 -0
index 129695ca4e..87e3595584 100755
@@ -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_arm_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
Reviewed-by on the v2 series
#4 lore raw
In reply to Kane Chen via
Quoted 24 lines · Kane Chen

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
---
Change log:
v2: Fine-tune test scripts

v1: Initial version
---
Kane-Chen-AS (3):
tests/functional/arm: Add helper to generate OTP images tests/functional/arm: Add AST1030 boot test with generated OTP image tests/functional/arm: Add AST2600 boot test with generated OTP image

Quoted 5 lines
  tests/functional/arm/test_aspeed_ast1030.py | 24 +++++++++++++++++----
  tests/functional/arm/test_aspeed_ast2600.py | 14 ++++++++++++
  tests/functional/aspeed.py                  |  8 +++++++
  3 files changed, 42 insertions(+), 4 deletions(-)

For the series,

Thanks,

C.

#5 lore raw

Hi Cédric,

Thanks for the review.

Best Regards,
Kane

Quoted 54 lines

-----Original Message-----
From: Cédric Le Goater <[email protected]>
Sent: Wednesday, September 17, 2025 2:23 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 v2 0/3] tests/functional/arm: Add OTP functional test

Quoted 25 lines · Kane Chen

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
---
Change log:
v2: Fine-tune test scripts

v1: Initial version
---
Kane-Chen-AS (3):
tests/functional/arm: Add helper to generate OTP images tests/functional/arm: Add AST1030 boot test with generated OTP image tests/functional/arm: Add AST2600 boot test with generated OTP
image

Quoted 1 line
  tests/functional/arm/test_aspeed_ast1030.py | 24

+++++++++++++++++----

Quoted 4 lines
  tests/functional/arm/test_aspeed_ast2600.py | 14 ++++++++++++
  tests/functional/aspeed.py                  |  8 +++++++
  3 files changed, 42 insertions(+), 4 deletions(-)

For the series,

Thanks,

C.

#6 lore raw
In reply to Kane Chen via
Quoted 24 lines · Kane Chen

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
---
Change log:
v2: Fine-tune test scripts

v1: Initial version
---
Kane-Chen-AS (3):
tests/functional/arm: Add helper to generate OTP images tests/functional/arm: Add AST1030 boot test with generated OTP image tests/functional/arm: Add AST2600 boot test with generated OTP image

Quoted 5 lines
  tests/functional/arm/test_aspeed_ast1030.py | 24 +++++++++++++++++----
  tests/functional/arm/test_aspeed_ast2600.py | 14 ++++++++++++
  tests/functional/aspeed.py                  |  8 +++++++
  3 files changed, 42 insertions(+), 4 deletions(-)

Applied to aspeed-next.

Thanks,

C.