Skip to content

drivers: sdio: Support SDIO driver for STM32. #89776

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

Merged
merged 4 commits into from
Jul 30, 2025

Conversation

ExaltZephyr
Copy link
Contributor

@ExaltZephyr ExaltZephyr commented May 11, 2025

This PR introduces support for the SDHC driver on STM32, enabling functionality APIs for SDHC host controllers.
We used Portenta H7 but we faced some issues with end-to-end testing with airoc-wifi module, which will be addressed later.

Supported commands

  • SD_GO_IDLE_STATE
  • SDIO_SEND_OP_COND
  • SD_SEND_RELATIVE_ADDR
  • SD_SELECT_CARD
  • SD_VOL_SWITCH (could not test on Portenta)
  • SDIO_RW_DIRECT
  • SDIO_RW_EXTENDED

Supported Modes

  • DMA mode
  • Polling mode

Integration with the Airoc driver for Murata 1DX

  • sample Output on Portenta:
    sample-output

Known Issues

  • During card identification process, specifically when issuing cmd opcode#3 asking for card relative address, both zephyr subsys and HAL shift the relative address coming from the response.
  • ✔️ this issue has been addressed in this driver "sdhc_stm32"

-HAL_SDIO_Init currently failing if we skip the card identification sequence, a fix from HAL is needed.
✔️ this issue has been addressed in this PR #281.

@ExaltZephyr ExaltZephyr force-pushed the stm32-sdio-support branch 10 times, most recently from 6df147b to 5c833af Compare May 11, 2025 15:59
ndrs-pst added a commit to DDC-NDRS/zephyr_rtos that referenced this pull request May 11, 2025
Rename the driver source file to `sdhc_stm32_v2.c` to prevent conflicts
with the file introduced in upcoming PR zephyrproject-rtos#89776.
@ExaltZephyr ExaltZephyr force-pushed the stm32-sdio-support branch from 5c833af to b72e9a9 Compare May 12, 2025 06:28
@pillo79
Copy link
Contributor

pillo79 commented May 12, 2025

First of all, thanks for this! Tried building the new sample, but it fails with the error

devicetree error: 'disk-name' is marked as required in 'properties:' in zephyr/dts/bindings/sdhc/st,stm32-sdhc.yaml, but does not appear in <Node /soc/sdmmc@52007000 in 'zephyr/misc/empty_file.c'>

(AFAICS CI did not build it).

I think this is caused by a very recently merged commit (f9e5eeb from #89086) being included. The name can be defined of course, but I am not sure if this has additional implications.

@ExaltZephyr
Copy link
Contributor Author

First of all, thanks for this! Tried building the new sample, but it fails with the error

devicetree error: 'disk-name' is marked as required in 'properties:' in zephyr/dts/bindings/sdhc/st,stm32-sdhc.yaml, but does not appear in <Node /soc/sdmmc@52007000 in 'zephyr/misc/empty_file.c'>

(AFAICS CI did not build it).

I think this is caused by a very recently merged commit (f9e5eeb from #89086) being included. The name can be defined of course, but I am not sure if this has additional implications.

I see, will push a fix now

@ExaltZephyr ExaltZephyr force-pushed the stm32-sdio-support branch from b72e9a9 to 4fb1bce Compare May 12, 2025 11:40
JarmouniA
JarmouniA previously approved these changes Jul 24, 2025
pillo79
pillo79 previously approved these changes Jul 24, 2025
Copy link
Contributor

@pillo79 pillo79 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! Let's get this very useful feature merged.

erwango
erwango previously approved these changes Jul 24, 2025
facchinm
facchinm previously approved these changes Jul 24, 2025
fabiobaltieri
fabiobaltieri previously approved these changes Jul 24, 2025
@fabiobaltieri
Copy link
Member

Hey @danieldegrasse, you are still blocking this, can you take a look?

Copy link
Contributor

@danieldegrasse danieldegrasse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only remaining blocking comment is about adding the SDHC sample that reads/writes to the card common I/O area- if we can use use the sdio subsystem test for this I'd prefer not to add another test with overlapping functionality

break;

default:
LOG_DBG("Unsupported Command, opcode:%d", cmd->opcode);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking, but I might change this to a LOG_ERR. Users should have a relatively easy way to see that this driver only supports the SDIO stack.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ExaltZephyr sorry for not following up here- does this sample still need to be added, or could we extend test/subsys/sd/sdio?

@erwango erwango assigned danieldegrasse and unassigned erwango Jul 25, 2025
@erwango
Copy link
Member

erwango commented Jul 25, 2025

Moving PR assignment to @danieldegrasse as I'll be off for a couple of weeks.

@ExaltZephyr
Copy link
Contributor Author

ExaltZephyr commented Jul 27, 2025

Only remaining blocking comment is about adding the SDHC sample that reads/writes to the card common I/O area- if we can use use the sdio subsystem test for this I'd prefer not to add another test with overlapping functionality

@danieldegrasse
I already added a sample that performs read/write operations to the card’s common area under samples/drivers/sdhc/sdhc_read_write.
Additionally, I’ve extended the SDIO tests to include a write test.
Are you asking me to remove the changes I made under tests, or to remove the sample entirely?

I felt it would be helpful to have both a test and a sample—especially Zephyr currently doesn’t include any SDHC sample.

@danieldegrasse
Copy link
Contributor

Only remaining blocking comment is about adding the SDHC sample that reads/writes to the card common I/O area- if we can use use the sdio subsystem test for this I'd prefer not to add another test with overlapping functionality

@danieldegrasse I already added a sample that performs read/write operations to the card’s common area under samples/drivers/sdhc/sdhc_read_write. Additionally, I’ve extended the SDIO tests to include a write test. Are you asking me to remove the changes I made under tests, or to remove the sample entirely?

I felt it would be helpful to have both a test and a sample—especially Zephyr currently doesn’t include any SDHC sample.

If the test and sample do something functionally distinct, I am fine with having both. However I don't want to add a sample that performs the same operations as the test- that is just additional code to maintain. From my read of the sample, it performs the same operations as the SDIO test, right?

If that is the case, I would prefer we remove the sample, yeah- the SDHC driver class is inherently only supposed to be used by the SD subystem, so samples are really just there to leverage the SDHC drivers- whether that be through SDMMC disk I/O or a WiFi sample using the SDIO stack.

This commit enables SDHC support for STM32 on arduino
portenta h7, giga r1 and nicla vision boards.

Signed-off-by: Sara Touqan <zephyr@exalt.ps>
This commit expands the SDIO subsystem test
suite by adding support for write test.
Also this commit adds needed conf/overlay
files for arduino portenta h7, nicla vision
and giga r1 for wifi_nm tests

Signed-off-by: Sara Touqan <zephyr@exalt.ps>
@ExaltZephyr
Copy link
Contributor Author

Only remaining blocking comment is about adding the SDHC sample that reads/writes to the card common I/O area- if we can use use the sdio subsystem test for this I'd prefer not to add another test with overlapping functionality

@danieldegrasse I already added a sample that performs read/write operations to the card’s common area under samples/drivers/sdhc/sdhc_read_write. Additionally, I’ve extended the SDIO tests to include a write test. Are you asking me to remove the changes I made under tests, or to remove the sample entirely?
I felt it would be helpful to have both a test and a sample—especially Zephyr currently doesn’t include any SDHC sample.

If the test and sample do something functionally distinct, I am fine with having both. However I don't want to add a sample that performs the same operations as the test- that is just additional code to maintain. From my read of the sample, it performs the same operations as the SDIO test, right?

If that is the case, I would prefer we remove the sample, yeah- the SDHC driver class is inherently only supposed to be used by the SD subystem, so samples are really just there to leverage the SDHC drivers- whether that be through SDMMC disk I/O or a WiFi sample using the SDIO stack.

@danieldegrasse done, I dropped the sample's commit

Copy link

@cfriedt cfriedt merged commit d53f324 into zephyrproject-rtos:main Jul 30, 2025
32 checks passed
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.

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy