I found the problem. The reference count was decrementing below 0. Here
is a fix for fatfs_node_unref() in fatfs_ncache.c.
if (node->refcnt)
node->refcnt--;
It could be that you have fixed the symptom and not the cause. Why is
it being unreferenced more times than it is referenced? Maybe there is
a missing ref() so you could get file corrupt?
Before i commit this i want a clear explanation why your change is
correct.
I also found that if you change the 512 to 32768 (sector size) in fatfs.c
call to cyg_blib_io_create() you get a 50% - 60% increase in disk
throughput, especially with large files. (driver reads writes clusters
not sectors)
Which driver? I quickly looked at the IDE and the MMC driver and both
appear to read/write blocks.
There is a FIXME where the cyg_blib_io_create() is, saying to get the
block size from the device. Maybe you want to implement this?