Skip to contentSkip to conversation

hw/arm: Enable U-Boot boot on MCIMX6UL-EVK

PATCH Superseded Bin Meng 4 participants 15 messages Aug 12 – Oct 4

Subsystems (2)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

cover hw/arm: Enable U-Boot boot on MCIMX6UL-EVK

The mcimx6ul-evk machine can boot Linux directly, but it cannot run the U-Boot proper produced by Buildroot far enough to load a kernel from its SD card. Early U-Boot boot test accesses currently abort or observe placeholder values, and the i.MX uSDHC model exposes several issues.

This series lets an unmodified Buildroot 2026.05 U-Boot 2024.07 image run on mcimx6ul-evk, load zImage and imx6ul-14x14-evk.dtb from USDHC2, start Linux, mount the SD card root file system, and reach the Buildroot login prompt. It also documents and tests the existing direct Linux boot path.

Patches 1 through 4 provide the minimum early-firmware-visible state. Patches 5 through 8 address i.MX uSDHC behavior needed by U-Boot. The last two patches document both boot paths and add functional tests for U-Boot and direct Linux boot.

Bin Meng (10):
hw/arm: fsl-imx6ul: Add SCU compatibility window hw/misc: imx6ul_ccm: Update PMU_MISC0 reset value hw/arm: fsl-imx6ul: Map early firmware register placeholders hw/arm: fsl-imx6ul: Add a minimal MMDC geometry model hw/sd: sdhci: Use a QEMU-local no-busy IRQ quirk bit hw/sd: sdhci: Honor i.MX uSDHC vendor clock gates hw/sd: sdhci: Preserve uSDHC status enables for U-Boot hw/sd: sdhci: Skip SDMA boundary stops for i.MX uSDHC docs/system/arm: Document MCIMX6UL-EVK Buildroot boot tests/functional/arm: Add MCIMX6UL-EVK boot tests

 MAINTAINERS                               |  1 +
 docs/system/arm/mcimx6ul-evk.rst          | 67 +++++++++++++++++
 hw/arm/fsl-imx6ul.c                       | 87 +++++++++++++++++++++-
 hw/arm/mcimx6ul-evk.c                     |  2 +
 hw/misc/imx6ul_ccm.c                      |  2 +-
 hw/sd/sdhci.c                             | 89 +++++++++++++++++++----
 include/hw/arm/fsl-imx6ul.h               |  2 +
 include/hw/sd/sdhci.h                     | 15 +++-
 tests/functional/arm/meson.build          |  2 +
 tests/functional/arm/test_mcimx6ul_evk.py | 70 ++++++++++++++++++
 10 files changed, 315 insertions(+), 22 deletions(-)
 create mode 100644 tests/functional/arm/test_mcimx6ul_evk.py

---
base-commit: e8d693e12af9cbb89d724baadfcc08559669e279
branch: imx6ul-evk

Signature · 1 line
2.53.0
author
#1 lore raw

PATCH 1/10 hw/arm: fsl-imx6ul: Add SCU compatibility window

U-Boot's common i.MX6 CPU identification code reads the Cortex-A9 SCU configuration register at PERIPHBASE + 0x4 even on i.MX6UL. The value is only used to distinguish Cortex-A9 i.MX6 variants.

Cortex-A7 reserves this address and reading it causes data abort.

The same U-Boot abort was discussed on qemu-arm in September 2024:
https://lists.gnu.org/archive/html/qemu-arm/2024-09/msg00072.html

Map only the four-byte configuration-register address as an unimplemented device. Its zero read result gives U-Boot the single-CPU encoding after the low two bits are masked, while the remainder of the reserved Cortex-A7 page stays unmapped.

---

 hw/arm/fsl-imx6ul.c | 9 +++++++++
 1 file changed, 9 insertions(+)
hw/arm/fsl-imx6ul.c +9 -0
index 1863558a0d..d6f662efe4 100644
@@ -187,6 +187,15 @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
     sysbus_realize(SYS_BUS_DEVICE(mpcore), &error_abort);
     sysbus_mmio_map(SYS_BUS_DEVICE(mpcore), 0, FSL_IMX6UL_A7MPCORE_ADDR);
 
+    /*
+     * U-Boot's shared i.MX6 CPU identification code reads the
+     * Cortex-A9 SCU configuration register on i.MX6UL. Cortex-A7
+     * reserves this address, so provide only the compatibility word
+     * needed before the console is initialized.
+     */
+    create_unimplemented_device("a7mpcore-scu-compat",
+                                FSL_IMX6UL_A7MPCORE_ADDR + 0x4, 4);
+
     gic = mpcore;
     gicsbd = SYS_BUS_DEVICE(gic);
     cpu = DEVICE(&s->cpu);
Signature · 1 line
2.53.0
author
#2 lore raw

PATCH 2/10 hw/misc: imx6ul_ccm: Update PMU_MISC0 reset value

In reply to Bin Meng

Commit 56a11a9b7580 ("hw/misc: imx6_ccm: Update PMU_MISC0 reset value") updated the i.MX6 CCM model so U-Boot sees PMU_MISC0[REFTOP_VBGUP] set after reset. The i.MX6UL CCM model still returns this bit clear, causing U-Boot init_bandgap() to wait for a state that the model never reaches.

Apply the same reset behavior to the i.MX6UL CCM model so U-Boot can observe that the bandgap has stabilized.

---

 hw/misc/imx6ul_ccm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/misc/imx6ul_ccm.c +1 -1
index c4f6e372fe..4accbcbeed 100644
@@ -592,7 +592,7 @@ static void imx6ul_ccm_reset(DeviceState *dev)
     s->analog[PMU_REG_3P0] = 0x00000F74;
     s->analog[PMU_REG_2P5] = 0x00001073;
     s->analog[PMU_REG_CORE] = 0x00482012;
-    s->analog[PMU_MISC0] = 0x04000000;
+    s->analog[PMU_MISC0] = 0x04000080;
     s->analog[PMU_MISC1] = 0x00000000;
     s->analog[PMU_MISC2] = 0x00272727;
     s->analog[PMU_LOWPWR_CTRL] = 0x00004009;
Signature · 1 line
2.53.0
author
#3 lore raw

PATCH 3/10 hw/arm: fsl-imx6ul: Map early firmware register placeholders

In reply to Bin Meng

U-Boot configures the AIPS bus access controls and the i.MX6UL SNVS low-power registers before its console is available. Its timer setup also enables the system counter through the control window on AIPS2.

These blocks are not modeled yet. Map unimplemented regions at their documented addresses so early firmware accesses complete without falling through to unmapped memory.

---

 hw/arm/fsl-imx6ul.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
hw/arm/fsl-imx6ul.c +15 -0
index d6f662efe4..74c1a30959 100644
@@ -210,6 +210,21 @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
     create_unimplemented_device("a7mpcore-dap", FSL_IMX6UL_A7MPCORE_DAP_ADDR,
                                 FSL_IMX6UL_A7MPCORE_DAP_SIZE);
 
+    /* AIPS bus configuration */
+    create_unimplemented_device("aips1-config", FSL_IMX6UL_AIPS1_CFG_ADDR,
+                                FSL_IMX6UL_AIPS1_CFG_SIZE);
+    create_unimplemented_device("aips2-config", FSL_IMX6UL_AIPS2_CFG_ADDR,
+                                FSL_IMX6UL_AIPS2_CFG_SIZE);
+
+    /* SNVS low-power general-purpose registers */
+    create_unimplemented_device("snvs-lp", FSL_IMX6UL_SNVS_LP_ADDR,
+                                FSL_IMX6UL_SNVS_LP_SIZE);
+
+    /* System counter control */
+    create_unimplemented_device("sys-counter-control",
+                                FSL_IMX6UL_SYS_CNT_CTRL_ADDR,
+                                FSL_IMX6UL_SYS_CNT_CTRL_SIZE);
+
     /*
      * MMDC
      */
Signature · 1 line
2.53.0
#4 lore raw

Re: [PATCH 03/10] hw/arm: fsl-imx6ul: Map early firmware register placeholders

Am 12. August 2026 01:36:06 UTC schrieb Bin Meng <[email protected]>:

Quoted 7 lines

U-Boot configures the AIPS bus access controls and the i.MX6UL SNVS low-power registers before its console is available. Its timer setup also enables the system counter through the control window on AIPS2.

These blocks are not modeled yet. Map unimplemented regions at their documented addresses so early firmware accesses complete without falling through to unmapped memory.

Hi Bin,

You could try setting

   mc->ignore_memory_transaction_failures = true;

in mcimx6ul_evk_machine_init() instead and check if that prevents these (and any future such) failures.

Best regards,
Bernhard

Quoted 33 lines

---

hw/arm/fsl-imx6ul.c | 15 +++++++++++++++

1 file changed, 15 insertions(+)
hw/arm/fsl-imx6ul.c +15 -0
index d6f662efe4..74c1a30959 100644
@@ -210,6 +210,21 @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
    create_unimplemented_device("a7mpcore-dap", FSL_IMX6UL_A7MPCORE_DAP_ADDR,
                                FSL_IMX6UL_A7MPCORE_DAP_SIZE);
 
+    /* AIPS bus configuration */
+    create_unimplemented_device("aips1-config", FSL_IMX6UL_AIPS1_CFG_ADDR,
+                                FSL_IMX6UL_AIPS1_CFG_SIZE);
+    create_unimplemented_device("aips2-config", FSL_IMX6UL_AIPS2_CFG_ADDR,
+                                FSL_IMX6UL_AIPS2_CFG_SIZE);
+
+    /* SNVS low-power general-purpose registers */
+    create_unimplemented_device("snvs-lp", FSL_IMX6UL_SNVS_LP_ADDR,
+                                FSL_IMX6UL_SNVS_LP_SIZE);
+
+    /* System counter control */
+    create_unimplemented_device("sys-counter-control",
+                                FSL_IMX6UL_SYS_CNT_CTRL_ADDR,
+                                FSL_IMX6UL_SYS_CNT_CTRL_SIZE);
+
    /*
     * MMDC
     */
#5 lore raw

Re: [PATCH 03/10] hw/arm: fsl-imx6ul: Map early firmware register placeholders

Hi Bernhard,

Quoted 12 lines · Bernhard Beschow

Am 12. August 2026 01:36:06 UTC schrieb Bin Meng <[email protected]>:

Quoted 7 lines

U-Boot configures the AIPS bus access controls and the i.MX6UL SNVS low-power registers before its console is available. Its timer setup also enables the system counter through the control window on AIPS2.

These blocks are not modeled yet. Map unimplemented regions at their documented addresses so early firmware accesses complete without falling through to unmapped memory.

Quoted 7 lines

Hi Bin,

You could try setting

   mc->ignore_memory_transaction_failures = true;

in mcimx6ul_evk_machine_init() instead and check if that prevents these (and any future such) failures.

I think that flag is way too wide to ignore lots of failures, not only unmapped areas.

From include/hw/core/board.h comments, it says new board models should not use this flag to enable access to unimplemented devices.

* @ignore_memory_transaction_failures:

 *    If this is flag is true then the CPU will ignore memory transaction
 *    failures which should cause the CPU to take an exception due to an
 *    access to an unassigned physical address; the transaction will instead
 *    return zero (for a read) or be ignored (for a write). This should be
 *    set only by legacy board models which rely on the old RAZ/WI behaviour
 *    for handling devices that QEMU does not yet model. New board models
 *    should instead use "unimplemented-device" for all memory ranges where
 *    the guest will attempt to probe for a device that QEMU doesn't
 *    implement and a stub device is required.

Regards,
Bin

author
#6 lore raw

PATCH 4/10 hw/arm: fsl-imx6ul: Add a minimal MMDC geometry model

In reply to Bin Meng

U-Boot probes DRAM size from the MMDC MDCTL and MDMISC registers. The existing unimplemented region returns zero, so U-Boot cannot derive a geometry matching the RAM mapped by the machine.

Replace the placeholder with a small read-only model. Use the 8-bank, 16-bit DDR3 layout of the EVK and derive the row count from the machine RAM size.

---

 hw/arm/fsl-imx6ul.c         | 63 +++++++++++++++++++++++++++++++++++--
 hw/arm/mcimx6ul-evk.c       |  2 ++
 include/hw/arm/fsl-imx6ul.h |  2 ++
 3 files changed, 65 insertions(+), 2 deletions(-)
hw/arm/fsl-imx6ul.c +61 -2
index 74c1a30959..473269fcea 100644
@@ -25,17 +25,75 @@
 #include "hw/core/boards.h"
 #include "system/system.h"
 #include "qemu/error-report.h"
+#include "qemu/host-utils.h"
 #include "qemu/module.h"
 #include "target/arm/cpu-qom.h"
 
 #define NAME_SIZE 20
 
+#define MMDC_MDCTL  0x00
+#define MMDC_MDMISC 0x18
+
+static uint32_t fsl_imx6ul_mmdc_mdctl(uint64_t ram_size)
+{
+    unsigned int size_bits;
+    unsigned int row;
+
+    /*
+     * Use the EVK's 8-bank, 16-bit DDR3 geometry and vary the row count
+     * so firmware observes no more memory than QEMU mapped
+     */
+    ram_size = pow2floor(MAX(ram_size, 16 * MiB));
+    size_bits = 63 - clz64(ram_size);
+
+    if (size_bits == 24) {
+        return BIT(31) | BIT(19);
+    }
+
+    row = MIN(size_bits - 25, 7);
+    return BIT(31) | (row << 24) | BIT(20) | BIT(19);
+}
+
+static uint64_t fsl_imx6ul_mmdc_read(void *opaque, hwaddr offset,
+                                     unsigned size)
+{
+    FslIMX6ULState *s = opaque;
+
+    switch (offset) {
+    case MMDC_MDCTL:
+        return fsl_imx6ul_mmdc_mdctl(s->ram_size);
+    case MMDC_MDMISC:
+        /* EVK reset geometry: 8 banks, bank interleaving and RALAT 5 */
+        return 0x1740;
+    default:
+        return 0;
+    }
+}
+
+static void fsl_imx6ul_mmdc_write(void *opaque, hwaddr offset,
+                                  uint64_t value, unsigned size)
+{
+}
+
+static const MemoryRegionOps fsl_imx6ul_mmdc_ops = {
+    .read = fsl_imx6ul_mmdc_read,
+    .write = fsl_imx6ul_mmdc_write,
+    .endianness = DEVICE_LITTLE_ENDIAN,
+    .valid = {
+        .min_access_size = 4,
+        .max_access_size = 4,
+    },
+};
+
 static void fsl_imx6ul_init(Object *obj)
 {
     FslIMX6ULState *s = FSL_IMX6UL(obj);
     char name[NAME_SIZE];
     int i;
 
+    memory_region_init_io(&s->mmdc, obj, &fsl_imx6ul_mmdc_ops, s,
+                          "imx6ul.mmdc", FSL_IMX6UL_MMDC_CFG_SIZE);
+
     object_initialize_child(obj, "cpu0", &s->cpu,
                             ARM_CPU_TYPE_NAME("cortex-a7"));
 
@@ -228,8 +286,8 @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
     /*
      * MMDC
      */
-    create_unimplemented_device("a7mpcore-mmdc", FSL_IMX6UL_MMDC_CFG_ADDR,
-                                FSL_IMX6UL_MMDC_CFG_SIZE);
+    memory_region_add_subregion(get_system_memory(),
+                                FSL_IMX6UL_MMDC_CFG_ADDR, &s->mmdc);
 
     /*
      * OCOTP
@@ -745,6 +803,7 @@ static const Property fsl_imx6ul_properties[] = {
                      true),
     DEFINE_PROP_BOOL("fec2-phy-connected", FslIMX6ULState, phy_connected[1],
                      true),
+    DEFINE_PROP_UINT64("ram-size", FslIMX6ULState, ram_size, 128 * MiB),
 };
 
 static void fsl_imx6ul_class_init(ObjectClass *oc, const void *data)
hw/arm/mcimx6ul-evk.c +2 -0
index 6e9d92b1f1..3f5acae57e 100644
@@ -45,6 +45,8 @@ static void mcimx6ul_evk_init(MachineState *machine)
     object_property_set_uint(OBJECT(s), "fec2-phy-num", 1, &error_fatal);
     object_property_set_bool(OBJECT(s), "fec1-phy-connected", false,
                              &error_fatal);
+    object_property_set_uint(OBJECT(s), "ram-size", machine->ram_size,
+                             &error_fatal);
     qdev_realize(DEVICE(s), NULL, &error_fatal);
 
     memory_region_add_subregion(get_system_memory(), FSL_IMX6UL_MMDC_ADDR,
include/hw/arm/fsl-imx6ul.h +2 -0
index 6205fe6b77..bc0baca721 100644
@@ -90,9 +90,11 @@ struct FslIMX6ULState {
     MemoryRegion       caam;
     MemoryRegion       ocram;
     MemoryRegion       ocram_alias;
+    MemoryRegion       mmdc;
 
     uint32_t           phy_num[FSL_IMX6UL_NUM_ETHS];
     bool               phy_connected[FSL_IMX6UL_NUM_ETHS];
+    uint64_t           ram_size;
 };
 
 enum FslIMX6ULMemoryMap {
Signature · 1 line
2.53.0
author
#7 lore raw

PATCH 5/10 hw/sd: sdhci: Use a QEMU-local no-busy IRQ quirk bit

In reply to Bin Meng

SDHCI_QUIRK_NO_BUSY_IRQ was copied from Linux with its bit number unchanged. The quirk mask is internal to QEMU: it is neither visible to guests nor part of migration state. Mirroring Linux therefore provides no compatibility benefit and constrains local allocations.

Move it to bit zero so QEMU can allocate SDHCI quirks sequentially in its own namespace.

---

 include/hw/sd/sdhci.h | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
include/hw/sd/sdhci.h +1 -4
index a9da6203fc..8083379de3 100644
@@ -109,11 +109,8 @@ typedef struct SDHCIState SDHCIState;
 /*
  * Controller does not provide transfer-complete interrupt when not
  * busy.
- *
- * NOTE: This definition is taken out of Linux kernel and so the
- * original bit number is preserved
  */
-#define SDHCI_QUIRK_NO_BUSY_IRQ    BIT(14)
+#define SDHCI_QUIRK_NO_BUSY_IRQ    BIT(0)
 
 #define TYPE_PCI_SDHCI "sdhci-pci"
 DECLARE_INSTANCE_CHECKER(SDHCIState, PCI_SDHCI,
Signature · 1 line
2.53.0
Reviewed-by on v1 5/10
#8 lore raw

Re: [PATCH 05/10] hw/sd: sdhci: Use a QEMU-local no-busy IRQ quirk bit

Quoted 5 lines · Bin Meng

SDHCI_QUIRK_NO_BUSY_IRQ was copied from Linux with its bit number unchanged. The quirk mask is internal to QEMU: it is neither visible to guests nor part of migration state. Mirroring Linux therefore provides no compatibility benefit and constrains local allocations.

Quoted 8 lines

Move it to bit zero so QEMU can allocate SDHCI quirks sequentially in its own namespace.

---

  include/hw/sd/sdhci.h | 5 +----
  1 file changed, 1 insertion(+), 4 deletions(-)
author
#9 lore raw

PATCH 6/10 hw/sd: sdhci: Honor i.MX uSDHC vendor clock gates

In reply to Bin Meng

U-Boot's i.MX uSDHC driver enables IPGEN, HCKEN, PEREN and CKEN in VEND_SPEC rather than the standard SDHCI clock-control fields. QEMU only checks the standard fields before issuing a command. It therefore silently drops U-Boot's MMC commands even though the controller clocks are enabled. U-Boot eventually times out waiting for command completion and cannot load the kernel and device tree from the SD card.

Accept the complete vendor clock-gate set as another valid clock source for i.MX uSDHC. Also report SDSTB when the vendor IP and host clocks are enabled, matching the state U-Boot polls while changing the clock.

Keep this behavior behind an i.MX uSDHC quirk because the shared eSDHC paths also serve controllers which use the standard SDHCI fields.

Reference: IMX6ULRM (Rev 2), section 56.8.10, 56.8.12 and 56.8.26
https://www.nxp.com/webapp/Download?colCode=IMX6ULRM

---

 hw/sd/sdhci.c         | 27 ++++++++++++++++++++++++---
 include/hw/sd/sdhci.h |  7 ++++++-
 2 files changed, 30 insertions(+), 4 deletions(-)
hw/sd/sdhci.c +24 -3
index e58a610397..09aea733ba 100644
@@ -992,9 +992,11 @@ static void sdhci_data_transfer(void *opaque)
     }
 }
 
+static bool sdhci_clocks_on(SDHCIState *s);
+
 static bool sdhci_can_issue_command(SDHCIState *s)
 {
-    if (!SDHC_CLOCK_IS_ON(s->clkcon) ||
+    if (!sdhci_clocks_on(s) ||
         (((s->prnsts & SDHC_DATA_INHIBIT) || s->stopped_state) &&
         ((s->cmdreg & SDHC_CMD_DATA_PRESENT) ||
         ((s->cmdreg & SDHC_CMD_RESPONSE) == SDHC_CMD_RSP_WITH_BUSY &&
@@ -1613,6 +1615,10 @@ static void sdhci_bus_class_init(ObjectClass *klass, const void *data)
 
 #define ESDHC_VENDOR_SPEC               0xc0
 #define ESDHC_FRC_SDCLK_ON              (1 << 8)
+#define ESDHC_VENDOR_IPGEN              (1 << 11)
+#define ESDHC_VENDOR_HCKEN              (1 << 12)
+#define ESDHC_VENDOR_PEREN              (1 << 13)
+#define ESDHC_VENDOR_CKEN               (1 << 14)
 
 #define ESDHC_DLL_CTRL                  0x60
 
@@ -1629,6 +1635,16 @@ static void sdhci_bus_class_init(ObjectClass *klass, const void *data)
 #define ESDHC_PRNSTS_SDSTB              (1 << 3)
 #define ESDHC_PRNSTS_CLOCK_GATE_OFF     BIT(7)
 
+static bool sdhci_clocks_on(SDHCIState *s)
+{
+    uint32_t vendor_clocks = ESDHC_VENDOR_IPGEN | ESDHC_VENDOR_HCKEN |
+                             ESDHC_VENDOR_PEREN | ESDHC_VENDOR_CKEN;
+
+    return SDHC_CLOCK_IS_ON(s->clkcon) ||
+           ((s->quirks & SDHCI_QUIRK_CLOCKS_IN_VENDOR) &&
+            (s->vendor_spec & vendor_clocks) == vendor_clocks);
+}
+
 static uint64_t esdhc_read(void *opaque, hwaddr offset, unsigned size)
 {
     SDHCIState *s = SYSBUS_SDHCI(opaque);
@@ -1664,7 +1680,11 @@ static uint64_t esdhc_read(void *opaque, hwaddr offset, unsigned size)
     case SDHC_PRNSTS:
         /* Add SDSTB (SD Clock Stable) bit to PRNSTS */
         ret = sdhci_read(opaque, offset, size) & ~ESDHC_PRNSTS_SDSTB;
-        if (s->clkcon & SDHC_CLOCK_INT_STABLE) {
+        if ((s->clkcon & SDHC_CLOCK_INT_STABLE) ||
+            ((s->quirks & SDHCI_QUIRK_CLOCKS_IN_VENDOR) &&
+             (s->vendor_spec & (ESDHC_VENDOR_IPGEN |
+                                ESDHC_VENDOR_HCKEN)) ==
+             (ESDHC_VENDOR_IPGEN | ESDHC_VENDOR_HCKEN))) {
             ret |= ESDHC_PRNSTS_SDSTB;
         }
         break;
@@ -1923,7 +1943,8 @@ static void imx_usdhc_init(Object *obj)
     DeviceState *dev = DEVICE(obj);
 
     s->io_ops = &usdhc_mmio_ops;
-    s->quirks = SDHCI_QUIRK_NO_BUSY_IRQ;
+    s->quirks = SDHCI_QUIRK_NO_BUSY_IRQ |
+                SDHCI_QUIRK_CLOCKS_IN_VENDOR;
     qdev_prop_set_uint8(dev, "sd-spec-version", 3);
 }
 
include/hw/sd/sdhci.h +6 -1
index 8083379de3..c542d47f9b 100644
@@ -110,7 +110,12 @@ typedef struct SDHCIState SDHCIState;
  * Controller does not provide transfer-complete interrupt when not
  * busy.
  */
-#define SDHCI_QUIRK_NO_BUSY_IRQ    BIT(0)
+#define SDHCI_QUIRK_NO_BUSY_IRQ          BIT(0)
+/*
+ * Controller uses vendor-specific clock gates in place of the standard
+ * SDHCI clock-control fields
+ */
+#define SDHCI_QUIRK_CLOCKS_IN_VENDOR     BIT(1)
 
 #define TYPE_PCI_SDHCI "sdhci-pci"
 DECLARE_INSTANCE_CHECKER(SDHCIState, PCI_SDHCI,
Signature · 1 line
2.53.0
Reviewed-by on v1 6/10
#10 lore raw

Re: [PATCH 06/10] hw/sd: sdhci: Honor i.MX uSDHC vendor clock gates

Quoted 17 lines · Bin Meng

U-Boot's i.MX uSDHC driver enables IPGEN, HCKEN, PEREN and CKEN in VEND_SPEC rather than the standard SDHCI clock-control fields. QEMU only checks the standard fields before issuing a command. It therefore silently drops U-Boot's MMC commands even though the controller clocks are enabled. U-Boot eventually times out waiting for command completion and cannot load the kernel and device tree from the SD card.

Accept the complete vendor clock-gate set as another valid clock source for i.MX uSDHC. Also report SDSTB when the vendor IP and host clocks are enabled, matching the state U-Boot polls while changing the clock.

Keep this behavior behind an i.MX uSDHC quirk because the shared eSDHC paths also serve controllers which use the standard SDHCI fields.

Reference: IMX6ULRM (Rev 2), section 56.8.10, 56.8.12 and 56.8.26
https://www.nxp.com/webapp/Download?colCode=IMX6ULRM

Quoted 6 lines

---

  hw/sd/sdhci.c         | 27 ++++++++++++++++++++++++---
  include/hw/sd/sdhci.h |  7 ++++++-
  2 files changed, 30 insertions(+), 4 deletions(-)
author
#11 lore raw

PATCH 7/10 hw/sd: sdhci: Preserve uSDHC status enables for U-Boot

In reply to Bin Meng

U-Boot's i.MX uSDHC probe calls fsl_esdhc_init(), which resets the controller and programs INT_STATUS_EN. It then calls esdhc_init_common(), which issues a second RSTA and only clears the BRR/BWR status enables afterward.

The generic SDHCI reset clears QEMU's normal and error status-enable fields. Consequently, the second RSTA removes command-complete, transfer-complete, DMA, and error enables. Commands still reach the card, but QEMU does not latch completion status, so U-Boot times out and fails to expose an MMC block device.

Preserve the normal and error status-enable fields around RSTA in the i.MX uSDHC register path. Signal enables still follow the generic reset because U-Boot disables interrupt signaling and polls INT_STATUS.

The IMX6ULRM describes RSTA as clearing read-write state and does not document INT_STATUS_EN as reset-persistent. Treat this as compatibility with U-Boot's established two-reset initialization sequence rather than as behavior directly specified by the reference manual.

---

 hw/sd/sdhci.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
hw/sd/sdhci.c +27 -0
index 09aea733ba..2ee62847cb 100644
@@ -1625,6 +1625,7 @@ static void sdhci_bus_class_init(ObjectClass *klass, const void *data)
 #define ESDHC_TUNING_CTRL               0xcc
 #define ESDHC_TUNE_CTRL_STATUS          0x68
 #define ESDHC_WTMK_LVL                  0x44
+#define ESDHC_SYSCTL_RSTA               BIT(24)
 
 /* Undocumented register used by guests working around erratum ERR004536 */
 #define ESDHC_UNDOCUMENTED_REG27        0x6c
@@ -1920,6 +1921,32 @@ usdhc_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)
         sdhci_write(opaque, offset, val | s->trnmod, size);
         break;
 
+    case SDHC_CLKCON:
+        if (value & ESDHC_SYSCTL_RSTA) {
+            uint16_t norintstsen = s->norintstsen;
+            uint16_t errintstsen = s->errintstsen;
+
+            esdhc_write(opaque, offset, val, size);
+
+            /*
+             * U-Boot programs INT_STATUS_EN in fsl_esdhc_init(), then issues
+             * another RSTA from esdhc_init_common(). It only clears BRR/BWR
+             * after that reset and relies on the remaining enables while
+             * polling INT_STATUS for command, transfer, and error completion.
+             *
+             * The generic SDHCI reset clears both status-enable fields,
+             * leaving U-Boot with no completion status. Preserve them across
+             * this uSDHC-specific RSTA path. Signal enables still follow
+             * generic reset semantics because U-Boot disables interrupt
+             * signaling for polling.
+             */
+            s->norintstsen = norintstsen;
+            s->errintstsen = errintstsen;
+        } else {
+            esdhc_write(opaque, offset, val, size);
+        }
+        break;
+
     default:
         esdhc_write(opaque, offset, val, size);
         break;
Signature · 1 line
2.53.0
author
#12 lore raw

PATCH 8/10 hw/sd: sdhci: Skip SDMA boundary stops for i.MX uSDHC

In reply to Bin Meng

The standard SDHCI Block Size register encodes an SDMA buffer boundary in bits 14:12. The generic model stops at each selected boundary, sets the DMA status, and waits for software to rewrite the SDMA system address before continuing.

Freescale eSDHC and i.MX uSDHC instead expose BLKATTR without a programmable standard boundary field. On both controller families, bits 14:13 are reserved and bit 12 is the high bit of the 13-bit block-size field. Linux masks the standard boundary encoding before writing BLKATTR.

Despite its name, esdhc_write() is the shared register translation helper. usdhc_write() delegates common register accesses to it. The existing translation inserts 0x7 into the generic boundary field so the common core sees a 512 KiB boundary.

For i.MX6UL uSDHC, BLK_ATT bits 15:13 are reserved and bit 12 is part of its 13-bit block size. DINT reports successful completion of the whole internal DMA transfer, not an intermediate boundary pause.

U-Boot programs one contiguous DMA address and a block count, then waits for both DINT and transfer-complete. It never rewrites the address at an intermediate boundary. Reads larger than 512 KiB therefore reach the synthetic boundary and stall with blocks remaining.

The missing field alone does not establish whether every older eSDHC has a fixed internal boundary handshake. Limit the new quirk to only TYPE_IMX_USDHC, where the reference manual, U-Boot behavior, and the observed failure agree. Existing FSL eSDHC and standard SDHCI behavior remain unchanged.

Reference: IMX6ULRM (Rev. 2), section 56.8.2 and 56.8.13
https://www.nxp.com/webapp/Download?colCode=IMX6ULRM

---

 hw/sd/sdhci.c         | 37 ++++++++++++++++++++++++-------------
 include/hw/sd/sdhci.h |  5 +++++
 2 files changed, 29 insertions(+), 13 deletions(-)
hw/sd/sdhci.c +24 -13
index 2ee62847cb..7c014d0345 100644
@@ -599,11 +599,13 @@ static void sdhci_write_dataport(SDHCIState *s, uint32_t value, unsigned size)
 /* Multi block SDMA transfer */
 static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s)
 {
+    bool boundary_enabled =
+        !(s->quirks & SDHCI_QUIRK_NO_SDMA_BOUNDARY);
     bool page_aligned = false;
     unsigned int begin;
     const uint16_t block_size = s->blksize & BLOCK_SIZE_MASK;
-    uint32_t boundary_chk = 1 << (((s->blksize & ~BLOCK_SIZE_MASK) >> 12) + 12);
-    uint32_t boundary_count = boundary_chk - (s->sdmasysad % boundary_chk);
+    uint32_t boundary_chk = 0;
+    uint32_t boundary_count = 0;
 
     if (!(s->trnmod & SDHC_TRNS_BLK_CNT_EN) || !s->blkcnt) {
         qemu_log_mask(LOG_UNIMP, "infinite transfer is not supported\n");
@@ -615,8 +617,11 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s)
      * possible stop at page boundary if initial address is not page aligned,
      * allow them to work properly
      */
-    if ((s->sdmasysad % boundary_chk) == 0) {
-        page_aligned = true;
+    if (boundary_enabled) {
+        boundary_chk =
+            1 << (((s->blksize & ~BLOCK_SIZE_MASK) >> 12) + 12);
+        boundary_count = boundary_chk - (s->sdmasysad % boundary_chk);
+        page_aligned = (s->sdmasysad % boundary_chk) == 0;
     }
 
     s->prnsts |= SDHC_DATA_INHIBIT | SDHC_DAT_LINE_ACTIVE;
@@ -632,7 +637,9 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s)
                 boundary_count = 0;
              } else {
                 s->data_count = block_size;
-                boundary_count -= block_size - begin;
+                if (boundary_enabled) {
+                    boundary_count -= block_size - begin;
+                }
                 if (s->trnmod & SDHC_TRNS_BLK_CNT_EN) {
                     s->blkcnt--;
                 }
@@ -656,7 +663,9 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s)
                 boundary_count = 0;
              } else {
                 s->data_count = block_size;
-                boundary_count -= block_size - begin;
+                if (boundary_enabled) {
+                    boundary_count -= block_size - begin;
+                }
             }
             dma_memory_read(s->dma_as, s->sdmasysad, &s->fifo_buffer[begin],
                             s->data_count - begin, MEMTXATTRS_UNSPECIFIED);
@@ -1818,13 +1827,14 @@ esdhc_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)
 
     case SDHC_BLKSIZE:
         /*
-         * ESDHCI does not implement "Host SDMA Buffer Boundary", and
-         * Linux driver will try to zero this field out which will
-         * break the rest of SDHCI emulation.
+         * Freescale eSDHC and i.MX uSDHC use BLKATTR without the standard
+         * Host SDMA Buffer Boundary field. uSDHC accesses reach this shared
+         * register translation through usdhc_write().
          *
-         * Linux defaults to maximum possible setting (512K boundary)
-         * and it seems to be the only option that i.MX IP implements,
-         * so we artificially set it to that value.
+         * Keep the largest boundary in the generic representation to
+         * preserve existing eSDHC behavior. TYPE_IMX_USDHC separately
+         * disables the associated stop semantics because its DINT reports
+         * completion of the entire transfer rather than a boundary event.
          */
         val |= 0x7 << 12;
         /* FALLTHROUGH */
@@ -1971,7 +1981,8 @@ static void imx_usdhc_init(Object *obj)
 
     s->io_ops = &usdhc_mmio_ops;
     s->quirks = SDHCI_QUIRK_NO_BUSY_IRQ |
-                SDHCI_QUIRK_CLOCKS_IN_VENDOR;
+                SDHCI_QUIRK_CLOCKS_IN_VENDOR |
+                SDHCI_QUIRK_NO_SDMA_BOUNDARY;
     qdev_prop_set_uint8(dev, "sd-spec-version", 3);
 }
 
include/hw/sd/sdhci.h +5 -0
index c542d47f9b..387c2dc80f 100644
@@ -116,6 +116,11 @@ typedef struct SDHCIState SDHCIState;
  * SDHCI clock-control fields
  */
 #define SDHCI_QUIRK_CLOCKS_IN_VENDOR     BIT(1)
+/*
+ * Controller completes contiguous SDMA transfers without the standard
+ * intermediate buffer-boundary stop and address-update handshake
+ */
+#define SDHCI_QUIRK_NO_SDMA_BOUNDARY     BIT(2)
 
 #define TYPE_PCI_SDHCI "sdhci-pci"
 DECLARE_INSTANCE_CHECKER(SDHCIState, PCI_SDHCI,
Signature · 1 line
2.53.0
author
#13 lore raw

PATCH 9/10 docs/system/arm: Document MCIMX6UL-EVK Buildroot boot

In reply to Bin Meng

Provide verified instructions for U-Boot and direct Linux boot using Buildroot images.

---

 docs/system/arm/mcimx6ul-evk.rst | 67 ++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)
docs/system/arm/mcimx6ul-evk.rst +67 -0
index 8871138ab3..84331b734d 100644
@@ -3,3 +3,70 @@ NXP MCIMX6UL-EVK (``mcimx6ul-evk``)
 
 The ``mcimx6ul-evk`` machine models the NXP i.MX6UltraLite Evaluation Kit
 MCIMX6UL-EVK development board. It has a single Cortex-A7 CPU.
+
+Booting Buildroot images
+------------------------
+
+Build the SD card image with the tested Buildroot version:
+
+.. code-block:: bash
+
+  $ git clone https://gitlab.com/buildroot.org/buildroot.git
+  $ cd buildroot
+  $ git checkout 2026.05
+  $ make imx6ulevk_defconfig
+  $ make
+
+The following examples use images generated by Buildroot::
+
+  IMAGES=/path/to/buildroot/output/images
+  QEMU_BUILD=/path/to/qemu/build
+
+The generated raw ``sdcard.img`` is about 84 MiB, which is not a capacity
+supported by QEMU's SD card model. Resize the image in place to 128 MiB::
+
+  "$QEMU_BUILD/qemu-img" resize -f raw "$IMAGES/sdcard.img" 128M
+
+This modifies the Buildroot output image; rebuilding the image restores its
+original size.
+
+The SD card must be attached to USDHC2 with ``index=1``. It is consequently
+named ``mmc1`` by U-Boot and ``mmcblk1`` by Linux. The first partition contains
+the kernel and device tree, while the second partition contains the root file
+system.
+
+U-Boot boot
+~~~~~~~~~~~
+
+The machine does not model the i.MX6UL Boot ROM or its SPL loading sequence.
+Load U-Boot proper at its linked address::
+
+.. code-block:: bash
+
+  "$QEMU_BUILD/qemu-system-arm" \
+      -M mcimx6ul-evk -m 512M \
+      -device loader,file="$IMAGES/u-boot.bin",addr=0x87800000,cpu-num=0 \
+      -drive file="$IMAGES/sdcard.img",if=sd,index=1,format=raw \
+      -nographic
+
+The default Buildroot U-Boot environment selects ``mmc1``, loads ``zImage``
+and ``imx6ul-14x14-evk.dtb`` from the first partition, and starts Linux with
+``/dev/mmcblk1p2`` as the root file system. A ``bad CRC`` warning while loading
+an uninitialized persistent U-Boot environment is expected; U-Boot continues
+with its compiled-in defaults.
+
+Direct Linux boot
+~~~~~~~~~~~~~~~~~
+
+QEMU can load the Buildroot kernel and device tree directly. The kernel then
+mounts the second SD card partition as its root file system::
+
+.. code-block:: bash
+
+  "$QEMU_BUILD/qemu-system-arm" \
+      -M mcimx6ul-evk -m 512M \
+      -kernel "$IMAGES/zImage" \
+      -dtb "$IMAGES/imx6ul-14x14-evk.dtb" \
+      -append "console=ttymxc0,115200 root=/dev/mmcblk1p2 rootwait rw" \
+      -drive file="$IMAGES/sdcard.img",if=sd,index=1,format=raw \
+      -nographic
Signature · 1 line
2.53.0
author
#14 lore raw

PATCH 10/10 tests/functional/arm: Add MCIMX6UL-EVK boot tests

In reply to Bin Meng

The MCIMX6UL-EVK machine supports loading U-Boot proper with the generic loader and booting Linux directly, but neither path has functional coverage.

Add a versioned Buildroot asset containing U-Boot, a Linux kernel, the board DTB, and a 128 MiB SD card image. Exercise both boot paths and verify that they reach the Buildroot login prompt.

Cover the new test in the existing MCIMX6UL EVK MAINTAINERS entry.

---

 MAINTAINERS                               |  1 +
 tests/functional/arm/meson.build          |  2 +
 tests/functional/arm/test_mcimx6ul_evk.py | 70 +++++++++++++++++++++++
 3 files changed, 73 insertions(+)
 create mode 100644 tests/functional/arm/test_mcimx6ul_evk.py
MAINTAINERS +1 -0
index 4628793dde..45288fb5b9 100644
@@ -909,6 +909,7 @@ F: include/hw/arm/fsl-imx6ul.h
 F: include/hw/display/imx6ul_lcdif.h
 F: include/hw/misc/imx6ul_ccm.h
 F: docs/system/arm/mcimx6ul-evk.rst
+F: tests/functional/arm/test_mcimx6ul_evk.py
 
 MCIMX7D SABRE / i.MX7
 M: Peter Maydell <[email protected]>
tests/functional/arm/meson.build +2 -0
index 61b00932db..d8b1408b13 100644
@@ -20,6 +20,7 @@ test_arm_timeouts = {
   'bpim2u' : 500,
   'collie' : 180,
   'cubieboard' : 360,
+  'mcimx6ul_evk' : 240,
   'orangepi' : 540,
   'quanta_gsj' : 240,
   'raspi2' : 120,
@@ -59,6 +60,7 @@ tests_arm_system_thorough = [
   'emcraft_sf2',
   'integratorcp',
   'max78000fthr',
+  'mcimx6ul_evk',
   'microbit',
   'orangepi',
   'quanta_gsj',
tests/functional/arm/test_mcimx6ul_evk.py new file +70 -0

70 lines not on this page · raw message

Signature · 1 line
2.53.0