USB Mass Storage USB Mass Storage Architecture C
USB Mass Storage ØUSB Mass Storage Architecture ØC Library to FAT File System Interface ØFAT File System ØUSB Mass Storage Driver ØRecommended Readings
USB Mass Storage Architecture
C Library to File System Interface • Interfaces the supported C library file I/O functions to the FAT file system and native file system. • Supported C library file I/O functions are: mkdir, rename, remove, fopen, fclose, fread, fwrite, fseek. • All FAT volumes are referenced with a single letter.
C Library to File System Interface – cont. • All native file system volumes are referenced with anything other than a single letter. • If FAT volume is drive A, do fopen(“A/dir 1/dir 2/filename”, “w+”) • If native FS RAM volume is drive RAM 0, do fopen(“RAM 0/dir 1/dir 2/filename”, “w+)
FAT File System • Sourced from HCC-Embedded in Hungary. • Supports FAT 12/16/32 depending on size of the media. • Supports long file names, multiple FAT volumes, multiple open files per volume and is thread safe. • Features a API similar to the C library file I/O functions, but with more functionality.
FAT File System – cont. • The FAT file system is limited to 8. 3 file names, 1 FAT volume and 1 open file per volume and is thread safe. • FAT file system is version 2. 62. Current versions have additional features such as thread context for current working directory (cwd) and a semaphore to synchronize access to each FAT volume.
USB Mass Storage Driver • Tested with USB 2. 0 and 1. 1 full speed Flash memory sticks. • Creates FAT volume on device insertion and removes FAT volume on device removal (just like Windows). • Uses the lowest drive letter to reference the newly created FAT volume.
USB Mass Storage Driver – cont. • Supports up to 4 devices • Driver initialization function usb_ms_init() allows specifying event notification or polling to notify user that a device was inserted and a FAT volume was created.
Recommended Readings • HCC-Embedded FAT 12/16/32 manual in /netos/src/examples/nafatfs
- Slides: 9