sdmmc: better calculation of erase timeout

Previous version of the code used a fixed constant (500 ms) for the
erase timeout and added 1 ms for each sector erased.
This commit improves timeouts calculation:
- For SD cards, check if erase timeout information is present in the
  SSR register. If yes, use it for erase timeout calculation.
  Otherwise assume 250ms per erase block, same as Linux does.
- For eMMC assume 250ms per erase block (but no less than 1 second).
  This has to be improved later to use the erase timeout info in the
  extended CSD register.
This commit is contained in:
Ivan Grokhotkov
2022-05-30 15:37:40 +02:00
parent a28828a6f4
commit 79659e3096
7 changed files with 85 additions and 10 deletions

View File

@@ -318,3 +318,12 @@ esp_err_t sdmmc_fix_host_flags(sdmmc_card_t* card)
}
return ESP_OK;
}
uint32_t sdmmc_get_erase_timeout_ms(const sdmmc_card_t* card, int arg, size_t erase_size_kb)
{
if (card->is_mmc) {
return sdmmc_mmc_get_erase_timeout_ms(card, arg, erase_size_kb);
} else {
return sdmmc_sd_get_erase_timeout_ms(card, arg, erase_size_kb);
}
}