mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
fix(sd): use heap_caps_alloc to maintain desc alignment
This commit is contained in:
committed by
Armando (Dou Yiwen)
parent
ac3c7ddb6f
commit
70acf169e0
@@ -82,19 +82,8 @@ esp_err_t sd_host_create_sdmmc_controller(const sd_host_sdmmc_cfg_t *config, sd_
|
||||
ESP_RETURN_ON_ERROR(ret, TAG, "no available sd host controller");
|
||||
}
|
||||
|
||||
size_t alignment = 0;
|
||||
size_t cache_alignment_bytes = 0;
|
||||
ret = esp_cache_get_alignment(0, &cache_alignment_bytes);
|
||||
assert(ret == ESP_OK);
|
||||
if (cache_alignment_bytes != 0) {
|
||||
alignment = cache_alignment_bytes;
|
||||
} else {
|
||||
alignment = 4;
|
||||
}
|
||||
|
||||
ESP_LOGD(TAG, "size: %d, alignment: %d", sizeof(sdmmc_desc_t), alignment);
|
||||
ctlr->dma_desc_num = config->dma_desc_num ? config->dma_desc_num : SD_HOST_SDMMC_DMA_DESC_CNT;
|
||||
ctlr->dma_desc = heap_caps_aligned_calloc(alignment, 1, sizeof(sdmmc_desc_t) * ctlr->dma_desc_num, SD_HOST_SDMMC_DMA_ALLOC_CAPS);
|
||||
ctlr->dma_desc = heap_caps_calloc(1, sizeof(sdmmc_desc_t) * ctlr->dma_desc_num, SD_HOST_SDMMC_DMA_ALLOC_CAPS);
|
||||
ESP_LOGD(TAG, "ctlr->dma_desc addr: %p", ctlr->dma_desc);
|
||||
ESP_RETURN_ON_FALSE(ctlr->dma_desc, ESP_ERR_NO_MEM, TAG, "no mem for dma descriptors");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user