Skip to content

drivers: disk: sdmmc_stm32: Add compatibility macros for STM32F4 SDIO #94903

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bricle
Copy link
Contributor

@bricle bricle commented Aug 24, 2025

Add compatibility macros to map SDMMC constants to SDIO equivalents for STM32F4 series MCUs. STM32F4 uses SDIO peripheral with SDIO_* constants while newer STM32F7/H7 series use SDMMC peripheral with SDMMC_* constants.

This fixes compilation errors on STM32F4 platforms where SDMMC_* constants are undefined:

  • SDMMC_CLOCK_EDGE_RISING
  • SDMMC_CLOCK_BYPASS_ENABLE/DISABLE
  • SDMMC_CLOCK_POWER_SAVE_ENABLE/DISABLE
  • SDMMC_HARDWARE_FLOW_CONTROL_DISABLE

Tests
under zephyr/tests/drivers/disk/disk_access with west build -b stm32f469i_disco/stm32f469xx -d build -p always

west build -b stm32f469i_disco/stm32f469xx -d build -p always  && west flash
-- west build: making build dir /home/bricl/zwksp/zephyr/tests/drivers/disk/disk_access/build pristine
-- west build: generating a build system
Loading Zephyr default modules (Zephyr base).
-- Application: /home/bricl/zwksp/zephyr/tests/drivers/disk/disk_access
-- CMake version: 4.0.3
-- Found Python3: /home/bricl/zephyrproject/.venv/bin/python3 (found suitable version "3.12.3", minimum required is "3.10") found components: Interpreter
-- Cache files will be written to: /home/bricl/.cache/zephyr
-- Zephyr version: 4.2.99 (/home/bricl/zwksp/zephyr)
-- Found west (found suitable version "1.4.0", minimum required is "0.14.0")
-- Board: stm32f469i_disco, qualifiers: stm32f469xx
-- ZEPHYR_TOOLCHAIN_VARIANT not set, trying to locate Zephyr SDK
-- Found host-tools: zephyr 0.17.1 (/home/bricl/zephyr-sdk-0.17.1)
-- Found toolchain: zephyr 0.17.1 (/home/bricl/zephyr-sdk-0.17.1)
-- Found Dtc: /home/bricl/zephyr-sdk-0.17.1/sysroots/x86_64-pokysdk-linux/usr/bin/dtc (found suitable version "1.7.0", minimum required is "1.4.6")
-- Found BOARD.dts: /home/bricl/zwksp/zephyr/boards/st/stm32f469i_disco/stm32f469i_disco.dts
-- Generated zephyr.dts: /home/bricl/zwksp/zephyr/tests/drivers/disk/disk_access/build/zephyr/zephyr.dts
-- Generated pickled edt: /home/bricl/zwksp/zephyr/tests/drivers/disk/disk_access/build/zephyr/edt.pickle
-- Generated devicetree_generated.h: /home/bricl/zwksp/zephyr/tests/drivers/disk/disk_access/build/zephyr/include/generated/zephyr/devicetree_generated.h
Parsing /home/bricl/zwksp/zephyr/tests/drivers/disk/disk_access/Kconfig
Loaded configuration '/home/bricl/zwksp/zephyr/boards/st/stm32f469i_disco/stm32f469i_disco_defconfig'
Merged configuration '/home/bricl/zwksp/zephyr/tests/drivers/disk/disk_access/prj.conf'
Configuration saved to '/home/bricl/zwksp/zephyr/tests/drivers/disk/disk_access/build/zephyr/.config'
Kconfig header saved to '/home/bricl/zwksp/zephyr/tests/drivers/disk/disk_access/build/zephyr/include/generated/zephyr/autoconf.h'
-- Found GnuLd: /home/bricl/zephyr-sdk-0.17.1/arm-zephyr-eabi/arm-zephyr-eabi/bin/ld.bfd (found version "2.38")
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- The ASM compiler identification is GNU
-- Found assembler: /home/bricl/zephyr-sdk-0.17.1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
-- Using ccache: /usr/bin/ccache
-- Found gen_kobject_list: /home/bricl/zwksp/zephyr/scripts/build/gen_kobject_list.py
-- Configuring done (9.3s)
-- Generating done (0.2s)
-- Build files have been written to: /home/bricl/zwksp/zephyr/tests/drivers/disk/disk_access/build
-- west build: building application
[1/157] Preparing syscall dependency handling

[2/157] Generating include/generated/zephyr/version.h
-- Zephyr version: 4.2.99 (/home/bricl/zwksp/zephyr), build: v4.2.0-2288-g379b67bfcda6
[157/157] Linking C executable zephyr/zephyr.elf
Memory region         Used Size  Region Size  %age Used
           FLASH:       44256 B         2 MB      2.11%
             RAM:       39360 B       320 KB     12.01%
             CCM:          0 GB        64 KB      0.00%
          SDRAM1:          0 GB        16 MB      0.00%
        IDT_LIST:          0 GB        32 KB      0.00%
Generating files from /home/bricl/zwksp/zephyr/tests/drivers/disk/disk_access/build/zephyr/zephyr.elf for board: 

Fixes #94896

@bricle bricle force-pushed the fix_sdmmc_stm32_f4_build_failure branch from 379b67b to 57fd66e Compare August 24, 2025 03:21
@bricle
Copy link
Contributor Author

bricle commented Aug 24, 2025

It seems like sdmmc_stm32.c driver is not built on ci, at least on STM32F4 series, is there a way to include this driver?

edited:it is tested on H7 platform but not on F4 platform.

Add compatibility macros to map SDMMC constants to SDIO equivalents
for STM32F4 series MCUs. STM32F4 uses SDIO peripheral with SDIO_*
constants while newer STM32F7/H7 series use SDMMC peripheral with
SDMMC_* constants.

This fixes compilation errors on STM32F4 platforms where SDMMC_*
constants are undefined:
- SDMMC_CLOCK_EDGE_RISING
- SDMMC_CLOCK_BYPASS_ENABLE/DISABLE
- SDMMC_CLOCK_POWER_SAVE_ENABLE/DISABLE
- SDMMC_HARDWARE_FLOW_CONTROL_DISABLE

Fixes Fixes zephyrproject-rtos#94896

Signed-off-by: Shan Pen <[email protected]>
@bricle bricle force-pushed the fix_sdmmc_stm32_f4_build_failure branch from 57fd66e to 7d7d6f6 Compare August 24, 2025 06:56
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

STM32 SDMMC Driver Compilation Error: Undefined SDMMC Constants on F4 series
3 participants