-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
base: main
Are you sure you want to change the base?
drivers: sdio: Support SDIO driver for STM32. #89776
Conversation
6df147b
to
5c833af
Compare
Rename the driver source file to `sdhc_stm32_v2.c` to prevent conflicts with the file introduced in upcoming PR zephyrproject-rtos#89776.
5c833af
to
b72e9a9
Compare
First of all, thanks for this! Tried building the new sample, but it fails with the error
(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 |
b72e9a9
to
4fb1bce
Compare
|
@ExaltZephyr I think it's better if you try to reproduce independently, the log is not very informative and probably most of the readings are failing anyway even before the timeout since I get 0 from the chip identification routine. If you need it, here's the patch I'm using to bypass the missing CMD8. diff --git a/subsys/sd/sd.c b/subsys/sd/sd.c
index d8c28914380..2bc70fa6624 100644
--- a/subsys/sd/sd.c
+++ b/subsys/sd/sd.c
@@ -58,6 +58,9 @@ static int sd_send_interface_condition(struct sd_card *card)
cmd.retries = CONFIG_SD_CMD_RETRIES;
cmd.timeout_ms = CONFIG_SD_CMD_TIMEOUT;
ret = sdhc_request(card->sdhc, &cmd, NULL);
+ if (ret == -ENOTSUP) {
+ return ret;
+ }
if (ret) {
LOG_DBG("SD CMD8 failed with error %d", ret);
/* Retry */
@@ -200,7 +202,8 @@ static int sd_command_init(struct sd_card *card)
* specification and expect something like this too.
*/
ret = sd_common_init(card);
- if (ret) {
+ if (ret && (ret != -ENOTSUP)) {
return ret;
}
diff --git a/subsys/sd/sdio.c b/subsys/sd/sdio.c
index a81403c5f82..8ec475e7f78 100644
--- a/subsys/sd/sdio.c
+++ b/subsys/sd/sdio.c
@@ -38,6 +38,9 @@ static int sdio_send_ocr(struct sd_card *card, uint32_t ocr)
/* Send OCR5 to initialize card */
for (retries = 0; retries < CONFIG_SD_OCR_RETRY_COUNT; retries++) {
ret = sdhc_request(card->sdhc, &cmd, NULL);
+ if (ret == -ENOTSUP) {
+ return 0;
+ }
if (ret) {
if (ocr == 0) {
/* Just probing card, likely not SDIO */
@@ -553,6 +556,10 @@ int sdio_card_init(struct sd_card *card)
/* Probe card with SDIO OCR CM5 */
ret = sdio_send_ocr(card, ocr_arg);
if (ret) {
+ LOG_ERR("Card did not respond to CMD5");
+ if (ret == -ENOTSUP) {
+ return 0;
+ }
return ret;
}
/* Card responded to CMD5, type is SDIO */ |
Description edited. |
36bff07
to
97ff080
Compare
The following west manifest projects have changed revision in this Pull Request:
⛔ DNM label due to: 1 project with PR revision Note: This message is automatically posted and updated by the Manifest GitHub Action. |
d6c6ca9
to
5a74878
Compare
I have concerns about this moving forwards without any plan to port the STM32 SDMMC driver. We are already in a situation where users or developers can get confused by the existence of the STM32 disk driver, and assume that is a supported method for using SD devices in Zephyr. If we also have an SDIO only driver for STM32, I worry that users are going to be more confused. There is also the issue that ST's SDIO layer appears to duplicate some of the SDIO initialization functionality that should be the responsibility of the SDIO stack- which is not how SDHC drivers should function. How difficult would it be (realistically) to use the SDIO layer with SDMMC? If it isn't possible I really feel that this driver needs to be implemented bare metal- we should not have stack-specific code in SDHC drivers |
Description edited. |
We have updated both the HAL and driver code. As a result, the card identification sequence is now skipped during HAL_SDIO_Init. |
Yes, we were able to reproduce the issue. We have identified and could address the problem related to the chip ID (we will discuss this later). Additionally, we resolved an issue with the block size. These fixes correct the failure of some calls; however, we are still encountering failures in subsequent calls. |
6cd605d
to
2e8ab45
Compare
2e8ab45
to
82e11c8
Compare
@ExaltZephyr any more updates? In any case, please rebase to fix the conflict, otherwise CI cannot run. Thanks! |
This commit introduces support for the SDHC driver on STM32, enabling functionality APIs for SDHC host controllers. Signed-off-by: Sara Touqan <zephyr@exalt.ps> Signed-off-by: Mohammad Odeh <zephyr@exalt.ps>
This commit adds the main DTS configurations required to enable SDHC support on STM32. Signed-off-by: Sara Touqan <zephyr@exalt.ps>
The sample performs the following: - Initializes the SDIO interface. - Reads a register using CMD52. - Writes a value using CMD52. - Verifies the write by reading back the reg. Signed-off-by: Sara Touqan <zephyr@exalt.ps>
update hal_stm32 to version that fixes an issue in SDIO driver where HAL_SDIO_Init() fails if the card identification sequence is skipped. Signed-off-by: Sara Touqan <zephyr@exalt.ps> Signed-off-by: ExaltZephyr <zephyr@exalt.ps>
This commit expands the SDIO subsystem test suite by adding support for write test. Signed-off-by: Sara Touqan <zephyr@exalt.ps> Signed-off-by: ExaltZephyr <zephyr@exalt.ps>
82e11c8
to
017f84d
Compare
|
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
Supported Modes
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.-
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.