Closed asarbs closed 2 years ago
static int sdmmc_send_ocr(struct sd_card *card, int ocr_arg)
{
struct sdhc_command cmd;
int ret;
int retries;
cmd.opcode = SD_APP_SEND_OP_COND;
cmd.arg = ocr_arg;
cmd.response_type = (SD_RSP_TYPE_R3 | SD_SPI_RSP_TYPE_R1);
cmd.timeout_ms = CONFIG_SD_CMD_TIMEOUT;
/* Send initialization ACMD41 */
for (retries = 0; retries < CONFIG_SD_OCR_RETRY_COUNT; retries++) {
**LOG_INF("retries=%d", retries);**
ret = sdmmc_app_command(card, 0U);
if (ret == SD_RETRY) {
/* Retry */
continue;
} else if (ret) {
return ret;
}
ret = sdhc_request(card->sdhc, &cmd, NULL);
if (ret) {
/* OCR failed */
return ret;
}
if (ocr_arg == 0) {
/* Just probing, don't wait for card to exit busy state */
return 0;
}
/*
* Check to see if card is busy with power up. PWR_BUSY
* flag will be cleared when card finishes power up sequence
*/
if (card->host_props.is_spi) {
if (!(cmd.response[0] & SD_SPI_R1IDLE_STATE)) {
break;
}
} else {
if ((cmd.response[0U] & SD_OCR_PWR_BUSY_FLAG)) {
break;
}
}
sd_delay(10);
}
if (retries >= CONFIG_SD_OCR_RETRY_COUNT) {
/* OCR timed out */
LOG_ERR("Card never left busy state");
return -ETIMEDOUT;
}
LOG_DBG("SDMMC responded to ACMD41 after %d attempts", retries);
if (!card->host_props.is_spi) {
/* Save OCR */
card->ocr = cmd.response[0U];
}
return 0;
}
After add of this LOG_INF line problem stop to occur.
@asarbs what board are you building for?
I'm using mimxrt1020_evk
I have do some more investigation and i have information that if i set CONFIG_SPEED_OPTIMIZATIONS=y, mount point flags suggest that this is READ ONLY File system and CONFIG_SPEED_OPTIMIZATIONS=n, mount point flags suggest that we can write.
I have found solution mp.type = FS_FATFS; mp.fs_data = &fat_fs; mp.mnt_point = _disk_mount_pt; mp.flags = 0; if (fs_mount(&mp) != FR_OK) {
@asarbs Interesting that this fixes the issue- based on your initial description I expected the issue was that CMD55 (app command) was being sent to the card too soon after CMD8. If you replace the LOG_INF
statement with k_busy_wait(100)
is the issue also resolved?
@danieldegrasse sorry last comment was my mistake, if we are talking about initial issue I still don't have solution.
@asarbs, sorry, missed this notification and was on PTO this past week. Will changing the LOG_INF
statement out for k_busy_wait
work to fix the issue?
@danieldegrasse yes.
Describe the bug
When I'm turning on
CONFIG_SPEED_OPTIMIZATIONS=y
I'm gettingsd:Card never left busy state
error.To Reproduce Steps to reproduce the behavior: prj.conf
I don't have this problem when i setup comment out
CONFIG_SPEED_OPTIMIZATIONS=y
from my config file.Expected behavior I'm able to read from SD card files with
CONFIG_SPEED_OPTIMIZATIONS=y
Impact I can't use
CONFIG_SPEED_OPTIMIZATIONS=y
Logs and console output
Environment (please complete the following information):
Additional context Add any other context that could be relevant to your issue, such as pin setting, target configuration, ...