I have done more investigation on this issue. It looks like the problem is in the sdcard/esdhc drivers. The problem happens on the first write to a new file. The buffer to write is 512 bytes. It is 1 block in the SD card. The driver issues a CMD24. In _esdhc_write() when the buffered CMD24 is finally sent to the device there is an ESDHC_LWEVENT_TRANSFER_ERROR. In the code below from _esdhc_write(), should line 5 be >= ?
if(_lwevent_get_signalled() & ESDHC_LWEVENT_TRANSFER_ERROR)
{
esdhc_ptr->SYSCTL |= SDHC_SYSCTL_RSTD_MASK;
if(esdhc_device_ptr->BUFFERED_CMD.BLOCKS > 1)
{
/* In this case the peripheral doesn't automatically send the CMD12, so MUST be sent manually */
ESDHC_COMMAND_STRUCT command;
command.COMMAND = ESDHC_CREATE_CMD(12, ESDHC_COMMAND_TYPE_NORMAL, ESDHC_COMMAND_RESPONSE_R1b, (ESDHC_COMMAND_NONE_FLAG));
command.ARGUMENT = 0;
command.BLOCKS = 0;
_esdhc_send_command(esdhc_device_ptr, &command, NULL);
/* Don't care about the result because the operation ends always by IO_ERROR. */
}
return IO_ERROR;
}
Paul