background image

 APPLICATION 

NOTE 

SH7286 Group 

R01AN0063EJ0100

Rev. 1.00

USB Function Module: USB Mass Storage Class 

Oct. 22, 2010

Summary 

This application note describes how to use the SH7286 USB function module and shows an example to create the 
firmware which is compliant to the USB mass storage class specification. 

This document and the sample program described are examples of the USB function module, and are therefore not 
guaranteed by Renesas. 

Target Device 

SH7286 MCU 

Contents 

R01AN0063EJ0100  Rev. 1.00 

 

Page 1 of 32 

Oct. 22, 2010 

 

1.

 

........................................................................................................................................ 2

 

Introduction

2.

 

....................................................................................................................................... 3

 

Applications

3.

 

.............................................................. 5

 

USB Mass Storage Class (Bulk-Only Transport) Overview

4.

 

.............................................................................................................. 10

 

Development Environment

5.

 

............................................................................................................. 15

 

Sample Program Overview

6.

 

...................................................................................................................................... 31

 

References

 

Содержание SH7286

Страница 1: ...ich is compliant to the USB mass storage class specification This document and the sample program described are examples of the USB function module and are therefore not guaranteed by Renesas Target Device SH7286 MCU Contents R01AN0063EJ0100 Rev 1 00 Page 1 of 32 Oct 22 2010 1 2 Introduction 2 3 Applications 3 5 USB Mass Storage Class Bulk Only Transport Overview 4 10 Development Environment 5 15 ...

Страница 2: ...nt Renesas Electronics High performance Embedded Workshop Ver 4 04 01 C Compiler Renesas Electronics SuperH RISC engine Family C C compiler package Ver 9 01 Release 01 Compiler Options Default setting in the High performance Embedded Workshop cpu sh2a object CONFIGDIR FILELEAF obj debug gbr auto chgincpath errorpath global_volatile 0 opt_range all infinite_loop 0 del_vacant_loop 0 struct_alloc 1 n...

Страница 3: ... Internal clock enabled only when EXTAL 12 MHz is selected Power down Mode When a USB cable is not connected less power is consumed by stopping the UDC internal clock Endpoint configuration listed in Table 1 Table 1 Endpoint Configuration Endpoint Number Name Transfer Mode Maximum Packet Size FIFO Buffer Capacity DMA DTC transfer EP0s Setup 8 bytes 8 bytes Endpoint 0 EP0i Control IN 8 bytes 8 byte...

Страница 4: ...a to the SDRAM on the SH7286 CPU board and to read data from the SDRAM The USB mass storage class Bulk only Transport device driver can be used which comes standard with the above mentioned operating system This system includes the following features 1 The sample program can be used to evaluate the SH7286 USB module 2 The sample program supports USB control transfer and bulk transfer 3 E10A USB em...

Страница 5: ...nsfer USB Mass Storage Class Control Bulk Interrupt CBI Transport uses control transfer bulk transfer and interrupt transfer CBI Transport divided into two data protocols one that uses interrupt transfer and one that does not use interrupt transfer The sample program uses USB Mass Storage Class Bulk Only Transport as its data transport protocol When the host computer uses a device to load or save ...

Страница 6: ...transports Start Bulk OUT transfer Bulk OUT transfer Bulk IN transfer Bulk IN transfer End Command Transport CBW Data Transport Status Transport CSW Figure 2 Relationship between the Transfer Type and Transport To notify the host computer to use the Bulk Only Transport protocol describe H 50 in the bInterfaceProtocol field of the Interface descriptor 3 3 1 Command Transport In command transport th...

Страница 7: ...in this sample program 3 3 2 Status Transport In status transport the function sends the status of the execution of the command block to the host computer via bulk IN transfer The status packet is defined as the Command Status Wrapper CSW Bulk Only Transport always ends with the CSW The function sends the CSW with a 13 byte packet via the Bulk IN transfer The format of the CSW is listed in Table 4...

Страница 8: ...n bmCBWFlags field of the CBW data is 1 and dCBWDataTransferLength field of the CBW data is not 0 Data transport is specified as Bulk IN transfer The function sends the amount of data expected as stated in dCBWDataTransferLength field to the host computer and sends the execution result of the SCSI commands specified in CBWCB field of the CBW data 3 4 Class specific Requests Class specific requests...

Страница 9: ...SENSE After an error occurred in the previous command block it provides the information about the error to the host H 12 INQUIRY Reports the information about the drive to the host H 1A MODE SENSE 6 Reports the state of the drive to the host H 1B START STOP UNIT Controls to attach or remove the media device H 1E PREVENT ALLOW MEDIUM REMOVAL Prevents or allows the removal of media H 23 READ FORMAT ...

Страница 10: ... the connection diagram R01AN0063EJ0100 Rev 1 00 Page 10 of 32 Oct 22 2010 USB cable Figure 3 Device Connection Diagram 1 SH7286 CPU board This system uses the E10A USB emulator To use the E10A USB emulator on the SH7286 CPU board set the DIP switches SW4 as listed in Table 7 Make sure to turn the power OFF before changing the SW4 setting Table 7 DIP Switches Setting SW4 Setting Mode 6 Description...

Страница 11: ...driver which comes standard with the operating system user does not have to install a driver newly 3 E10A USB computer Use Windows 2000 Windows XP Windows Vista or Mac OS9 based computer with the USB port as the E10A USB computer Use a USB cable to connect the E10A USB emulator and the USB connector of the E10A USB computer and use an E10A cable to connect the E10A USB emulator and the CPU board A...

Страница 12: ...e Embedded Workshop 4 is installed to use the sample program Figure 4 shows files stored in sh7286_usb_msc folder sh7286_usb_msc folder sh7286_usb_msc hws sh7286_usb_msc folder Intermediate files object files inc folder Collection of include files to share src folder main c common folder Sample programs related to set up the CPU usb folder Sample programs related to USB mass storage class Figure 4...

Страница 13: ...am on the SH7286 CPU board 4 3 2 Executing the Program Select Reset Go on the Debug menu to execute the program 4 4 How to Use the RAM Disk This section gives an example to use the RAM disk on Windows XP based computer When executing the program insert a USB series B connector to the SH7286 CPU board series A connector on the other side to the USB host computer After an enumeration using control t...

Страница 14: ...This sample program uses 16 MB SDRAM as a RAM disk Alter the SysMemMap h file to modify the amount of RAM disk First specify the total number of bytes of RAM disk 1 by DISK_ALL_BYTE Then specify the beginning and the end of the RAM disk area by RAM_DISK_S and RAM_DISK_E 2 respectively Notes 1 Specify the value bigger than 1 5 MB As the FAT information consumes the RAM disk area the actual amount o...

Страница 15: ... USB communication completed Interrupt generated USBFI0 Control transfer Bulk transport USB communication state Reset state Stationary state Figure 5 State Transition Diagram Reset state The SH7286 enters reset state when it is reset at power on or manually reset The sample program mainly configures the SH7286 in reset state Stationary state When configuring the SH7286 is completed the sample prog...

Страница 16: ...trol Transfer Control transfer is used to retrieve the device information and set the device state which is executed immediately after the function is connected to the host Control transfer consists of two or three stages Setup stage Data stage and Status stage 5 2 2 Bulk Transfer Bulk transfer is used to transfer large amount of data untimely but without any error Transfer speed is not guaranteed...

Страница 17: ...and c Parses and processes SCSI commands CatBOTTypedef h Bulk Only Transport structure definition CatProType h Prototype declaration CatSCSITypedef h SCSI structure definition macro definition to create FAT information CatTypedef h Basic structure definition used by USB firmware SetBOTInfo h Configures variables to support Bulk Only Transport SetMacro h Macro definition SetSCSIInfo h Configures va...

Страница 18: ... to the interrupt GetPacket Writes data to RAM transferred from the host controller GetPacket4 Writes data transferred from the host controller to RAM in longwords Ring buffer supported not used in the USB Mass Storage Class GetPacket4S Writes data transferred from the host controller to RAM in longwords Ring buffer not supported high speed PutPacket Writes data to USB module transferred to the ho...

Страница 19: ...Only Transport Get Max LUN command returns the maximum number of logical units supported by peripherals As the number of logical units in this sample program is 1 it returns 0 to the host Table 12 DoRequestBOT_StorageClass c File Name Function Name Description DoRequestBOT_ StorageClass c DecBOTClassCommands Handles the USB Mass Storage Class Bulk Only Transport DoControl c When the SETUP TS inter...

Страница 20: ...ification Table 15 DoBOTMSClass c File Name Function Name Description ActBulkOnly Detects the current state and divides into stages ActBulkOnlyCommand Controls CBW in the Bulk Only Transport ActBulkOnlyIn Controls Data transport and Status transport in Bulk Only Transport Data Stage direction IN DoBOTMSClass c ActBulkOnlyOut Controls Data transport and Status transport in Bulk Only Transport Data ...

Страница 21: ...on boot block as shown in Figure 7 When turning ON the system write the Master boot block and Partition boot block in the RAM disk area on the SDRAM using the initialization routine Master boot block Partition boot block Sector 0 Sector 20 Figure 7 Disk Structure Use the SCSI commands to access from the host computer to the function store data read data User must understand the structure shown in ...

Страница 22: ...the host computer When the media cannot be accessed it returns Command failed CSW status H 01 CBW Decodes the command acknowledges it is READ 10 command and prepares for sending the specified number of bytes of data from the read sector in a disk which is executed on SDRAM When the media cannot be accessed LSB of unit_state 0 is 1 the function handles the transfer as with no data and handles it ac...

Страница 23: ...s Failed and the sense key of the REQUEST SENSE to NOT READY Data This command does not include the Data transport TEST UNIT READY CSW Sends Command passed to the host computer When the media cannot be accessed it returns Command failed CSW status H 01 CBW Decodes the command acknowledges it is the VERIFY 10 command and prepares for sending Command passed to the host computer When the media cannot...

Страница 24: ...Y Data Sends the READ FORMAT CAPACITY information to the host computer When the media cannot be accessed it returns the same number of bytes of data H 00 requested from the host READ FORMAT CAPACITY CSW Sends the command execution result to the host computer When the media cannot be accessed it returns Command failed CSW status H 01 CBW Decodes the command When the command is not supported it sets...

Страница 25: ...ata transfer and function intends to transfer no data 2 Host expects no data transfer and function intends to send data to the host 3 Host expects no data transfer and function intends to receive data from the host 4 Host expects to receive data from the function and function intends to transfer no data 5 The amount of data received from the function that the host expected is less than the amount ...

Страница 26: ...ent on the USB Data transport is other than 0 and the amount of data specified by the SCSI command is 0 10 When the host issues the READ command it also sends data on the USB Data transport 11 When the host issues the WRITE command the amount of data specified by the SCSI command is less than the data sent on the USB Data transport 13 When the host issues the WRITE command the amount of data speci...

Страница 27: ...ction intends 0 CBW data is valid Receive CBW Detect the direction of Data transport by the CBW Set H 02 to the bCSWStatus Stall EP2 Bulk IN transfer on Data transport Bulk OUT transfer on Data transport Receive CSW End Command transport Data transport Status transport Figure 8 Flow Chart for Error Handling on Data Transfer 1 3 R01AN0063EJ0100 Rev 1 00 Page 27 of 32 Oct 22 2010 ...

Страница 28: ...host expects Number of data function intends Number of data host expects Number of data function intends Add 0 to reach the number of data host expects Set the number of data added to the dCSWDataResidue Set the number of data not transmitted to the dCSWDataResidue Set H 00 to the bCSWStatus Set H 02 to the bCSWStatus Yes No Yes No Case 6 Case 4 5 Case 7 8 Figure 9 Flow Chart for Error Handling on...

Страница 29: ...n the Data transport Set the number of data not transmitted to the dCSWDataResidue Set H 01 to the bCSWStatus Set H 02 to the bCSWStatus Yes No Yes No Case 6 Case 9 11 Case 13 Number of data host expects Number of data function intends Number of data host expects Number of data function intends Set the number of data exceeded to the dCSWDataResidue Dummy read the number of data host expects Case 1...

Страница 30: ... to Figure 10 flow charts When there is no error during the data transfer between the host and function the sample program subtracts the number of bytes to transfer from fields dCBWDataTransferLength and dCSWDataTransferResidue every time the data transfer is executed on the Data transport Otherwise the sample program sets the difference between the number of bytes of data the host expects to proc...

Страница 31: ...om the Renesas Electronics website Hardware Manual 2 SH7280 Group Hardware Manual Rev 2 00 The latest version of hardware manual can be downloaded from the Renesas Electronics website USB specifications 3 Universal Serial Bus Specification Revision 2 0 4 Universal Serial Bus Mass Storage Class Specification Overview 5 Universal Serial Bus Mass Storage Class Bulk Only Transport USB Implementers For...

Страница 32: ... Class R01AN0063EJ0100 Rev 1 00 Page 32 of 32 Oct 22 2010 Website and Support Renesas Electronics Website http www renesas com Inquiries http www renesas com inquiry All trademarks and registered trademarks are the property of their respective owners ...

Страница 33: ...A 1 Revision Record Description Rev Date Page Summary 1 00 Oct 22 10 First edition issued ...

Страница 34: ...s supplied until the reset process is completed In a similar way the states of pins in a product that is reset by an on chip power on reset function are not guaranteed from the moment when power is supplied until the power reaches the level at which resetting has been specified 3 Prohibition of Access to Reserved Addresses Access to reserved addresses is prohibited The reserved addresses are provi...

Страница 35: ...rtificial life support devices or systems surgical implantations or healthcare intervention e g excision etc and any other applications or purposes that pose a direct threat to human life 8 You should use the Renesas Electronics products described in this document within the range specified by Renesas Electronics especially with respect to the maximum rating operating supply voltage range movement...

Отзывы: