Extract from F4 errata sheet:
Code: Select all
2.12 SDIO peripheral limitations
2.12.1 SDIO HW flow control
When enabling the HW flow control by setting bit 14 of the SDIO_CLKCR register to ‘1’,
glitches can occur on the SDIOCLK output clock resulting in wrong data to be written into
the SD/MMC card or into the SDIO device. As a consequence, a CRC error will be reported
to the SD/SDIO MMC host interface (DCRCFAIL bit set to ‘1’ in SDIO_STA register).
Note: Do not use the HW flow control. Overrun errors (Rx mode) and FIFO underrun (Tx mode)
should be managed by the application software.
Conclusion: Do not use the HW flow control.
Yeah I read about that, but currently I do not know if sdfat manages any kind of errors or just fails, so I wanted to see if with HW Flow control we would get the CL10 card detected and start writing, even if it failed the hash. But in Pito's test it did not work any better.
I think we need to add at least a basic error management and retries in our layer, since the HAL SDIO drive does not provide error management (it does report, but doesn't retry).
From what I have read, I think we need to confirm before reads or writes that the card is ready to actually accept data. And once a write is completed, read the card status and confirm there were no errors, and retry if needed.
But perhaps SDFat already provides for some retry. It's kind of complicated to track it all with so many layers.
Regarding SdioEX. Basically what it adds is support for multiblock writes. The SdFat library uses a single 512byte cache. That is 1 block. So to write 10 consecutive blocks, SdioEX does this:
1-Send starting LBA to the card, and the command for multiblock write.
2.-Sends a block and return
3.- Sdfat calls the driver for another write, the drive check if the lba is the consecutive one.
4.-If so, the drive writes the new block without sending any command or address to the card.
5.- Repeat from step 3 until the LBA to write to is not consecutive, in which case send a command to stop multiblock write and start from step 1.
The HAL currently does not do that, every write implies sending command and address to the card, wait for the card to accept them, then send 1 block. Next write even if consecutive LBA address is used, will result in the whole process again.
The HAL does not provide for sending multiple blocks one by one. You can send a block of say 2KB at once, but since SdFat writes always in blocks of 512 because that is the size of the buffer, it results in single block addressing and write each time.
We could copy the parts we need from the HAL and modify for allowing multiblock writes as the SdioEX, but I wonder how much that would break compatibility between series...