memcpy(mmc_data + index, data, sizeof(struct sd_data_blob));
index += sizeof(struct sd_data_blob);
- /* Flush buffer to uSD ? */
+ /* Flush buffer to uSD ?
+ * Do it when there's not enough room in buffer for another chunk of data. */
if ((index + sizeof(struct sd_data_blob)) >= MMC_BUF_SIZE) {
int ret = scialys_uSD_write(last_block.block_num + 1);
if (ret != 0) {
uprintf(UART0, "Write to uSD returned %d\n", ret);
+ /* Drop old data ... we do not have that much RAM available !!! */
+ index = 0;
return ret;
}
last_block.block_num++;