zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.33k stars 6.33k forks source link

SDMMC driver with STM32 U575 #49154

Closed JA-vega closed 2 years ago

JA-vega commented 2 years ago

Is this request related to a missing driver support for a particular hardware platform, SoC or board? Please describe. STM32 SDMMC driver isn't compatible with the u575 (?), I have defined the dts/dtsi from the SoC and board with the given pins, register and IRQ but I'm not able to use it.

Describe why you are asking for this support? I have added and configured the sdmmc for the U575 but it isn't working as expected.

Additional context stm32u5.dtsi: image board .dts: image Zephyr console output: image

FRASTM commented 2 years ago

On a nucleo_u575zi_q with the DTS you show (except for the ) it looks like a SDMMC clock pb. By default the SDMMC clock selection is on ICLK (set by the RCC_CCIPR2) bit 14 is 0. This ICLK is the Intermediate clock source selected by the RCC CCIPR1. By default the ICLK is on HSI48. At least the HSI48 must be on with something like

    LL_RCC_HSI48_Enable();
    while (!LL_RCC_HSI48_IsReady()) {
    }

just before HAL_SD_Init in sdmmc_stm32.c as a workaround or though a HAL_SD_MspInit function,

void HAL_SD_MspInit(SD_HandleTypeDef *hsd)
{
    /* By default the SDMMC clock source is 0 = 48MHz, it must be enabled */
    LL_RCC_HSI48_Enable();
    while (!LL_RCC_HSI48_IsReady()) {
    }
}

until the HSI48 is totally handled by the clock_control driver.

Then, as no card is present on the connector CN8 (pin D43 - D48) the HAL_SD_InitCard fails later ; this can be identified with the ErrorCode set by the hal.

    err = HAL_SD_Init(&priv->hsd);
    if (err != HAL_OK) {
        LOG_ERR("failed to init stm32_sdmmc (0x%X)", priv->hsd.ErrorCode);
        return -EIO;
    }
JA-vega commented 2 years ago

Thanks a lot, the HSI48 was disabled yes