USB Mass Storage USB Mass Storage Architecture C Library to FAT File System Interface FAT File...

9
USB Mass Storage USB Mass Storage Architecture C Library to FAT File System Interface FAT File System USB Mass Storage Driver Recommended Readings

Transcript of USB Mass Storage USB Mass Storage Architecture C Library to FAT File System Interface FAT File...

Page 1: 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

USB Mass Storage ArchitectureC Library to FAT File System InterfaceFAT File SystemUSB Mass Storage DriverRecommended Readings

Page 2: 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 ArchitectureC Library

usb_scsi_intfpci_scsi_intf

(not implemented)pci_atapi_intf

(not implemented)usb_atapi_intf

(not implemented)

SCSI Protocol ATAPI Protocol(not implemented)

FAT32 File System

Protocol I/O (PIO) Interface

USB Storage Driver

PCI to SCSI / ATAPIDevice Driver(not implemented)

USB Host Stack

USB SCSI FlashDrive 0

SCSI / ATAPI Drives(not supported)

USB SCSI FlashDrive x

USB ATAPIFlash Drives

(not supported)

FAT32 DriverInterface Layer

Protocol Layer

usb_

ms_

prob

e()

calls

f_i

nitv

olum

e()

usb_

ms_

disc

onne

ct()

cal

ls f

_del

volu

me(

)

Page 3: USB Mass Storage  USB Mass Storage Architecture  C Library to FAT File System Interface  FAT File System  USB Mass Storage Driver  Recommended Readings.

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.

Page 4: USB Mass Storage  USB Mass Storage Architecture  C Library to FAT File System Interface  FAT File System  USB Mass Storage Driver  Recommended Readings.

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/dir1/dir2/filename”, “w+”)

• If native FS RAM volume is drive RAM0, do fopen(“RAM0/dir1/dir2/filename”, “w+)

Page 5: USB Mass Storage  USB Mass Storage Architecture  C Library to FAT File System Interface  FAT File System  USB Mass Storage Driver  Recommended Readings.

FAT File System

• Sourced from HCC-Embedded in Hungary.• Supports FAT12/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.

Page 6: USB Mass Storage  USB Mass Storage Architecture  C Library to FAT File System Interface  FAT File System  USB Mass Storage Driver  Recommended Readings.

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.

Page 7: 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 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.

Page 8: 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 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.

Page 9: USB Mass Storage  USB Mass Storage Architecture  C Library to FAT File System Interface  FAT File System  USB Mass Storage Driver  Recommended Readings.

Recommended Readings

• HCC-Embedded FAT12/16/32 manual in /netos/src/examples/nafatfs