usb to sd by: nadav haklai & noam rabinovici supervisors: mike sumszyk & roni lavi...

26
USB 2.0 to SD-Card File Transfer USB to SD By: Nadav Haklai & Noam Rabinovici Supervisors: Mike Sumszyk & Roni Lavi Semester: Spring 2010

Upload: walter-cummings

Post on 23-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: USB to SD By: Nadav Haklai & Noam Rabinovici Supervisors: Mike Sumszyk & Roni Lavi Semester:Spring 2010

USB 2.0 to SD-CardFile Transfer

USB to SD

By: Nadav Haklai & Noam RabinoviciSupervisors: Mike Sumszyk & Roni LaviSemester: Spring 2010

Page 2: USB to SD By: Nadav Haklai & Noam Rabinovici Supervisors: Mike Sumszyk & Roni Lavi Semester:Spring 2010

Project Goal

Create a prototype for file transfer system.

Implement a stand alone bridge between USB and SD-Card interfaces.

Design a platform for future file transfer developments.

Learn the USB and SD-Card protocols.

Page 3: USB to SD By: Nadav Haklai & Noam Rabinovici Supervisors: Mike Sumszyk & Roni Lavi Semester:Spring 2010

System Definition:

Copy files between USB and SD card devices.

Stand-alone device. Support FAT file systems. Easy to use user interface. Low power – self powered (battery) . Fast transfer rates - USB 2.0. Low cost product.

Page 4: USB to SD By: Nadav Haklai & Noam Rabinovici Supervisors: Mike Sumszyk & Roni Lavi Semester:Spring 2010

Prototype Constrains:

Altera DE-3 Development Board High power – Power supply. Large dimensions. Lower transfer rates – generic FPGA. Very expensive.

Short development time and resources Using open-source code (FAT). Using Altera examples as skeleton.

Page 5: USB to SD By: Nadav Haklai & Noam Rabinovici Supervisors: Mike Sumszyk & Roni Lavi Semester:Spring 2010

Prototype System Architecture:

DE3 Board

Stratix III

Nios II Soft

Processor

Avalon Switch Fabric

JTAG

ISP1761 (USB Controller)

USB 2.0 Port

PIO Controller

On Chip Memory

PIO Controller

ISP1761 Controlle

r

Console

SD Card Connecto

r

Leds and switches

Page 6: USB to SD By: Nadav Haklai & Noam Rabinovici Supervisors: Mike Sumszyk & Roni Lavi Semester:Spring 2010

Development Tools

Software: Quartus II 10.0 SOPC Builder NIOS II IDE 10.0

Hardware: Altera DE3 Board

▪ Stratix III FPGA▪ Soft NIOS II Core▪ USB Controller - ISP1761

Signal Analyzer USB Analyzer

Page 7: USB to SD By: Nadav Haklai & Noam Rabinovici Supervisors: Mike Sumszyk & Roni Lavi Semester:Spring 2010

Software Architecture:

NIOS II PIO

ISP 1761 HAL

USB HOST Controller

USB Protocol

USB mass storage device

Driver

FAT File System

Main Program – User Interface

SD-Card Driver

Control Layer

Files Layer

512 Bytes Blocks Layer

Physical Layer

Page 8: USB to SD By: Nadav Haklai & Noam Rabinovici Supervisors: Mike Sumszyk & Roni Lavi Semester:Spring 2010

Technical Background:

USB 2.0- Standard for peripheral devices The USB mass storage device class ISP1761 - single-chip Hi-Speed Universal

Serial Bus (USB) On-The-Go (OTG) Controller

SD-Card - Non-Volatile memory card format Very popular and common

(Cameras, Embedded Systems) Fat - File System

Page 9: USB to SD By: Nadav Haklai & Noam Rabinovici Supervisors: Mike Sumszyk & Roni Lavi Semester:Spring 2010

Definition: A specification to establish communication between devices and a host controller.

Main Uses Device Classes

Mass Storage Device Human Interface Device (HID)

Physical Layer Host/Device Topology

USB 2.0

Page 10: USB to SD By: Nadav Haklai & Noam Rabinovici Supervisors: Mike Sumszyk & Roni Lavi Semester:Spring 2010

USB Protocol - UFI Layer USB Floppy Interface USB method for file transfers Based on SCSI Commands Data packet encapsulation Uses USB low level driver

USB Mass Storage Class

Page 11: USB to SD By: Nadav Haklai & Noam Rabinovici Supervisors: Mike Sumszyk & Roni Lavi Semester:Spring 2010

USB UFI level Implementation main commands: Write Command:

Read Command:

USB Mass Storage Class

Page 12: USB to SD By: Nadav Haklai & Noam Rabinovici Supervisors: Mike Sumszyk & Roni Lavi Semester:Spring 2010

USB Bulk level : Command/Data/Status Flow:

Command Status/Block Wrapper Packet structure:

USB Mass Storage Class

Page 13: USB to SD By: Nadav Haklai & Noam Rabinovici Supervisors: Mike Sumszyk & Roni Lavi Semester:Spring 2010

USB Write Function Structure This function writes

512Bytes block using the USB.

USB Mass Storage Class

Request from the file system to write 512B logical

block

USBDISK_WriteBlock512

Request from the file system to write a physical block (equal or less than

512B)

USBDISK_ BOT_Write10

USBDISK_ BOT_execute

Sending the command to the device, same to read & write

Port_BulkIN

Port_BulkOut

Port_AltOutPort_AltIn

Changing datagram with the device

Page 14: USB to SD By: Nadav Haklai & Noam Rabinovici Supervisors: Mike Sumszyk & Roni Lavi Semester:Spring 2010

Technical Background:

USB 2.0- Standard for peripheral devices The USB mass storage device class ISP1761 - single-chip Hi-Speed Universal

Serial Bus (USB) On-The-Go (OTG) Controller

SD-Card - Non-Volatile memory card format Very popular and common

(Cameras, Embedded Systems) Fat - File System

Page 15: USB to SD By: Nadav Haklai & Noam Rabinovici Supervisors: Mike Sumszyk & Roni Lavi Semester:Spring 2010

SD-Card Protocol SD Mode (1 or 4bits) vs. SPI Mode Bus Protocol basic operation:

▪ Command Packet Format

▪ Data Packet Format

SD-Card

Page 16: USB to SD By: Nadav Haklai & Noam Rabinovici Supervisors: Mike Sumszyk & Roni Lavi Semester:Spring 2010

SD-Card Implementation: Initialization flow:

SD-Card

Page 17: USB to SD By: Nadav Haklai & Noam Rabinovici Supervisors: Mike Sumszyk & Roni Lavi Semester:Spring 2010

SD-Card Implementation: Write Flow:

Read Flow:

SD-Card

Page 18: USB to SD By: Nadav Haklai & Noam Rabinovici Supervisors: Mike Sumszyk & Roni Lavi Semester:Spring 2010

SD-Card Write Function Structure:

SD-Card

Request from the file system to write 512B logical block

SD_write_block

Sending the command

send_cmd

SD_CLK_HIGH

executing the command

SD_CLK_LOW SD_CMD_HIGH SD_CMD_LOW

SD_DAT0_HIGH

SD_DAT0_LOW

Page 19: USB to SD By: Nadav Haklai & Noam Rabinovici Supervisors: Mike Sumszyk & Roni Lavi Semester:Spring 2010

Technical Background:

USB 2.0- Standard for peripheral devices The USB mass storage device class ISP1761 - single-chip Hi-Speed Universal

Serial Bus (USB) On-The-Go (OTG) Controller

SD-Card - Non-Volatile memory card format Very popular and common

(Cameras, Embedded Systems) Fat - File System

Page 20: USB to SD By: Nadav Haklai & Noam Rabinovici Supervisors: Mike Sumszyk & Roni Lavi Semester:Spring 2010

A method of storing and organizing computer files and their data

FAT Fundamentals: Sectors and Clusters Volume Structure: MBR:

FAT File System

Page 21: USB to SD By: Nadav Haklai & Noam Rabinovici Supervisors: Mike Sumszyk & Roni Lavi Semester:Spring 2010

Implementation – Open Source File System Support for:

▪ SD-Card

▪ USB – Mass Storage Device

Application Interface:▪ f_mount - Register/Unregister a work area

▪ f_open - Open/Create a file

▪ f_write - Write file

▪ f_read - Read file

▪ f_opendir - Open a directory

▪ f_getfree - Get free clusters

FAT File System

Page 22: USB to SD By: Nadav Haklai & Noam Rabinovici Supervisors: Mike Sumszyk & Roni Lavi Semester:Spring 2010

Files organization on storage device Cluster Chains example

FAT File System

Page 23: USB to SD By: Nadav Haklai & Noam Rabinovici Supervisors: Mike Sumszyk & Roni Lavi Semester:Spring 2010

Technical Background:

USB 2.0- Standard for peripheral devices The USB mass storage device class ISP1761 - single-chip Hi-Speed Universal

Serial Bus (USB) On-The-Go (OTG) Controller

SD-Card - Non-Volatile memory card format Very popular and common

(Cameras, Embedded Systems) Fat - File System

Page 24: USB to SD By: Nadav Haklai & Noam Rabinovici Supervisors: Mike Sumszyk & Roni Lavi Semester:Spring 2010

SD Card: Signals Timing issues – Driver development.

USB: Software bugs in the Terasic DE-3 examples

code. FAT:

Had to search for reliable open source code. Complex integration of the FAT and the

interfaces.

Encountered Difficulties:

Page 25: USB to SD By: Nadav Haklai & Noam Rabinovici Supervisors: Mike Sumszyk & Roni Lavi Semester:Spring 2010

ASIC vs. FPGA Board Design Increase SD Card throughput Support for different memory cards USB 3.0 NTFS File system support Low power design considerations User interface Product package

From Prototype to Product:

Page 26: USB to SD By: Nadav Haklai & Noam Rabinovici Supervisors: Mike Sumszyk & Roni Lavi Semester:Spring 2010

Questions?

Thank You