FatFs Module Application Note

Started by tha, May 05, 2022, 10:36:15 AM

Previous topic - Next topic

tha

http://elm-chan.org/fsw/ff/doc/appnote.html#port

FatFs Module Application Note

1. How to Port
2. Limits
3. Memory Usage
4. Reducing Module Size
5. Long File Name
6. Unicode API
7. exFAT Filesystem
8. 64-bit LBA
9. Re-entrancy
10. Duplicated File Access
11. Performance Effective File Access
12. Considerations on Flash Memory Media
13. Critical Section
14. Various Usable Functions for FatFs Projects
15. About FatFs License

tha

How to Port

Basic Considerations
   The FatFs module ถือเงื่อนไขต่อไปนี้ในการพอร์ต.

      •  ANSI C
         The FatFs module เป็น a middleware ที่เขียนใน ANSI C (C89). ไม่มีการพึ่งพาแพลตฟอร์ม, ตราบใดที่คอมไพเลอร์เป็นไป
         ตาม C89 หรือใหม่กว่า. เฉพาะ exFAT feature เท่านั้นที่ต้องการ C99.

      •  ขนาดของ integer types
         •  Size of char ต้องเป็น 8-bit.
         •  Size of int, ตลอดจน integer promotion, ต้องเป็น 16-bit or 32-bit.
         •  Size of short and long ต้องเป็น 16-bit and 32-bit ตามลำดับ. (ใน C89 เท่านั้น)

      •  Dependency
         •  C89: string.h.
         •  C99: string.h and stdint.h.

tha

Integer Types in FatFs API

   Integer types ที่ใช้ใน FatFs ถูกกำหนดใน ff.h ดังอธิบายข้างล่าง. มันถูกอิงตาม Win32 API (windef.h). นี้จะไม่เป็นปัญหากับ
   แพลตฟอร์มส่วนใหญ่. เมื่อมีข้อขัดแย้งกับ existing definitions เกิดขึ้น, คุณต้องแก้ไขมันด้วยความระมัดระวัง.

   BYTE
      8-bit unsigned integer ในช่วง 0 ถึง 28 - 1.

   WORD
      16-bit unsigned integer in range of 0 to 216 - 1.

   DWORD
      32-bit unsigned integer in range of 0 to 232 - 1.

   QWORD
      64-bit unsigned integer in range of 0 to 264 - 1.

   UINT
      นามแฝงของ unsigned int ที่ใช้เพื่อระบุจำนวนใดๆ.

   WCHAR
      นามแฝงขอ WORD ที่ใช้เพื่อระบุ a UTF-16 code unit.

   TCHAR
      นามแฝงขอ char, WCHAR or DWORD ที่ใช้เพื่อระบุ a character encoding unit.

   FSIZE_t
      นามแฝงขอ DWORD or QWORD ที่ใช้เพื่อแอดเดรสส์ file offset และเพื่อระบุ file size.

   LBA_t
      นามแฝงขอ DWORD or QWORD ที่ใช้เพื่อแอดเดรสส์ sectors ใน LBA และเพื่อระบุ number of sectors.


tha

System Organizations

   The dependency diagram ที่แสดงข้างล่างเป็นการกำหนดค่าแบบทั่วไป, แต่ไม่เฉพาะเจาะจง, ของ the embedded system ด้วย
   FatFs module.
   

   (a) ถ้า a working disk module สำหรับ FatFs ถูกจัดให้มี, ไม่มีสิ่งอื่นจะถูกต้องการ.
   (b) เพื่อแนบติด existing disk drivers ที่มีอินเตอร์เฟสที่ต่างกัน, บาง glue functions ถูกต้องการเพื่อแปล the interfaces ระหว่าง
        FatFs และ the driver.
   

tha

Required Functions

คุณจำเป็นต้องจัดให้มีเฉพาะ MAI functions ที่ต้องการโดย FatFs module เท่านั้นและไม่มีสิ่งอื่นอีก. ถ้า a working device control module สำหรับ the target system มีให้ใช้ประโยชน์, คุณจำเป็นต้องเขียนเฉพาะ glue functions เพื่อแนบติดมันกับ the FatFs module. ถ้าไม่, คุณจำเป็นต้องพอร์ต another device control module หรือเขียนมันตั้งแต่เริ่มต้น. ส่วนใหญ่ของ MAI functions ไม่จำเป็นเสมอไป. เช่น, the write function ไม่ถูกต้องการใน read-only configuration. ตารางต่อไปนี้แสดงซึ่งฟังชั่นใดถูกต้องการขึ้นอยู่กับ the configuration options.



FatFs ไม่สนใจเกี่ยวกับทั้งชนิดของ storage device ที่ถูกใช้เป็นอะไรหรือทั้งวิธีที่มันถูกนำไปใช้งานอย่างไร. มีความต้องการเพียงว่ามันเป็น a block device ที่อ่าน/ที่เขียนใน fixed-size blocks ที่สามารถเข้าถึงได้โดยทาง the disk I/O functions ที่กำหนดไว้ข้างบน.

tha

Limits

  •  Filesystem type: FAT, FAT32(rev0.0) and exFAT(rev1.0).
  •  Number of open files: ไม่จำกัด. (ขึ้นอยู่กับ available memory)
  •  Number of volumes: สูงถึง 10.
  •  Sector size: 512, 1024, 2048 and 4096 bytes.
  •  Minimum volume size: 128 sectors.
  •  Maximum volume size: 2^32 - 1 sectors in 32-bit LBA, แทบไม่จำกัดใน 64-bit LBA ด้วย exFAT.
  •  Maximum file size: 2^32 - 1 bytes on FAT volume, แทบไม่จำกัดในบน exFAT volume.
  •  Cluster size: สูงถึง 128 sectors บน FAT volume และสูงถึง 16 MB บน exFAT volume.

tha

Memory Usage

The memory usage ต่างกันไปขึ้นอยู่กับ the configuration options.



เหล่านี้คือ the memory usage ของ FatFs module โดยไม่มี lower layer บนบาง target systems ในเงื่อนไขต่อไปนี้. V หมายถึง
จำนวนของ mounted volumes และ F หมายถึงจำนวนของ open files. ทุกๆตัวอย่างที่นี่ถูกปรับให้เหมาะสมใน code size.


tha

Reducing Module Size

ตารางต่อไปนี้แสดงว่า API function ใดถูกลบโดย configuration options เพื่อลด the module size. เพื่อใช้ an API function, แถวของ the function ต้องเคลียร์.