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.

Parents
  • "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

Reply
  • "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

Children
  • 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.

  • You are referring to elm-chan.org/.../00index_e.html aren't you?

    You need to make this clear, as not everyone reading this thread will automatically know what you mean by "the chan's documents"

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

    It uses the term "disk" generically to mean "the physical storage medium" - so that includes real disks, SD-Cards, or anything else.

    This is much the same as the way that PCs view storage media like SD-Cards and USB sticks: they all appear as "drives", and it is (largely) irrelevant whether the "drive" is a real disk or not...

  • I think that may not be a good idea?

    I seem to remember reading somewhere that you need to take care when formatting an SD-Card in a PC - or you can end up with an inappropriate format.

    The disks come correctly formatted from the manufacturer - so don't mess with the formatting if at all poissible!

  • This is the classical concept already discussed above. Format with FAT16 and huge clusters, or FAT32 and small clusters. And a lot of MP3 players or cameras will not support FAT32, in which case they will reject a card that is default-formatted by a PC.

    That is a good reason for formatting a card in the device it is intended to be used with.

    If the goal is to decode data structures, then it is helpful to also test with the values generated by a PC. A number of cameras manages to generate incorrect file systems, where some fields either have incorrect values, or no values at all.

  • Hi to all,
    I trying to understand the FAT fs. So i made some efforts for that. now i am referring www.siwawi.arubi.uni-kl.de/.../

    i made some changes on the code and i got some results :).

    my code from main.c is:

        FATFS *fs;/* Pointer to file system object */
        DWORD fre_clust, fre_sect, tot_sect;
        DRESULT Disk;
        FRESULT res1;
    
    
    
    
        IoInit(); //Timer, UART and LED initialize
    
        xputs("\nFatFs module test monitor for LPC2388");
    
        w1 = f_mount(0,fs); // mounting logical drive 0
        xprintf("\r\nmount status %d",w1);
    
    //    res = disk_initialize(0); // physical drive 0. But i dont know why
    //      xprintf("\r\n Return value of diak_initilize() is %d",res);
    
         Disk = disk_status(0); // status if physical drive 0
         xprintf("\r\n Return value of diak_status() is %x",Disk);
    
    
        // Get drive information and free clusters
        res1 = f_getfree("/Test.txt", &fre_clust, &fs);
        if (res1)
            put_rc(res1);
        xprintf("\r\n Retuen value of getfree() is %d",res1);
    
    //      xprintf("\r\n Free Clusters %ld",fre_clust);
    
    
    
    
        // Get total sectors and free sectors
        tot_sect = (fs->max_clust - 2) * fs->csize;
        fre_sect = fre_clust * fs->csize;
    
        // Print free space in unit of KB (assuming 512B/sector)
        xprintf("%\r\nlu KB total drive space.\n"
               "%lu KB available.\n",
               fre_sect / 2, tot_sect / 2);
    
    
        // Open source file
        res1 = f_open(&file1, "Test.txt", FA_OPEN_EXISTING | FA_READ);
        if (res1)
            {
                    put_rc(res1);
            }
            xprintf("\r\n status Opening Test1 file %d",res1);
    
        // Create destination file
        res1 = f_open(&file2, "b.txt", FA_CREATE_ALWAYS | FA_WRITE);
        if (res1)
            {
                    put_rc(res1);
            }
            xprintf("\r\n status of opening b file %d",res1);
    
    
        // Copy source to destination
        for (;;)
            {
            res1 = f_read(&file1, Buff, sizeof(Buff), &br);
            if (res1 || br == 0)
                    {
                            put_rc(res1);
                            xprintf("\r\n Reading status %d",res1);
                            break;   // error or eof
                    }
                    xprintf("\r\n Read sta %d",w1);
            res1 = f_write(&file2, Buff, br, &bw);
            if (res1 || bw < br)
                    {
                            put_rc(res1);
                            xprintf("\r\n write status %d",res1);
                            break;   // error or disk full
                    }
            xprintf("\r\n Write Sta %d",w1);
        }
    
       // Close all files
        f_close(&file1);
        f_close(&file2);
    
        // Unregister a work area before discard it
        f_mount(0, NULL);
    

    i give the result here.

    FatFs module test monitor for LPC2388

    mount status 0

    Return value of diak_status() is MCI_INIT ok
    no timeout on CMD8 -> SD-Card>=Version 2.0
    ACMD41 success -> SD-Card SC or HC
    SDSC detected
    MCI_Send_CSD result: 002f0032 5f5983bd edb7ff9f 964000a8
    setting 4bit width success

    rc=11 FR_NO_FILESYSTEM
    Retuen value of getfree() is 11MCI_INIT ok
    no timeout on CMD8 -> SD-Card>=Version 2.0
    ACMD41 success -> SD-Card SC or HC
    SDSC detected
    MCI_Send_CSD result: 002f0032 5f5983bd edb7ff9f 964000a8
    setting 4bit width success

    rc=11 FR_NO_FILESYSTEM

    status Opening Test1 file 11MCI_INIT ok
    no timeout on CMD8 -> SD-Card>=Version 2.0
    ACMD41 success -> SD-Card SC or HC
    SDSC detected
    MCI_Send_CSD result: 002f0032 5f5983bd edb7ff9f 964000a8

    I dont remember that i formatted SD card by either FAT32 or FAT Default.

    But after the result i tried to format it again, but it using FAT32 but it says write protected.
    But i didnt make it as write protected.

    So how can i remove this Write protected?

    I dont know whats the MCI_Send_CSD result?
    What those values tell me?

    Then i tried to fwrite a file and copy that file to another file. but i always failed. Y?

    The way i am going on is correct or not?
    From Andy and per's lot of reply helped me to come to this level. But still i need more....

    f_mkdir("0:sub1");
    


    It says invalied drive.
    But

    f_mkdir("1:sub1");
    

    This one succeed. but is this a folder? like we create a new folder in Harddisk?

    But i tried to read themon laptop. but no sign of them.
    However it says write protected, but creating root directory has been succeed?

    pls. need help?