Problem with SD card init after unexpected CPU reset

Discussion to talk about software related topics only.
Post Reply
Taris
Posts: 6
Joined: Sat Oct 31, 2009 8:03 am

Problem with SD card init after unexpected CPU reset

Post by Taris »

Hello,

I have a problem with SD card after CPU reseting. I'm using an example "nburn\examples\EFFS\EFFS-BASIC" for to find out how to work with SD card.
The program works great if I wait until program starts and only then I insert SD card and press <enter> button. You can see a log below:

********************************************************************
===== Starting EFFS BASIC MMC/SD Program =====
No MMC/SD card detected. Insert a card and then press <Enter>
FAT mount to SD/MMC successful
SD/MMC drive change successful
Retrieving external flash usage...
Flash card memory usage (bytes):
32014336 total, 32012288 free, 2048 used, 0 bad
Found File [TESTFILE.TXT] : 75 Bytes

Creating test file: TestFile.txt
Wrote 15 bytes: Hello World 0
Wrote 15 bytes: Hello World 1
Wrote 15 bytes: Hello World 2
Wrote 15 bytes: Hello World 3
Wrote 15 bytes: Hello World 4

Rewinding file
Read 75 bytes:
Hello World 0
Hello World 1
Hello World 2
Hello World 3
Hello World 4

Closing file TestFile.txt

Unmounting SD/MMC card

Program complete. Reset to repeat
**********************************************************************

After this test I press reset button with inserted SD card and this time the program does not work correctly. You can see the log below:

**********************************************************************
===== Starting EFFS BASIC MMC/SD Program =====
FAT mount to SD/MMC failed: F_ERR_NOTFORMATTED
Retrieving external flash usage...

*** Error in f_getfreepace(): F_ERR_NOTFORMATTED

Creating test file: TestFile.txt

*** Error opening file "TestFile.txt", fp = 0
Unmounting SD/MMC card

Program complete. Reset to repeat
***********************************************************************

Why does not the program work correctly after reset with iserted SD card second time?
I would like write a program which will initialize a SD (with FAT) card properly after unexpected CPU reseting. Now I need remove SD card after first unexpected CPU reseting then insert and initialize.

Best regards
rnixon
Posts: 833
Joined: Thu Apr 24, 2008 3:59 pm

Re: Problem with SD card init after unexpected CPU reset

Post by rnixon »

What happens if you format the sd card to fat 32 on your pc, then repeat that test?

Can you see the files if, after just the first part where it appears to work correctly, you then put it in your pc and view the files. Are they intact?
Taris
Posts: 6
Joined: Sat Oct 31, 2009 8:03 am

Re: Problem with SD card init after unexpected CPU reset

Post by Taris »

rnixon wrote:What happens if you format the sd card to fat 32 on your pc, then repeat that test?

Can you see the files if, after just the first part where it appears to work correctly, you then put it in your pc and view the files. Are they intact?
I made a mistake I'm using not SD card but MMC card!!! It is SanDisk MMC 32MB card. I can't format this card to FAT32
I can see files with my pc. There is no problem with card. Yes I know that this card is very old :) , but it was first card which I found at home :). I will try to find new module card and I will repeat the test...
Taris
Posts: 6
Joined: Sat Oct 31, 2009 8:03 am

Re: Problem with SD card init after unexpected CPU reset

Post by Taris »

Taris wrote:
rnixon wrote:What happens if you format the sd card to fat 32 on your pc, then repeat that test?

Can you see the files if, after just the first part where it appears to work correctly, you then put it in your pc and view the files. Are they intact?
I made a mistake I'm using not SD card but MMC card!!! It is SanDisk MMC 32MB card. I can't format this card to FAT32
I can see files with my pc. There is no problem with card. Yes I know that this card is very old :) , but it was first card which I found at home :). I will try to find new module card and I will repeat the test...
I made this test (I wrote in my first post) with Kingston 2GB SD card and the test program worked great after second CPU reset. I don't understand why are the testing results is different with Sandisk MMC 32MB :) and Kingston 2GB SD...???? Do EFFS Function calls support old MMC card? Does somebody know about this issue? There is no guarantee that customers won't insert old 32MB MMC card...
What is a program skeleton which have possibility to reinitialize SD (with FAT) after unexpected CPU reset?
Post Reply