Skip to content

Commit

Permalink
Merge branch 'fix/ssdmmc_send_cmd_set_relative_addr_rca_v5.2' into 'r…
Browse files Browse the repository at this point in the history
…elease/v5.2'

fix(sdmmc): Retry to get another RCA if the previous response was 0 (v5.2)

See merge request espressif/esp-idf!34346
  • Loading branch information
pacucha42 committed Nov 1, 2024
2 parents 13c2660 + 88d884d commit ca86e7f
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion components/sdmmc/sdmmc_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,22 @@ esp_err_t sdmmc_send_cmd_set_relative_addr(sdmmc_card_t* card, uint16_t* out_rca
if (err != ESP_OK) {
return err;
}
*out_rca = (card->is_mmc) ? mmc_rca : SD_R6_RCA(cmd.response);

if (card->is_mmc) {
*out_rca = mmc_rca;
} else {
uint16_t response_rca = SD_R6_RCA(cmd.response);
if (response_rca == 0) {
// Try to get another RCA value if RCA value in the previous response was 0x0000
// The value 0x0000 is reserved to set all cards into the Stand-by State with CMD7
err = sdmmc_send_cmd(card, &cmd);
if (err != ESP_OK) {
return err;
}
response_rca = SD_R6_RCA(cmd.response);
}
*out_rca = response_rca;
}
return ESP_OK;
}

Expand Down

0 comments on commit ca86e7f

Please sign in to comment.