Shop OBEX P1 Docs P2 Docs Learn Events
Open discussion about features to implement in FAT32/16 file system. - Page 4 — Parallax Forums

Open discussion about features to implement in FAT32/16 file system.

124»

Comments

  • ericballericball Posts: 774
    edited 2009-07-17 19:46
    Format options:

    1. Quick & simple - overwrite the MBR & VBR and make one big FAT32 partition. The question is whether you can determine the size of the SD card without user input.
    2. Quick Format - zero out the FAT & root directory of the current partition.
    3. User specified partition & format - don't update the partition table, but use the start & length info.
    4. FDISK functionality - partition table management.
    5. Same as #1, but skip the partition table and format it like a giant floppy.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Composite NTSC sprite driver: Forum
    NTSC & PAL driver templates: ObEx Forum
    OnePinTVText driver: ObEx Forum
  • lonesocklonesock Posts: 917
    edited 2009-07-17 19:55
    Kye said...
    ...
    Well... I think I'll just put a "freeALL" function that just takes an already valid FAT16 or FAT32 file system and then deletes everything on it.
    To save on flash erase cycles, I'd recommend using a multiblock write, and setting the pre-erase block size.

    Jonathan

    P.S. You had mentioned that in your block driver the 1st write fails. Some cards I have refuse to do a write first. As long as I do a readblock right after mount, everything worked. This is fine for fsrw, as the 1st thing that happens is a read of block 0.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    lonesock
    Piranha are people too.
  • KyeKye Posts: 2,200
    edited 2009-07-17 21:39
    @lonesock

    Well, its just the first write in general always fails. But it suceeds in the data transfer. The card just never gives me the all good signal. Maybe I'm giving it too little time. I just assumed it would finish within 512 more cycles of reading in busy bytes.

    @ericball

    As for formating, well, I was going to try option two. I had originally tried full FDisk functionality but that its a pain in the *** when I'm trying to keep the functions simple.

    So, I'm just going to take clusso99's advice and just leave it out.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • KyeKye Posts: 2,200
    edited 2009-07-17 21:44
    Okay, the first round of in house testing has been completed.
    FAT16 functionality with small files works. Next I'll test FAT32 with small files. I'm not sure I can really test larger files right now however as the block driver I have isn't very great at writing alot of blocks at once.
    Anway, here's the final API
    The code size with the block driver is arround 1200 longs.
    [code]
    ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
    │ File Engine │
    │ │
    │ Author: Kwabena W. Agyeman │
    │ Updated: 7/10/2009 │
    │ Designed For: P8X32A │
    │ │
    │ Copyright (c) 2009 Kwabena W. Agyeman │
    │ See end of file for terms of use. │
    │ │
    │ Driver Info: │
    │ │
    │ The file engine interfaces with a secure digital flash card allowing acess to a FAT 16/32 file system. │
    │ │
    │ The driver, is only guaranteed and tested to work at an 80Mhz system clock or higher. The driver is designed for the P8X32A │
    │ so port B will not be operational. │
    │ │
    │ Nyamekye, │
    └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
    Object "fileEngine" Interface:

    PUB readCharacter
    PUB writeCharacter(character)
    PUB writeCharacters(characters)
    PUB getCharacterPosition
    PUB setCharacterPosition(position)
    PUB closeFile
    PUB openFile(fileName, readWrite, append)
    PUB newEntry(entryName, fileOrDirectory)
    PUB deleteEntry(entryName)
    PUB renameEntry(entryNameToChange, entryNameToChangeTo)
    PUB changeEntryAttributes(entryName, readOnlyFlag, hiddenFlag, systemFlag, archiveFlag)
    PUB changeDirectory(directoryName)
    PUB listSearch(entryName)
    PUB listName
    PUB listSize
    PUB listCreationDay
    PUB listCreationMonth
    PUB listCreationYear
    PUB listCreationSeconds
    PUB listCreationMinutes
    PUB listCreationHours
    PUB listAccessDay
    PUB listAccessMonth
    PUB listAccessYear
    PUB listModificationDay
    PUB listModificationMonth
    PUB listModificationYear
    PUB listModificationSeconds
    PUB listModificationMinutes
    PUB listModificationHours
    PUB listIsReadOnly
    PUB listIsHidden
    PUB listIsSystem
    PUB listIsDirectory
    PUB listIsArchive
    PUB listReset
    PUB computeCard(freeOrUsedSpace) : buffer
    PUB mountCard(partition)
    PUB fileEngine


    3.3V


     1.8KΩ

    ─┻─ Data Out
    3.3V


     1.8KΩ

    ─┻─ Clock
    3.3V


     1.8KΩ

    ─┻─ Data In
    3.3V


     1.8KΩ

    ─┻─ Chip Select

    __________________
    PUB readCharacter
    32 Stack Longs
    ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
    │ Reads a character from the file that is currently open for reading and advances the position by one. │
    │ │
    │ Has no affect if the file is open for writing, no file is open, or a card is not mounted. Returns zero. │
    │ │
    │ Returns the character read from the file on sucess (could be zero) and zero on failure. │
    └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
    ______________________________
    PUB writeCharacter(character)
    33 Stack Longs
    ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
    │ Writes a character to the file that is currently open for writing and advances the position by one. │
    │ │
    │ Has no affect if the file is open for reading, no file is open, or a card is not mounted. Returns zero. │
    │ │
    │ Returns false on failure and true on sucess. Returns false when trying to make a file too big. │
    │ │
    │ Character - The character to write to the file. │
    └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
    ________________________________
    PUB writeCharacters(characters)
    37 Stack Longs
    ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
    │ Writes a string of characters to the file that is currently open for writing and advances the position by string length. │
    │ │
    │ Has no affect if the file is open for reading, no file is open, or a card is not mounted. Returns zero. │
    │ │
    │ Returns false on failure and true on sucess. │
    │ │
    │ Characters - A pointer to a string of characters to write to the file. │
    └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
    _________________________
    PUB getCharacterPosition
    3 Stack Longs
    ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
    │ Returns the current character position within a file for reading and writing. │
    └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
    ___________________________________
    PUB setCharacterPosition(position)
    22 Stack Longs
    ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
    │ Sets the current character position within a file for reading and writing. │
    │ │
    │ Returns true on success and false on failure. │
    │ │
    │ Position - A character position in the file. Set to false to go to the begining of the file and true to go to the end. │
    └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
    ______________
    PUB closeFile
    18 Stack Longs
    ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
    │ Closes any previously opened files. │
    │ │
    │ All files opened for writing must be closed or corruption will occur. │
    │ │
    │ Returns true on sucess and false on failure. │
    └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
    __________________________________________
    PUB openFile(fileName, readWrite, append)
    42 Stack Longs
    ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
    │ Searches the current directory for a file and opens it for reading or writing. │
    │ │
    │ Closes any previously opened files. │
    │ │
    │ The "." and ".." entries are ignored by this function. Use "listName" to see them. │
    │ │
    │ Returns a pointer to the name of the entry on success or a string of zero length if not found or false on failure. │
    │ │
    │ FileName - The name of the file to search for and open in the current directory. │
    │ ReadWrite - If true then the file is opened for writing otherwise it is opened for reading. │
    │ Append - If true then the file is opened after the last byte in that file. Only for write mode. │
    └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
    _________________________________________
    PUB newEntry(entryName, fileOrDirectory)
    41 Stack Longs
    ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
    │ Creates a new entry in the current directory. │
    │ │
    │ List functions are not valid after calling this function. │
    │ │
    │ Will do nothing and return false if a file is currently open or if the card is not mounted. │
    │ │
    │ The "." and ".." entries are ignored by this function. Use "listName" to see them. │
    │ │
    │ Returns a pointer of length on success, of no length if the request could not be processed, and false on failure. │
    │ │
    │ EntryName - The name of the new entry to create. Must be a new unique name in the current directory. │
    │ FileOrDirectory - If true then a directory is created otherwise then a file is created. │
    └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
    ___________________________
    PUB deleteEntry(entryName)
    40 Stack Longs
    ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
    │ Deletes an entry in the current directory. │
    │ │
    │ Will do nothing and return false if a file is currently open or if the card is not mounted. │
    │ │
    │ The "." and ".." entries are ignored by this function. Use "listName" to see them. │
    │ │
    │ Returns a pointer to the name of the entry on success or a string of zero length if not found or false on failure. │
    │ │
    │ EntryName - The name of the entry to delete. This entry cannot be undeleted. Directories to be deleted must be empty. │
    └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
    ________________________________________________________
    PUB renameEntry(entryNameToChange, entryNameToChangeTo)
    41 Stack Longs
    ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
    │ Renames an entry in the current directory. │
    │ │
    │ List functions are not valid after calling this function. │
    │ │
    │ Will do nothing and return false if a file is currently open or if the card is not mounted. │
    │ │
    │ The "." and ".." entries are ignored by this function. Use "listName" to see them. │
    │ │
    │ Returns a pointer to the name of the entry on success or a string of zero length if not found or false on failure. │
    │ │
    │ EntryNameToChange - The name of the entry to change. Must be in the current directory. │
    │ EntryNameToChangeTo - The name of the entry to change to. Must be a new unique name in the current directory. │
    └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
    ________________________________________________________________________________________
    PUB changeEntryAttributes(entryName, readOnlyFlag, hiddenFlag, systemFlag, archiveFlag)
    44 Stack Longs
    ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
    │ Changes the attributes of an entry in the current directory. │
    │ │
    │ List functions are not valid after calling this function. │
    │ │
    │ Will do nothing and return false if a file is currently open or if the card is not mounted. │
    │ │
    │ The "." and ".." entries are ignored by this function. Use "listName" to see them. │
    │ │
    │ Returns a pointer to the name of the entry on success or a string of zero length if not found or false on failure. │
    │ │
    │ EntryName - The name of the entry to change the attributes of. │
    │ ReadOnlyFlag - If true then the read only file/folder flag is inverted otherwise then this is ignored. │
    │ HiddenFlag - If true then the hidden file/folder flag is inverted otherwise then this is ignored. │
    │ SystemFlag - If true then the system file/folder flag is inverted otherwise then this is ignored. │
    │ ArchiveFlag - If true then the archive file/folder flag is inverted otherwise then this is ignored. │
    └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
    ___________________________________
    PUB changeDirectory(directoryName)
    40 Stack Longs
    ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
    │ Searches for a directory in the current directory to change to and move into that directory. │
    │ │
    │ List functions are not valid after calling this function. │
    │ │
    │ Will do nothing and return false if a file is currently open or if the card is not mounted. │
    │ │
    │ The "." and ".." entries are ignored by this function. Use "listName" to see them. │
    │ │
    │ Use "." to move into the current directory. │
    │ │
    │ Use ".." to move into the previous directory. │
    │ │
    │ Returns a pointer to the name of the entry on success or a string of zero length if not found or false on failure. │
    │ │
    │ DirectoryName - The name of the directory to move into. │
    └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
    __________________________
    PUB listSearch(entryName)
    36 Stack Longs
    ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
    │ Searches for an entry and validates the list functions to get information about the item if found. │
    │ │
    │ Will do nothing and return false if a file is currently open or if the card is not mounted. │
    │ │
    │ The "." and ".." entries are ignored by this function. Use "listName" to see them. │
    │ │
    │ Returns a pointer to the name of the entry on success or a string of zero length if not found or false on failure. │
    │ │
    │ EntryName - The name of the entry to search for in the current directory. │
    └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
    _____________
    PUB listName
    32 Stack Longs
    ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
    │ Returns the name of the next entry and validates the list functions to get information about the item. │
    │ │
    │ Will do nothing and return false if a file is currently open or if the card is not mounted. │
    │ │
    │ Returns a pointer to the name of the entry on success or a string of zero length if not found or false on failure. │
    └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
    _____________
    PUB listSize
    3 Stack Longs
    ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
    │ Gets the size of current file or directory pointed to by "listName". Directories have no size. │
    │ │
    │ If a file is currently open this function will retrieve that files information. │
    │ │
    │ If "listName" did not succed or was not previously called the value returned is invalid. │
    │ │
    │ Returns the size of the file or directory in bytes. │
    └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
    ____________________
    PUB listCreationDay
    3 Stack Longs
    ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
    │ Gets the creation day of the current file or directory pointed to by "listName". │
    │ │
    │ If a file is currently open this function will retrieve that files information. │
    │ │
    │ If "listName" did not succed or was not previously called the value returned is invalid. │
    │ │
    │ Returns the day of the file or directory. │
    └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
    ______________________
    PUB listCreationMonth
    3 Stack Longs
    ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
    │ Gets the creation month of the current file or directory pointed to by "listName". │
    │ │
    │ If a file is currently open this function will retrieve that files information. │
    │ │
    │ If "listName" did not succed or was not previously called the value returned is invalid. │
    │ │
    │ Returns the month of the file or directory. │
    └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
    _____________________
    PUB listCreationYear
    3 Stack Longs
    ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
    │ Gets the creation year of the current file or directory pointed to by "listName". │
    │ │
    │ If a file is currently open this function will retrieve that files information. │
    │ │
    │ If "listName" did not succed or was not previously called the value returned is invalid. │
    │ │
    │ Returns the year of the file or directory. │
    └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
    ________________________
    PUB listCreationSeconds
    3 Stack Longs
    ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
    │ Gets the creation second of the current file or directory pointed to by "listName". │
    │ │
    │ If a file is currently open this function will retrieve that files information. │
    │ │
    │ If "listName" did not succed or was not previously called the value returned is invalid. │
    │ │
    │ Returns the second of the file or directory. │
    └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
    ________________________
    PUB listCreationMinutes
    3 Stack Longs
    ┌─────────────
  • KyeKye Posts: 2,200
    edited 2009-07-17 21:46
    Oh, I guess I'll need to add block reads and writes too.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • pgbpsupgbpsu Posts: 460
    edited 2009-10-28 12:28
    Kye-

    Has this code been released? I can't find it in the obex and my search abilities can not locate it on the forums. Looks like a very useful piece of software. I'm most interested in the filesize and available disk space methods.

    Thanks,
    Peter
  • Rob7Rob7 Posts: 275
    edited 2009-10-28 15:03
    Kye,
    Everything you can ever want is in the engine !
    Thanks, Thanks, Thanks.
    When do you think it will be released ?
  • KyeKye Posts: 2,200
    edited 2009-10-29 01:10
    I'm in school right now so I'm very busy, but here's the last release of the driver if you want to play arround with it.

    I'll get back to this later when I have free time in December/January.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
Sign In or Register to comment.