Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/sdmmc/sdmmc_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ esp_err_t sdmmc_send_cmd_send_op_cond(sdmmc_card_t* card, uint32_t ocr, uint32_t
.flags = SCF_CMD_BCR | SCF_RSP_R3,
.opcode = SD_APP_OP_COND
};
int nretries = SDMMC_SEND_OP_COND_MAX_RETRIES;
int nretries = SDMMC_SEND_OP_COND_MAX_RETRIES * 5;
int err_cnt = SDMMC_SEND_OP_COND_MAX_ERRORS;
for (; nretries != 0; --nretries) {
bzero(&cmd, sizeof cmd);
Expand Down
6 changes: 6 additions & 0 deletions components/sdmmc/sdmmc_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ esp_err_t sdmmc_card_init(const sdmmc_host_t* config, sdmmc_card_t* card)
#if CONFIG_SD_ENABLE_SDIO_SUPPORT
/* IO_SEND_OP_COND(CMD5), Determine if the card is an IO card. */
SDMMC_INIT_STEP(io_supported, sdmmc_init_io);
/* Some cards (especially after CMD5) delay R1 response by up to 8 bytes.
* If the next command starts too soon, the old 0x05 (illegal cmd) byte
* corrupts the new CMD frame (seen as CRC_ON_OFF fail). */
if (card->is_mem) {
SDMMC_INIT_STEP(always, sdmmc_send_cmd_go_idle_state);
}
Copy link

Choose a reason for hiding this comment

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

Bug: CMD0 Workaround Inconsistency Affects Memory Cards

The CMD0 workaround for CMD5 response delay corruption is applied only to memory cards (card->is_mem) and only when SDIO support is enabled. This means memory cards may not receive the fix if SDIO support is disabled, potentially causing CRC errors. The card->is_mem condition also seems inconsistent with the comment's description of the issue occurring "especially after CMD5," which is an SDIO-related command.

Fix in Cursor Fix in Web

#endif

const bool is_mem = card->is_mem;
Expand Down