The previous thread is now marked read only, so I'm posting the workaround here. Add one line to the init driver: /*-----------------------------------------------------------------------------
* Initialize the Flash File System
*----------------------------------------------------------------------------*/
void initFS (void) {
U32 retv;
retv = finit(NULL);
while ((retv = finit (NULL)) != 0) { /* Wait until the FS is ready */
if (retv == 1) {
bugOut ("\nSD/MMC Init Failed");
bugOut ("\nInsert Memory card and press key...\n");
while (getkey () == 0);
}
else {
bugOut ("\nSD/MMC Card is Unformatted");
strcpy (&in_line[0], "AEGIS\r\n");
cmdFormat (&in_line[0]);
now it works 100%
Why two finit() lines? Why not just the second line?
There are two threads with this title, go read the previous one. Basically there's a problem where the finit fails half the time under some circumstances. If you have the problem, having two finits cures it. If you don't have the problem it doesn't hurt.
Yes, but the second line should represent "two finit()" since it contains a loop to repeat the call until it doesn't fail (or possibly hangs the application for ever). So what is the reason of a separate finit() before the one in the while loop?
The second one just loops until some kind of return. In this case, half the time it fails, and then you have to deal with it. If you do the first one, then the second, it does not fail.
Yes. But the loop would loop until it gets happy even without the preceding call.
So the first line should not be needed, unless the first call sometimes returns zero despite actually failing. So is the first call returning zero (OK) even when failing?
The loop returns that it failed, and then tells the user to put in the SD card and try again. The SD card is already in, and is fine, so it should not have failed and not alerted the customer to a problem that doesn't exist. That's a guaranteed customer service call. The problem is discerning when the finit call is just fubar or when the card really isn't in and the customer does need to be notified. There are other solutions, I just found this one to be the simplest.