Skip to main content

Fat32 complete library in asm language

Observing that the file system created by me is almost identical to FAT32, i decided to convert to FAT32, this library work with clusters from 256 bytes to 32768 bytes autodetect from storage device.

This library is in asm language.

This file system is designed for double buffered (a buffer to the Allocation Table and a data buffer) this method of using separate buffers increase the rate of transfer to the storage device.

The buffer’s separation between allocation table and the data, makes that at each change of the data cluster not to charge the next cluster index from storage device. In this case, the index is token from allocation table’s buffer, if this is inside the sector memorized inside buffer. If this is not inside the sector of the buffer, then will be saved the buffer in allocation table (in case that inside the buffer has been made a modification), and then will be loaded in the sector where the index is.

In this way can be made with the data buffer. The pointer can be putted at an particular offset from open file, and then, from the address of the pointer can be read byte with byte, the pointer been incremented automatically. The same will be the sectors inside the buffer, those will be changed automatically. It doesn’t matter for user which cluster or bit must be read, because everything is done automatically. User must set the address of the file needed and the pointer of the address of the byte inside the file.

Done functions:
-Go to file/folder ( address in clusters )
-Go to next file/folder in current directory ( this function return Flag T in Sreg = 0 if the pointer is on bottom of the list else return 1)
-Go to forward file folder in current directory ( this function return Flag T in Sreg = 0 if the pointer is on top of the list else return 1)
-Read address on pointed file/folder ( in clusters )
-Read short name of pointed file/folder ( string 11 char )
-Read full name of pointed file/folder ( string max 128 char )
-Read byte by byte the file opened ( offset of byte in file ) with autoincrement pointer
-Write byte by byte in the file opened ( offset of byte in file ) with autoincrement pointer ( this function work with append in file and have property to enlarge the size of file )
-Read pointed file size (in bytes)
-Write pointed file size = current pointer
-Read pointed file attribute
-Write pointed file attribute
-Read pointer in opened file
-Write pointer in opened file
-Create file with short name converted from long name( Creating with long name not completed )
-CloseFile ( when the file is closed if the pointer in file is bigger to actual size of file , the actual size of file = pointer position in file ( in read mode is not possible to point to an byte address bigger to file size but in write mode this is possible because the file is auto enlarged )

The terminal have next functions:
+ :
Go Down one file folder and read short and long file name.
- :
Go Up one file folder and read short and long file name.
Enter :
1) Go to selected folder,
2) Open selected file,
3) Close opened file.
Esc :
Close opened file
p :
Enter in write long file name, and Enter will convert from long filename to short filename
c :
Create file with converted short filename


Performance obtained with ATmega640 at 16 Mhz and SPI hardware at 8Mhz:

Write SD Card with 512 Bytes/cluster = 48659 Bytes/s
Write SD Card with 4096 Bytes/cluster = 40163 Bytes/s
Read SD Card with 512 Bytes/cluster = 70286 Bytes/s
Read SD Card with 4096 Bytes/cluster = 56229 Bytes/s

Transfer rate depends on the device storage and on fragmentation.
The flash used not include the terminal

Resources for maxim 512 bytes/cluster:
Flash= 3220 Bytes ( Only read section )
Flash= 5042 Bytes ( Read and write sections )
Ram for allocation table management= 542
Ram for data management= 629 (512Bytes (Data Buffer)+ 64 (Bytes String Long Name) + 11Bytes (String Short Name) + Variables )
Total Ram= 1171Bytes

Resources for maxim 4096 bytes/cluster:
Flash= 3220 Bytes ( Only read section )
Flash= 5042 Bytes ( Read and write sections )
Ram for allocation table management= 542
Ram for data management= 4213 (4096Bytes (Data Buffer)+ 64 Bytes (String Long Name) + 11Bytes (String Short Name) + Variables )
Total Ram= 4755 Bytes

The ram size is set by user because the maximum size of cluster is set by ram buffer data cluster

The data management library is a dynamic library ( That means this library can be open multiple times, and when you call the library in Z must be the beginning address of RAM to work with ) for this i wrote the ram size table occupied by allocation library and data management library separately

In conclusion we can work with multiple open files using a single library written in flash that can work with multiple sections of ram

Operating principle:
This block function is one example only for 512 Bytes/Cluster Fat32 formats for other cluster dimension the ram allocation is different.


Fig1


In this moment i work to create and allocation table library from static library to dynamic library

These two libraries ( allocation table and data section ) will be in 2 variants:
1) A library will have only buffer for data which can be put on the controllers with ram more than 655Bytes
2) A library that does not include buffers (will lose the stats of dynamic library) but which can be put on the controllers that have the minimum 128Bytes of ram
____________________________________________________________________

This library is concept to work with only one buffer and work fine to my MP3 players at 5Mhz with 320Kb/s melody with one artifice, and from this moment this library is open source
This library use 3016Bytes of flash and 655Bytes of ram memory
The up bloc description in Fig1 can by applied and for this library

1)Fat32_DataInit
2)Fat32_ReadByte
3)Fat32_GoToRoot
4)Fat32_GoToFile
5)Fat32_ResetDirPointer
6)Fat32_IncrementDirPointer
7)Fat32_DecrementDirPointer
8)Fat32_GetShortFileName
9)Fat32_GetLongFileName
10)Fat32_GetFileAdress
11)Fat32_ReadFileSize
12)Fat32_ReadFileAttr
13)Fat32_WritePointerInFile
14)Fat32_ReadPointerInFile
15)Fat32_OpenPointedFileFolder
16)Fat32_CloseFile

Last update 17-06-2009
Download fat32 read only library for atmega64
Download fat32 read only library for atmega8

Now this driver is included in my SDK here

For support post a comment

Facebook

Facebook Recommendations

Followers


Web Designing In Karachi



Haroof.com


Politics blogs

My Zimbio

Email Subscribe

Enter your email address:

Watch online Live TV

Popular posts from this blog

Matric General Group Result SECONDARY SCHOOL CERTIFICATE (S. S. C.) PART - II CLASS - X - 2010 (www.apnieyesp.com )

PASSED THE SECONDARY SCHOOL CERTIFICATE (S. S. C.) PART - II CLASS - X) ANNUAL EXAMINATION, 2010. ERRORS AND OMISSIONS EXCEPTED, CANDIDATES BEARING THE FOLLOWING ROLL NUMBERS ARE DECLARED TO HAVE PASSED THE SECONDARY SCHOOL CERTIFICATE (S. S. C.) PART - II CLASS - X) ANNUAL EXAMINATION, 2010. ------------------------------------------------- GENERAL GROUP (REG&PVT) --- GRADE..'A-ONE' ---- ----------------------- ( CANDIDATES SECURING TOTAL MARKS 680 AND ABOVE) MARKS SECURED BY THE CANDIDATES OUT OF TOTAL MARKS OF 850 ARE MENTIONED AGAINST EACH ROLL NUMBER IN BRACKET --------------------------------------------------- 601086 (689) XXX (XXX) XXX (XXX) XXX (XXX) XXX (XXX) XXX (XXX) 601327 (681) 363 (684) 364 (719) 407 (685) 664 (682) 788 (687) 601836 (692) 882 (683) XXX (XXX) XXX (XXX) XXX (XXX) XXX (XXX) 602315 (723) 316 (715) 320 (712) 321 (739) 325 (686) 326 (702) 602327 (683) 329 (70...

Updated: 25 best Windows 8 apps available today

CNETAnalysis: Best Windows 8 apps: 1-12 Windows 8 has many interesting new features, but the most important has to be the Store. It’s now easy to enhance your PC with a host of powerful apps – games, multimedia, tools, productivity and more – and these can then automatically be installed on all your other Windows 8 systems in a click or two. You’ll have to find them first, of course, which is something of a challenge, since the Windows Store now has thousands of apps competing for your attention. But don’t worry, we’ve been scouring the latest releases for the hidden gems, so if you’d like to save time and jump straight to the Store highlights then read on for our guide to the best Windows 8 apps currently available. Windows 8 review Windows 8 vs Windows 7: 8 ways it’s different 50 Windows 8 tips, tricks and secrets Windows 8 tablets: what you need to know Making sense of the Windows 8 versions All our ...

In Depth: Could robots be the writers of the future?

CNETAnalysis: It might be concerned with aliens, outer space and dimensional jumping for now, but ‘sci-fi’ might have to be redefined if the latest advances in automated writing continue apace. Software that can construct sentences, analyse data and even put a ‘spin’ on a news story are threatening to make the newsdesk and the author’s writing room very different places. The end for journalists? Journalism isn’t complicated. The popularity of online news stories can be tracked – and therefore the importance of news easily ranked – while almost everything is written using the inverted pyramid structure . Since automated writing software can already do most of that, are we looking at the last generation of human journalists? Narrative Science’s Quill is the leading automated writing software title. It transforms structured data into readable, plain English stories that are identical to those written by humans, ...

Labels

Show more