Hi Alejandro,
I have some new information to report. I noticed this forum post which is similar to the problem I'm experiencing though it's on the K70FX platform (mine is Vybrid). It prompted me to look at the sdcard driver and investigate a little deeper. One observation I made recently was that the frequency of the data corruption seems to be affected by ethernet communication activity. Few errors occur with the network cables left disconnected but would immediately increase once the network cable was connected on both our board and the TWR board. The test I'm performing continually reads a 1MB file from the sdcard and performs an MD5 checksum of the file which it then compares with the known checksum - roughly once a second. I've found that with network communication active it fails about 30% of the time.
As a test I modified the sdcard driver to disable interrupts while data was being copied to/from the sdcard dma buffer. The result was that it significantly reduced the number of errors (6 errors in 330,000 file reads).
Here is the portion of the code that I modified in esdhc.c:
In esdhc_read() beginning at around line 1554:
#if ESDHC_IS_HANDLING_CACHE
_int_disable();
if (head_len)
{
_DCACHE_INVALIDATE_LINE(head);
_mem_copy(head, data_ptr, head_len);
}
if (body_len)
{
_DCACHE_INVALIDATE_MBYTES(body, body_len);
}
if (tail_len)
{
_DCACHE_INVALIDATE_LINE(tail);
_mem_copy(tail, ((uint8_t *)data_ptr) + head_len + body_len, tail_len);
}
_int_enable();
#endif
{
_DCACHE_INVALIDATE_LINE(tail);
_mem_copy(tail, ((uint8_t *)data_ptr) + head_len + body_len, tail_len);
}
In esdhc_write() beginning at around line 1692:
_int_disable();
/* Flush caches */
if (head_len)
{
_mem_copy(data_ptr, head, head_len);
_DCACHE_FLUSH_LINE(head);
}
if (body_len)
{
_DCACHE_FLUSH_MBYTES(body, body_len);
}
if (tail_len)
{
_mem_copy(((uint8_t*)data_ptr) + head_len + body_len, tail, tail_len);
_DCACHE_FLUSH_LINE(tail);
}
_int_enable();