Can SF32LB52B use SDIO to drive a TF card?

Configured to use SDIO, but TF card cannot be found. No signal observed on the clock line when measured with an oscilloscope.

rt_pin_mode(11, PIN_MODE_INPUT);

while (rt_pin_read(11) == PIN_HIGH)
{
    LOG_W("Please insert TF card.\n");
    rt_thread_mdelay(1000);
}

LOG_I("TF card detected.\n");

rt_device_t msd = rt_device_find("sd0");
if (msd == NULL)
{
    LOG_E("Error: the flash device name (sd0) is not found.\n");
    return false;
}

Which example was used as reference?

example/rt_device/emmc/project · SiTech/SiFli-SDK - Gitee - Open Source China

The pinmux must be configured correctly.

This routine has been tried, but it still doesn’t work. I configured the SDIO functional pins as follows:

HAL_PIN_Set(PAD_PA14, SD1_CLK, PIN_NOPULL, 1);

HAL_PIN_Set(PAD_PA15, SD1_CMD, PIN_NOPULL, 1);

HAL_PIN_Set(PAD_PA16, SD1_DIO0, PIN_NOPULL, 1);

HAL_PIN_Set(PAD_PA17, SD1_DIO1, PIN_NOPULL, 1);

HAL_PIN_Set(PAD_PA12, SD1_DIO2, PIN_NOPULL, 1);

HAL_PIN_Set(PAD_PA13, SD1_DIO3, PIN_NOPULL, 1);

This is the device list printed by the eMMC routine, and sd0 is not present.

The existing 52B Nano development board connects pins PA12~PA17 directly to an external NorFlash, thus eMMC is not supported. See reference: Feature request: SDIO documentation is currently scarce; hope to have an example for reading/writing eMMC and mounting a file system - Wish Pool - SiFli BBS

1 Like

I made another board that routes SDIO to the TF card slot. I tried configuring a new board template but couldn’t figure out how to modify it to use SDIO, so I’ve temporarily set it aside and plan to open-source the board. I’m not familiar with the software architecture and don’t have time to work on adapting it :innocent:.

The main branch has a development board sf32lb52-core_e8r16, but the board documentation has not yet been released. This board is based on the SF32LB52J and boots from a TF card via the SDIO interface, without using MPI2. MPI1 remains connected to PSRAM.

SF32LB52-CORE_E8R16 - SiFli SDK Programming Guide

For reference on pinmux configuration code, see:
SiFli-SDK/customer/boards/sf32lb52-core_base/bsp_pinmux.c at main · OpenSiFli/SiFli-SDK

    HAL_PIN_Set(PAD_PA15, SD1_CMD, PIN_PULLUP, 1);
    HAL_PIN_Set(PAD_PA14, SD1_CLK,  PIN_NOPULL, 1);
    HAL_PIN_Set(PAD_PA16, SD1_DIO0, PIN_PULLUP, 1);
    HAL_PIN_Set(PAD_PA17, SD1_DIO1, PIN_PULLUP, 1);
    HAL_PIN_Set(PAD_PA12, SD1_DIO2, PIN_PULLUP, 1);
    HAL_PIN_Set(PAD_PA13, SD1_DIO3, PIN_PULLUP, 1);
    HAL_PIN_Set(PAD_PA11, GPIO_A11, PIN_PULLUP, 1);

Although using the SF32LB52B allows avoiding MPI2 and enables booting from internal flash, the lack of PSRAM limits its application scenarios. Additionally, the internal flash capacity is limited, restricting the amount of code that can be stored.

I’ll check again when I have time. Applications without color screens, along with on-chip SRAM and 4MB of flash, are often sufficient. Having all IOs connected to the main core also enables easier control and lower power consumption.