This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Diff between File system and FAT file system

Hi to all, i started to work on FAT file system on SD 1GB card. LPC2388 on MCB2300 board.

Just now i have completed my binary search on File system on SD card. Simply fopen, fread, fseek,etc.

Now i have to work on SD card using FAT file system. i went through so many web pages that didnt answer my question or i was not able to understand.

how to make a File allocating table on my SD Card? Some simple example can give me a good start...

my question is Whats the difference between Normal File system (which i have done on my SD card) and FAT File system?

And I had formatted the SD card on LAPTOP with the 2 options of FAT(Default) and FAT32.
When i tried to use the card after i did format using FAT(Default) option, i was able to work with my code which i developed for SD card using normal File system.

But if format using FAT32 option, then while trying to initialize the card it says SD card un formatted.

So what its trying to say?

So by default my controller accept FAT12?

Can i use FAT32 on the same SD card for my same code in which i didnt give an option to recognize FAT32?

As i studied from the web source for FAT16, the clusters address divide my SD card in to sectors and gives back the location address to me(2^16 address)?

So on for FAT32?

So please give me some clear explanation how to start? And i gone through Wikipedia and all the sources so dont give me the link for wikipedia pls.

  • Just now i have completed my binary search on File system on SD card. Simply fopen, fread, fseek,etc.

    Now i have to work on SD card using FAT file system

    but how could you, without implementing your own FAT FS?
    please explain and try to focus your questions to the core issues - what EXACTLY are you trying to do?

  • FAT12, FAT16 or FAT32 are basically the same thing. The big difference is how many bits that are used in each FAT entry, to point at a usable cluster. With 12 bits, you can not have more than 4096 clusters. With 16 bits, you can have at most 65536 clusters. With 32 bits, you can have 2^32 clusters.

    For a large memory card, you will either need to have few but large clusters, or switch to a version of the FAT file system that has more bits to address many smaller clusters.

    You can write code that autodetects if a memory card has FAT12, FAT16 or FAT32. I really do thing you should return to the wikipedia pages and read them again - and possibly a third time. If you are going to implement your own FAT code, then you must understand how the FAT file system works. How to detect the file-system parameters (such as FS type, cluster size, ...) How to locate a primary and secondary FAT. How to locate the root directory. How to translate a directory entry into a chain if clusters. How to compute the address of these clusters to retrieve the data. How to differentiate between used and unused clusters (in case you need write support).

  • "Whats the difference between Normal File system (which i have done on my SD card) and FAT File system?"

    There is no such thing as a "Normal File system" - there are plenty of different file systems, but you can't say that one of them is uniquely "Normal" and all the others are not!

    "FAT File System" is usually taken to mean the Microsoft FAT File System - as found on MS-DOS and later Microsoft systems.

    The technical specification of the Microsoft FAT File System is available for free download here: www.microsoft.com/.../fatgen.mspx

    FatFs is an open-source implementation of the Microsoft FAT File System: elm-chan.org/.../00index_e.html

    It includes an example for SD Cards: elm-chan.org/.../mmc_e.html

  • but how could you, without implementing your own FAT FS?
    please explain and try to focus your questions to the core issues - what EXACTLY are you trying to do?

    y did i say that means I didnt create any clusters, volume , drive and directory. by default it may be FAT12 i think.

    In the file_config.c i made my default drive as memory card drive.

    i was using RT Agent and File_config.h which provided by RL ARM.

    So i was directly influenced by create anything.

    So as you said should i have a FAT to implement a file system?
    My code working well. So what FAT's role over there?

    When ever i need a data i just fopen, fread and fseek with the data what ever i need. if a match occurs simply i read the data from that location using offset..

            FILE *loc;
            FILE *dat;
            loc = fopen ("Index.txt", "r");
            dat = fopen ("UserLocation.txt", "r");
    

    then i do the Binary searching

            mid = (begin + end) / 2;
                    offset = mid;
    
                fseek (loc, offset * 2, SEEK_SET);
                fread (&count2[0], 2, 1, loc);
    
                    location = count2[0];
    
                fseek (dat, location * 4, SEEK_SET);
                    fread (&First_fourByte[0], 4, 1, dat);
    

    Then normal C code...

    I think i did not understand the FAT FS well. I know there might be some good for me when i understand it fully. Where i am using FAT here?

  • However i cant fseek a data when i opened a file for writing?

    So can a FAT fs fix this issue?

  • Is that a question, or a statement?

    Does the specification of your fseek function say that this should be possible?

    "can a FAT fs fix this issue?"

    See previous reply: "a FAT fs" simply means any file system that uses a File Allocation Table - so it is impossible to answer your question without knowing which specific FAT File System you are talking about, and which specific implementation of that file system you are talking about!

  • Something still i am in confusion..

    FAT12 can have 2^12 clusters.
    so Each cluster can hold how much data?
    A typical cluster size is 2,048 bytes, 4,096 bytes, or 8,192 bytes

    So for my 1 GB SD card how many clusters i need and what ill be the each clusters size/
    and how its depend my project requirement?

    Explain me with an example if you wish..

    continue....How it relates to Size of the memory card?
    And how to choose a FAT(12 or 16 or 32) with the size of SD card?
    What are the criteria presents to choose a FAT fs?

    And FAT32 or FAT16 formatting can only done by PC or our MCU can do this?

    as per said How can we figure out which FAT system table available in the SD card by using a MCU?

  • I think the format to be used on the card is defined by the card manufacturers.

    If you use the elm-chan.org/.../00index_e.html implementation, this is all handled for you.

  • You don't want to receive Wiki links, but the question is:
    Have you _really_ read this page?
    en.wikipedia.org/.../File_Allocation_Table

    1GB and max 32kB cluster size means how many clusters?
    4096 clusters * 32kB is 128MB.

    Any PC or microcontroller can create a FAT12, FAT16 or FAT32 file system. It is just a question of if the used source code supports it, and if the connected hardware needs it.

    A camera can manage reasonably well with FAT16, since it generates few, but large, photos. This means that the waste will be small if you format the memory card with very large clusters.

    But 65536 clusters of 32kB is still a limiting factor, since that would represent a limit of 2GB.

    You might have noticed that older cameras (or MP3 players, ...) do not support FAT32 and can't be used with larger memory cards.

    Next step up is of course to consider patens and licenses. Microsoft will _probably_ only be able to sue if you implement support for long file names. The alternative is to pay licensing fees.

  • ->
    However i cant fseek a data when i opened a file for writing?

    So can a FAT fs fix this issue?
    <-

    http://www.keil.com/support/man/docs/rlarm/rlarm_fseek.htm

    Note

    * Seeking within a file opened for "w" mode is currently unsupported.

  • Hi keil Enthu,

    To better understand and control the SD-card on you embedded system, you need to learn a lot of things. There is no shortcut.

    But in your situation, you might be able to treat something as a Black Box, and just use them until you encounter a related problem.

    However, you must need to read the manual of RLARM, it is the basic requirement.

  • Only if he is actually using RLARM - which has not been mentioned before.

    RLARM is certainly not necessary to implement a File System - including the MS FAT File Systems - on an SD Card.

  • Ok i take all your advice.

    but if i get any simple or big doubt, to whom i can ask??

    i can ask here and to you peoples only...:)

    I dont want to make more no of threads by simply asking small small doubts(Even i try to figure out by my self) and wasting your time ...

    Then my post may not be worthy to all. may give bore to the thread readers...

    Thats why i wanted to make it as single and bulk...

    Anyway i want to make this post as worth for me.

    So in the chan's documents in which i went through, What they mean by Disk(Isn't not SD card)?

    Whats that No of physical drive on SD card?

    And on SD card also do we have physical drives?

    Do we have to partition the SD card into no of physical drives?and how?

  • Only if he is actually using RLARM - which has not been mentioned before.

    I was using RLARM only for my existing project(Binary search on SD card file system).

  • Are you going to implement a FATx file system yourself, or use an existing implementation?

    If you are going to implement one - format the card in a PC and then read back the structures and analyze them. That should give you a lot of ideas about how a FAT file system works.