Skip to content

SD Card Interface

Helpful Kconfig options:

CONFIG_SDHC

CONFIG_STM32_MEMMAP

#CONFIG_XIP=y
CONFIG_FLASH=y
CONFIG_LOG=y
CONFIG_FLASH_LOG_LEVEL_ERR=y
CONFIG_SHELL=y
CONFIG_FLASH_SHELL=y
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_MCUBOOT_SHELL=y
CONFIG_IMG_MANAGER=y
CONFIG_STREAM_FLASH=y
CONFIG_MCUBOOT_IMG_MANAGER=y
CONFIG_FLASH_MAP=y

Current MB Pinout

SPI1 
PA0 SDC_SEL  Output OD Low       SD Card Selection       // 0 for STM32 SPI, 1 for external connector
PA1 SDC_EN  Output OD Low       SD Card Enable          // 0/low active to activate MUX
PA4 SDC_CS  AF  PP Medium  5 SPI1_NSS SD Card
PA5 SDC_SCK  AF  PP High  5 SPI1_SCK SD Card
PA6 SDC_MISO AF      5 SPI1_MISO SD Card
PA7 SDC_MOSI AF  PP High  5 SPI1_MOSI SD Card

Example DeviceTree

&spi1 {
        status = "okay";
        cs-gpios = <&porta 4 GPIO_ACTIVE_LOW>;

        sdhc0: sdhc@0 {
                compatible = "zephyr,sdhc-spi-slot";
                reg = <0>;
                status = "okay";
                mmc {
                    compatible = "zephyr,sdmmc-disk";
                    disk-name = "SD";
                    status = "okay";
                };
                spi-max-frequency = <24000000>;
        };
};

Documentation

https://docs.zephyrproject.org/latest/hardware/peripherals/sdhc.html#api-reference

https://docs.zephyrproject.org/latest/services/storage/disk/access.html#disk-access-api