FatFS f_unlink error

1 post / 0 new
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm running into an intermittent problem with FatFS and the "f_unlink" function occasionally not actually deleting files. I've traced the problem to the private function, remove_chain, which seems to occasionally respond with FR_DISK_ERR, indicating a disk error. However, if I put in one line of code,

gpio_set_pin_high(RED);    // Light up RED LED

it seems to work fine and delete the file.

I'm not really sure what the problem could be, perhaps some overzealous optimization, I am using -Os, but I'm not sure how the best way to check that would be. Has anyone else had issues with this before? I hate that it's seemingly intermittent, much harder to track down and fix...