Skip to contentSkip to conversation

More imx8mp-evk improvements

PATCH Superseded Bernhard Beschow 3 participants 8 messages Apr 5, 2025 – Apr 8, 2025

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover More imx8mp-evk improvements

This series adds a functional test for the imx8mp-evk board with USDHC coverage. Thanks to Guenter Roeck the usage of the board gets simplified by not asking the user to remove the cpu-idle-states properties from the devicetree since that is now done automatically. Likewise, a stack trace during boot is resolved by also automatically removing an offending device node.

Supersedes: [email protected]

Bernhard Beschow (1):
tests/functional: Add test for imx8mp-evk board with USDHC coverage

Guenter Roeck (2):
hw/arm/imx8mp-evk: Remove unimplemented cpu-idle-states properties
from devicetree
hw/arm/imx8mp-evk: Remove unimplemented nxp,imx8mp-fspi node from
devicetree

 MAINTAINERS                                 |  1 +
 docs/system/arm/imx8mp-evk.rst              | 12 +---
 hw/arm/imx8mp-evk.c                         | 29 +++++++++
 tests/functional/meson.build                |  1 +
 tests/functional/test_aarch64_imx8mp_evk.py | 69 +++++++++++++++++++++
 5 files changed, 102 insertions(+), 10 deletions(-)
 create mode 100644 tests/functional/test_aarch64_imx8mp_evk.py
Signature · 1 line
2.49.0
#1 lore raw

PATCH 1/3 tests/functional: Add test for imx8mp-evk board with USDHC coverage

Introduce a functional test which boots Debian 12 on the imx8mp-evk board. Since the root filesystem resides on an SD card, the test also verifies the basic operation of the USDHC.

---
 MAINTAINERS                                 |  1 +
 tests/functional/meson.build                |  1 +
 tests/functional/test_aarch64_imx8mp_evk.py | 69 +++++++++++++++++++++
 3 files changed, 71 insertions(+)
 create mode 100644 tests/functional/test_aarch64_imx8mp_evk.py
MAINTAINERS +1 -0
index d54b5578f8..4ceffa89dc 100644
@@ -833,6 +833,7 @@ F: include/hw/arm/fsl-imx8mp.h
 F: include/hw/misc/imx8mp_*.h
 F: include/hw/pci-host/fsl_imx8m_phy.h
 F: docs/system/arm/imx8mp-evk.rst
+F: tests/functional/test_aarch64_imx8mp_evk.py
 F: tests/qtest/rs5c372-test.c
 
 MPS2 / MPS3
tests/functional/meson.build +1 -0
index 0f8be30fe2..aaaf3472f1 100644
@@ -75,6 +75,7 @@ tests_aarch64_system_quick = [
 
 tests_aarch64_system_thorough = [
   'aarch64_aspeed',
+  'aarch64_imx8mp_evk',
   'aarch64_raspi3',
   'aarch64_raspi4',
   'aarch64_replay',
tests/functional/test_aarch64_imx8mp_evk.py new file +69 -0

69 lines not on this page · raw message

Signature · 1 line
2.49.0
#2 lore raw

Re: [PATCH-for-10.0 1/3] tests/functional: Add test for imx8mp-evk board with USDHC coverage

Hi!

tests/functional/test_aarch64_imx8mp_evk.py

Quoted 38 lines · Bernhard Beschow

Introduce a functional test which boots Debian 12 on the imx8mp-evk board. Since the root filesystem resides on an SD card, the test also verifies the basic operation of the USDHC.

---
  MAINTAINERS                                 |  1 +
  tests/functional/meson.build                |  1 +
  tests/functional/test_aarch64_imx8mp_evk.py | 69 +++++++++++++++++++++
  3 files changed, 71 insertions(+)

create mode 100644 tests/functional/test_aarch64_imx8mp_evk.py

MAINTAINERS +1 -0
index d54b5578f8..4ceffa89dc 100644
@@ -833,6 +833,7 @@ F: include/hw/arm/fsl-imx8mp.h
  F: include/hw/misc/imx8mp_*.h
  F: include/hw/pci-host/fsl_imx8m_phy.h
  F: docs/system/arm/imx8mp-evk.rst
+F: tests/functional/test_aarch64_imx8mp_evk.py
  F: tests/qtest/rs5c372-test.c
 
  MPS2 / MPS3
tests/functional/meson.build +1 -0
index 0f8be30fe2..aaaf3472f1 100644
@@ -75,6 +75,7 @@ tests_aarch64_system_quick = [
 
  tests_aarch64_system_thorough = [
    'aarch64_aspeed',
+  'aarch64_imx8mp_evk',
    'aarch64_raspi3',
    'aarch64_raspi4',
    'aarch64_replay',
tests/functional/test_aarch64_imx8mp_evk.py new file +0 -0
new file mode 100644

The test files should be executable so you can run them directly (after setting PYTHONPATH and QEMU_TEST_QEMU_BINARY)

Quoted 29 lines

index 0000000000..5419d3c525

tests/functional/test_aarch64_imx8mp_evk.py new file +25 -0
@@ -0,0 +1,69 @@
+#!/usr/bin/env python3
+#
+# Functional test that boots a Linux kernel and checks the console
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+from qemu_test import LinuxKernelTest, Asset
+
+class Imx8mpEvkMachine(LinuxKernelTest):
+
+    ASSET_IMAGE = Asset(
+        ('https://cloud.debian.org/images/cloud/bookworm/20231210-1590/'
+         'debian-12-generic-arm64-20231210-1590.tar.xz'),
+        '7ebf1577b32d5af6204df74b54ca2e4675de9b5a9fa14f3ff70b88eeb7b3b359')
+
+    KERNEL_OFFSET = 0x51000000
+    KERNEL_SIZE = 32622528
+    INITRD_OFFSET = 0x76000000
+    INITRD_SIZE = 30987766
+    DTB_OFFSET = 0x64F51000
+    DTB_SIZE = 45 * 1024
+
+    def extract(self, in_path, out_path, offset, size):
+        try:
+            with open(in_path, "rb") as source:

tests/functional/test_aarch64_imx8mp_evk.py line 35

Quoted 10 lines
tests/functional/test_aarch64_imx8mp_evk.py new file +10 -0
+                source.seek(offset)
+                data = source.read(size)
+            with open(out_path, "wb") as target:
+                target.write(data)
+        except (IOError, ValueError) as e:
+            self.log.error(f"Failed to extract {out_path}: {e}")
+            raise
+
+    def setUp(self):
+        super().setUp()

Is there any special reason for overriding the setUp function here? ... otherwise, I think this could also simply be done from the test_aarch64_imx8mp_evk_usdhc function instead?

tests/functional/test_aarch64_imx8mp_evk.py line 37

Quoted 1 line
tests/functional/test_aarch64_imx8mp_evk.py new file +1 -0
+        self.ASSET_IMAGE.fetch()

I think you can omit the fetch() here, it should be handled by archive_extract() already. At least that's what we're doing in the other spots that use archive_extract().

Quoted 10 lines
tests/functional/test_aarch64_imx8mp_evk.py new file +10 -0
+        self.archive_extract(self.ASSET_IMAGE)
+
+        self.image_path = self.scratch_file("disk.raw")
+        self.kernel_path = self.scratch_file("linux")
+        self.initrd_path = self.scratch_file("initrd.zstd")
+        self.dtb_path = self.scratch_file("imx8mp-evk.dtb")
+
+        self.extract(self.image_path, self.kernel_path,
+                     self.KERNEL_OFFSET, self.KERNEL_SIZE)
+        self.extract(self.image_path, self.initrd_path,

tests/functional/test_aarch64_imx8mp_evk.py line 57

Quoted 10 lines
tests/functional/test_aarch64_imx8mp_evk.py new file +10 -0
+                     self.INITRD_OFFSET, self.INITRD_SIZE)
+        self.extract(self.image_path, self.dtb_path,
+                     self.DTB_OFFSET, self.DTB_SIZE)
+
+    def test_aarch64_imx8mp_evk_usdhc(self):
+        self.set_machine('imx8mp-evk')
+        self.vm.set_console(console_index=1)
+        self.vm.add_args('-m', '2G',
+                         '-smp', '4',
+                         '-accel', 'tcg',

The imx8mp-evk board has a "depends on TCG" in its Kconfig file, so I think you could omit "-accel tcg" here (but it also does not hurt to be explicit, I guess).

Thomas

Quoted 12 lines
tests/functional/test_aarch64_imx8mp_evk.py new file +12 -0
+                         '-kernel', self.kernel_path,
+                         '-initrd', self.initrd_path,
+                         '-dtb', self.dtb_path,
+                         '-append', 'root=/dev/mmcblk2p1',
+                         '-drive', f'file={self.image_path},if=sd,bus=2,'
+                                    'format=raw,id=mmcblk2')
+
+        self.vm.launch()
+        self.wait_for_console_pattern('Welcome to ')
+
+if __name__ == '__main__':
+    LinuxKernelTest.main()
#3 lore raw

Re: [PATCH-for-10.0 1/3] tests/functional: Add test for imx8mp-evk board with USDHC coverage

Am 7. April 2025 05:38:28 UTC schrieb Thomas Huth <[email protected]>:

Quoted 33 lines

Hi!

Quoted 30 lines · Bernhard Beschow

Introduce a functional test which boots Debian 12 on the imx8mp-evk board. Since the root filesystem resides on an SD card, the test also verifies the basic operation of the USDHC.

---
  MAINTAINERS                                 |  1 +
  tests/functional/meson.build                |  1 +
  tests/functional/test_aarch64_imx8mp_evk.py | 69 +++++++++++++++++++++
  3 files changed, 71 insertions(+)

create mode 100644 tests/functional/test_aarch64_imx8mp_evk.py

MAINTAINERS +1 -0
index d54b5578f8..4ceffa89dc 100644
@@ -833,6 +833,7 @@ F: include/hw/arm/fsl-imx8mp.h
  F: include/hw/misc/imx8mp_*.h
  F: include/hw/pci-host/fsl_imx8m_phy.h
  F: docs/system/arm/imx8mp-evk.rst
+F: tests/functional/test_aarch64_imx8mp_evk.py
  F: tests/qtest/rs5c372-test.c
    MPS2 / MPS3
tests/functional/meson.build +0 -0
index 0f8be30fe2..aaaf3472f1 100644
@@ -75,6 +75,7 @@ tests_aarch64_system_quick = [
    tests_aarch64_system_thorough = [
    'aarch64_aspeed',
Quoted 8 lines

tests/functional/test_aarch64_imx8mp_evk.py

Quoted 6 lines
tests/functional/meson.build +1 -0
+  'aarch64_imx8mp_evk',
    'aarch64_raspi3',
    'aarch64_raspi4',
    'aarch64_replay',
tests/functional/test_aarch64_imx8mp_evk.py new file +0 -0
new file mode 100644

The test files should be executable so you can run them directly (after setting PYTHONPATH and QEMU_TEST_QEMU_BINARY)

Ack. Will fix.

Quoted 34 lines
Quoted 34 lines

index 0000000000..5419d3c525

tests/functional/test_aarch64_imx8mp_evk.py new file +29 -0
@@ -0,0 +1,69 @@
+#!/usr/bin/env python3
+#
+# Functional test that boots a Linux kernel and checks the console
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+from qemu_test import LinuxKernelTest, Asset
+
+class Imx8mpEvkMachine(LinuxKernelTest):
+
+    ASSET_IMAGE = Asset(
+        ('https://cloud.debian.org/images/cloud/bookworm/20231210-1590/'
+         'debian-12-generic-arm64-20231210-1590.tar.xz'),
+        '7ebf1577b32d5af6204df74b54ca2e4675de9b5a9fa14f3ff70b88eeb7b3b359')
+
+    KERNEL_OFFSET = 0x51000000
+    KERNEL_SIZE = 32622528
+    INITRD_OFFSET = 0x76000000
+    INITRD_SIZE = 30987766
+    DTB_OFFSET = 0x64F51000
+    DTB_SIZE = 45 * 1024
+
+    def extract(self, in_path, out_path, offset, size):
+        try:
+            with open(in_path, "rb") as source:
+                source.seek(offset)
+                data = source.read(size)
+            with open(out_path, "wb") as target:
+                target.write(data)
Quoted 8 lines

tests/functional/test_aarch64_imx8mp_evk.py line 35

Quoted 6 lines
tests/functional/test_aarch64_imx8mp_evk.py new file +6 -0
+        except (IOError, ValueError) as e:
+            self.log.error(f"Failed to extract {out_path}: {e}")
+            raise
+
+    def setUp(self):
+        super().setUp()

Is there any special reason for overriding the setUp function here? ... otherwise, I think this could also simply be done from the test_aarch64_imx8mp_evk_usdhc function instead?

The idea is that it prepares the test data once which could be used by multiple test cases in the future. One could add tests booting via USB and PCIe. Not done yet due to concerns about CI resources.

Quoted 4 lines

tests/functional/test_aarch64_imx8mp_evk.py line 37

Quoted 2 lines
tests/functional/test_aarch64_imx8mp_evk.py new file +1 -0
+        self.ASSET_IMAGE.fetch()

I think you can omit the fetch() here, it should be handled by archive_extract() already. At least that's what we're doing in the other spots that use archive_extract().

Sounds excellent, I'll try that.

Quoted 15 lines
Quoted 15 lines
tests/functional/test_aarch64_imx8mp_evk.py new file +14 -0
+        self.archive_extract(self.ASSET_IMAGE)
+
+        self.image_path = self.scratch_file("disk.raw")
+        self.kernel_path = self.scratch_file("linux")
+        self.initrd_path = self.scratch_file("initrd.zstd")
+        self.dtb_path = self.scratch_file("imx8mp-evk.dtb")
+
+        self.extract(self.image_path, self.kernel_path,
+                     self.KERNEL_OFFSET, self.KERNEL_SIZE)
+        self.extract(self.image_path, self.initrd_path,
+                     self.INITRD_OFFSET, self.INITRD_SIZE)
+        self.extract(self.image_path, self.dtb_path,
+                     self.DTB_OFFSET, self.DTB_SIZE)
+
Quoted 8 lines

tests/functional/test_aarch64_imx8mp_evk.py line 57

Quoted 6 lines
tests/functional/test_aarch64_imx8mp_evk.py new file +6 -0
+    def test_aarch64_imx8mp_evk_usdhc(self):
+        self.set_machine('imx8mp-evk')
+        self.vm.set_console(console_index=1)
+        self.vm.add_args('-m', '2G',
+                         '-smp', '4',
+                         '-accel', 'tcg',

The imx8mp-evk board has a "depends on TCG" in its Kconfig file, so I think you could omit "-accel tcg" here (but it also does not hurt to be explicit, I guess).

I've seen it elsewhere, and I plan to add KVM support. That's why I added it. If it can be omitted I'm happy to remove it.

Best regards,
Bernhard

Quoted 17 lines

Thomas

Quoted 12 lines
tests/functional/test_aarch64_imx8mp_evk.py new file +12 -0
+                         '-kernel', self.kernel_path,
+                         '-initrd', self.initrd_path,
+                         '-dtb', self.dtb_path,
+                         '-append', 'root=/dev/mmcblk2p1',
+                         '-drive', f'file={self.image_path},if=sd,bus=2,'
+                                    'format=raw,id=mmcblk2')
+
+        self.vm.launch()
+        self.wait_for_console_pattern('Welcome to ')
+
+if __name__ == '__main__':
+    LinuxKernelTest.main()
#4 lore raw

PATCH 2/3 hw/arm/imx8mp-evk: Remove unimplemented cpu-idle-states properties from devicetree

In reply to Bernhard Beschow

From: Guenter Roeck <[email protected]>

The cpu-idle-states property causes a hard boot hang. Rather than documenting the workaround, perform the removal from the devicetree automatically.

[Bernhard: split patch, update documentation, adapt commit message]
---
 docs/system/arm/imx8mp-evk.rst | 12 ++----------
 hw/arm/imx8mp-evk.c            | 14 ++++++++++++++
 2 files changed, 16 insertions(+), 10 deletions(-)
docs/system/arm/imx8mp-evk.rst +2 -10
index 00527b0cbe..b2f7d29ade 100644
@@ -35,7 +35,7 @@ Direct Linux Kernel Boot
 
 Probably the easiest way to get started with a whole Linux system on the machine
 is to generate an image with Buildroot. Version 2024.11.1 is tested at the time
-of writing and involves three steps. First run the following commands in the
+of writing and involves two steps. First run the following commands in the
 toplevel directory of the Buildroot source tree:
 
 .. code-block:: bash
@@ -50,14 +50,6 @@ it and resize the SD card image to a power of two:
 
   $ qemu-img resize sdcard.img 256M
 
-Finally, the device tree needs to be patched with the following commands which
-will remove the ``cpu-idle-states`` properties from CPU nodes:
-
-.. code-block:: bash
-
-  $ dtc imx8mp-evk.dtb | sed '/cpu-idle-states/d' > imx8mp-evk-patched.dts
-  $ dtc imx8mp-evk-patched.dts -o imx8mp-evk-patched.dtb
-
 Now that everything is prepared the machine can be started as follows:
 
 .. code-block:: bash
@@ -65,6 +57,6 @@ Now that everything is prepared the machine can be started as follows:
   $ qemu-system-aarch64 -M imx8mp-evk -smp 4 -m 3G \
       -display none -serial null -serial stdio \
       -kernel Image \
-      -dtb imx8mp-evk-patched.dtb \
+      -dtb imx8mp-evk.dtb \
       -append "root=/dev/mmcblk2p2" \
       -drive file=sdcard.img,if=sd,bus=2,format=raw,id=mmcblk2
hw/arm/imx8mp-evk.c +14 -0
index f17d5db466..3bbf2bfbea 100644
@@ -15,6 +15,19 @@
 #include "system/qtest.h"
 #include "qemu/error-report.h"
 #include "qapi/error.h"
+#include <libfdt.h>
+
+static void imx8mp_evk_modify_dtb(const struct arm_boot_info *info, void *fdt)
+{
+    int offset;
+
+    /* Remove cpu-idle-states property from CPU nodes */
+    offset = fdt_node_offset_by_compatible(fdt, -1, "arm,cortex-a53");
+    while (offset >= 0) {
+        fdt_nop_property(fdt, offset, "cpu-idle-states");
+        offset = fdt_node_offset_by_compatible(fdt, offset, "arm,cortex-a53");
+    }
+}
 
 static void imx8mp_evk_init(MachineState *machine)
 {
@@ -32,6 +45,7 @@ static void imx8mp_evk_init(MachineState *machine)
         .board_id = -1,
         .ram_size = machine->ram_size,
         .psci_conduit = QEMU_PSCI_CONDUIT_SMC,
+        .modify_dtb = imx8mp_evk_modify_dtb,
     };
 
     s = FSL_IMX8MP(object_new(TYPE_FSL_IMX8MP));
Signature · 1 line
2.49.0
#5 lore raw

PATCH 3/3 hw/arm/imx8mp-evk: Remove unimplemented nxp, imx8mp-fspi node from devicetree

In reply to Bernhard Beschow

From: Guenter Roeck <[email protected]>

The nxp,imx8mp-fspi node triggers a warning backtrace. Remove it from the devicetree file.

Inspired-by commit bf1da4b308 ("hw/arm/raspi4b: Temporarily disable

unimplemented rpi4b devices")

[Bernhard: split patch, adapt commit message]
---
 hw/arm/imx8mp-evk.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
hw/arm/imx8mp-evk.c +16 -1
index 3bbf2bfbea..b5aec06ec5 100644
@@ -19,7 +19,22 @@
 
 static void imx8mp_evk_modify_dtb(const struct arm_boot_info *info, void *fdt)
 {
-    int offset;
+    int i, offset;
+
+    /* Temporarily disable following nodes until they are implemented */
+    const char *nodes_to_remove[] = {
+        "nxp,imx8mp-fspi",
+    };
+
+    for (i = 0; i < ARRAY_SIZE(nodes_to_remove); i++) {
+        const char *dev_str = nodes_to_remove[i];
+
+        offset = fdt_node_offset_by_compatible(fdt, -1, dev_str);
+        while (offset >= 0) {
+            fdt_nop_node(fdt, offset);
+            offset = fdt_node_offset_by_compatible(fdt, offset, dev_str);
+        }
+    }
 
     /* Remove cpu-idle-states property from CPU nodes */
     offset = fdt_node_offset_by_compatible(fdt, -1, "arm,cortex-a53");
Signature · 1 line
2.49.0
#6 lore raw
In reply to Bernhard Beschow
Quoted 5 lines · Bernhard Beschow

Guenter Roeck (2):
hw/arm/imx8mp-evk: Remove unimplemented cpu-idle-states properties
from devicetree
hw/arm/imx8mp-evk: Remove unimplemented nxp,imx8mp-fspi node from
devicetree

Patches 2 & 3 queued, thanks!

#7 lore raw

Am 8. April 2025 18:57:45 UTC schrieb "Philippe Mathieu-Daudé" <[email protected]>:

Quoted 9 lines · Bernhard Beschow
Quoted 6 lines

Guenter Roeck (2):
hw/arm/imx8mp-evk: Remove unimplemented cpu-idle-states properties
from devicetree
hw/arm/imx8mp-evk: Remove unimplemented nxp,imx8mp-fspi node from
devicetree

Patches 2 & 3 queued, thanks!

Thanks! This is a real quality of life improvement.

Best regards,
Bermhard