diff --git a/firmware/target/arm/as3525/sd-as3525v2.c b/firmware/target/arm/as3525/sd-as3525v2.c index abe9ceab5f..27664ec52b 100644 --- a/firmware/target/arm/as3525/sd-as3525v2.c +++ b/firmware/target/arm/as3525/sd-as3525v2.c @@ -867,13 +867,6 @@ sd_transfer_retry_with_reinit: MCI_BYTCNT = transfer * SD_BLOCK_SIZE; - ret = sd_wait_for_tran_state(drive); - if (ret < 0) - { - ret -= 25; - goto sd_transfer_error; - } - int arg = start; if(!(card_info[drive].ocr & (1<<30))) /* not SDHC */ arg *= SD_BLOCK_SIZE; @@ -907,6 +900,18 @@ sd_transfer_retry_with_reinit: goto sd_transfer_error; } + ret = sd_wait_for_tran_state(drive); + if (ret < 0) + { + ret -= 25; + goto sd_transfer_error; + } + + /* According to datasheet DMA channel should be automatically disabled + * when transfer completes. But it not true for DMA_PERI_SD. + * Disable DMA channel manually to prevent problems with DMA. */ + dma_disable_channel(1); + if(!retry) { if(!write && !aligned)