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.

FAT16 on SD card, cannot find Root Directory

Status
Not open for further replies.

pepillo

Advanced Member level 4
Full Member level 1
Joined
Jan 23, 2006
Messages
114
Helped
3
Reputation
6
Reaction score
0
Trophy points
1,296
Location
Spain
Activity points
2,382
Hi,

I am implementing a system to read files on a FAT16 formatted SD card through a PIC18. However I am stuck because I cannot find the Root Directory. I apply the formulae for calculating the start of the Root Directory, as follows:

Root directory first sector = 0x00 + Number of reserved sectors + (Number of FATs * sectors per FAT)

According to the information in the Boot Sector, I get the following values:
- Number of reserved sectors = 0x0008 = 8 <-- this is weird, usually it´s only 1 in FAT16
- Number of FATs = 0x02 = 2
- Sectors per FAT = 0x00EC = 236

So, if that´s correct, the Root directory should start at sector 480 (0x01E0), but when I read that block I get all zeroes so it looks like it must be somewhere else... Does anybody know what can be wrong in there?

I attach an screenshot of the Boot Sector contents.

If you could give me some advice that would be great... Thanks. Best regards,

P

P.S.: I formatted the card on WindowsXP under "FAT" format
 

I have never worked with this before. But I have a question, why are you implementing FAT yourself instead of using a ready-made one?
--
Amr
 

Hi Amraldo,

I tried to integrate a FAT filesystem but it was too complicated, there were too many problems (I had to port it to PIC18, there was not enough information, then my compiler -CCS- couldn´t compile the libraries, etc...)

Now I am reading the FAT filesystem by myself and I am progressing well. But I am stuck as I cannot read the Root Directory even though I have calculated the position correctly (apparently).
 

I guess you can refer to the file system you were trying to port. This will speed up your process.
--
Amr Ali
 

Hi Amraldo,
Thanks for your kind reply. I already referred to the documentation when I was trying to port it, there were things that were not included in the documentation, like how to port in my specific compiler. I was bounded to using that compiler because all the rest of my code (low level routines for media access and applications) where written there.

Getting back to the Root Directory entry, does anybody know how I can find it? Thanks
 

To port a software to a new compiler, the simplest way is to add it to your compiler and try to c ompile it. Then fix errors and warnings issued by your compiler.
--
Amr
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top