In order to improve the speed of SD-card writing I want to perform multi-block writes.
The generic NuttX code and the stm32f device code seem to support it, even permitting DMA from the user's buffers (if certain alignment and size conditions are met).
I am testing the writing very large files, 10 to 100 MB files.
When I write 512-byte buffers (uses single block writes) everything is fine.
When I try to write 16 KB buffers (uses multiple block writes) I see...
mmcsd_geometry: Entry
mmcsd_geometry: available: true mediachanged: false writeenabled: true
mmcsd_geometry: nsectors: 7774208 sectorsize: 512
mmcsd_write: sector: 13232 nsectors: 32 sectorsize: 512
mmcsd_writemultiple: startblock=13232 nblocks=32
mmcsd_writemultiple: nbytes=16384 byte offset=13232
mmcsd_eventwait: ERROR: Awakened with 0c
mmcsd_writemultiple: ERROR: CMD25 transfer failed: -116
Write error occurred at 0/37 (MB/16KB).
Error 116 is ETIMEDOUT and occurs when the sdio driver "data delay" value decrements to 0.
The above test was run on a Class 10 SDHC card (4GB) the failure occurred after 36 16KB buffers were written successfully.
(By the way, in order to get this far I applied this patch...
diff --git a/arch/arm/src/stm32f7/stm32_sdmmc.c b/arch/arm/src/stm32f7/stm32_sdmmc.c
index 86481dd..45638e8 100644
--- a/arch/arm/src/stm32f7/stm32_sdmmc.c
+++ b/arch/arm/src/stm32f7/stm32_sdmmc.c
@@ -2201,7 +2201,9 @@ static int stm32_sendsetup(FAR struct sdio_dev_s *dev, FAR const
/* Then set up the SDIO data path */
dblocksize = stm32_log2(priv->blocksize) << STM32_SDMMC_DCTRL_DBLOCKSIZE_SHIFT;
- stm32_dataconfig(priv, SDMMC_DTIMER_DATATIMEOUT, nbytes, dblocksize);
+ //BobChange:
+// stm32_dataconfig(priv, SDMMC_DTIMER_DATATIMEOUT, nbytes, dblocksize);
+ stm32_dataconfig(priv, 0xffffffff, nbytes, dblocksize); // was 0x000fffff
Before the patch the same failures would occur after writing about 8 16K buffers.)
I have tried different cards. they all fail. The same error occurred using an U1 class 32 GB card.
That card was able to transfer a little over a Megabyte (~64 16KB buffers).
)
It is suspicious that the failures occur after a power of 2 number of 16K buffers are transferred.
The significance of a "power of 2" could be that the SD-card is doing something normal that just takes longer.
The driver seems to be trying to DMA the entire 16KBs of data at once and is expecting the SDIO to cut it into 32 512-byte (plus CRC) packets.
It seems that this is working, but sometimes inter-packet "wait for ready" delays are very very long and exceed the sdio addapter's ability to wait.
Has anyone else had problems or success writing more than 512 bytes at a time to a SD-card?
-Bob