Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

SD Card Free Space Calculation

Status
Not open for further replies.

w_bwr

Member level 3
Member level 3
Joined
Feb 4, 2010
Messages
66
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Karachi, Pakistan
Visit site
Activity points
1,810
Hi,

I want to find the free space on SD Card. What i am doing reading out every sector and mark the free sectors. In the end, multiplying it with number of clusters and BytesPerSector. it works fine. but it takes much time on 40MHz micorcontroller and the time increases with the increase in the size of Sd Card.

Is there any other way to calculate the free space?
 

There's no other way than scanning the FAT for free clusters. A fast file system implementation would want to buffer the FAT content, but I guess that's no option for your microcontroller, due to lack of memory capacity.
 

Are you referring to an SD Card formatted in FAT?

Yes, I was referring to an SD Card formatted in FAT/FAT32.

There's no other way than scanning the FAT for free clusters.

Yes, this is true for FAT only. For FAT32, there is structure INFO Sector, usually the 1st sector, that contains the information about number of free clusters, and next free cluster etc.
Reading the sector, significantly reduces the time.

Well, I am facing another problem now. Every time I reset the my micro controller, the SD card successful initialization happen on alternate turns.
The ACMD41 command fails every 2nd reset. But if I reset the controller again, it initializes fine. what could be the reason for that?
 

Yes, this is true for FAT only. For FAT32, there is structure INFO Sector, usually the 1st sector, that contains the information about number of free clusters, and next free cluster etc.
Reading the sector, significantly reduces the time.

The FAT32 FSInfo entries FSI_Free_Count and FSI_Nxt_Free are optional and rarely used by embedded FAT32 implementations. In so far, the statement is probably true for FAT32 as well well. In any case, a FAT32 implementation must be prepared to compute the said values by itself. See the MS FAT32 specification for details.

The ACMD41 command fails every 2nd reset.
Fails how?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top