cancel
Showing results for 
Search instead for 
Did you mean: 

Is stm32f7 HAL v1.15 mmc driver broken? I try to read out several blocks. The first block reads normally, while the others are filled with zeros

MSmit.7
Associate

Hi. I have stm32f722re connected with emmc MTFC4GMWDQ by 8-bit interface.

When I read out the data from the card, I see in the debugger that starting from index 512 to the end, the second buffer is filled with zeros.

This behavior is observed in blocking mode, interrupt, and DMA.

Error reproduction code below.

...
 
#define BLOCKS_COUNT 2
 
uint8_t buffers[2][512 * BLOCKS_COUNT];
uint8_t write_buffer[512 * BLOCKS_COUNT];
 
int main() {
 
    ... 
 
    HAL_StatusTypeDef status;
 
    status = HAL_MMC_InitCard(&hmmc1);
    if (status != HAL_OK)
        Error_Handler();
 
    while (HAL_MMC_GetCardState(&hmmc1) != HAL_MMC_CARD_TRANSFER)
        ;
 
    for (int i = 0; i < 512 * BLOCKS_COUNT; i++)
        write_buffer[i] = i % 256;
 
    for (int i = 0; i < BLOCKS_COUNT; i++) {
        while (HAL_MMC_GetCardState(&hmmc1) != HAL_MMC_CARD_TRANSFER)
            ;
 
        status = HAL_MMC_WriteBlocks(&hmmc1, write_buffer + i * 512, i + 3000, 1, 0x100000);
        if (status != HAL_OK)
            Error_Handler();
    }
 
    for (int i = 0; i < BLOCKS_COUNT; i++) {
        while (HAL_MMC_GetCardState(&hmmc1) != HAL_MMC_CARD_TRANSFER)
            ;
 
        status = HAL_MMC_ReadBlocks(&hmmc1, buffers[0] + i * 512, i + 3000, 1, 0x100000);
        if (status != HAL_OK)
            Error_Handler();
    }
 
    while (HAL_MMC_GetCardState(&hmmc1) != HAL_MMC_CARD_TRANSFER)
        ;
 
    status = HAL_MMC_ReadBlocks_IT(&hmmc1, buffers[1], 3000, BLOCKS_COUNT);
    if (status != HAL_OK)
        Error_Handler();
 
        while (HAL_MMC_GetCardState(&hmmc1) != HAL_MMC_CARD_TRANSFER)
            ;
 
    for (int i = 0; i < BLOCKS_COUNT * 512; i++) {
        if (buffers[0][i] != buffers[1][i])
            Error_Handler(); // here i get when the second block starts
    }
 
  while (1) {
    ...
  }
 
return 0;
}
 
...

BTW

I tried to run the same code on the h743 nucleo, but with an SD card and it works.

0 REPLIES 0