Page 1
On April 1 , 2010, NEC Electronics Corporation merged with Renesas Technology Corporation, and Renesas Electronics Corporation took over all the business of both companies. Therefore, although the old company name remains in this document, it is a valid Renesas Electronics document. We appreciate your understanding.
Page 2
Renesas Electronics. Renesas Electronics shall not be in any way liable for any damages or losses incurred by you or third parties arising from the use of any Renesas Electronics product for an application categorized as “Specific”...
USB Function Module: USB Mass Storage Class Introduction This application note describes how to use the USB function module of the SH7216 and examples of creation of firmware conforming to USB Mass Storage Class. The contents of this application note and the software are provided for describing application examples of the USB function module, but not for ensuring the contents.
USB Function Module: USB Mass Storage Class Preface Specifications This application note describes how to use the USB function module of the SH7216 and examples of creation of firmware conforming to USB Mass Storage Class. Modules Used • Interrupt controller (INTC) •...
This program performs control transfer, bulk transfer, and processing for Mass Storage Class commands that use the USB function module (USB). The features of the USB Function Module contained in the SH7216 are listed below. • Automatic processing of USB protocol •...
Page 6
By connecting the host PC and the SH7216 CPU Board through USB, the SDRAM in the SH7216 CPU Board can be accessed as a RAM disk, enabling data in the SDRAM of the SH7216 CPU Board to be stored in and loaded from the host PC.
SH7216 Group USB Function Module: USB Mass Storage Class Overview of the USB Mass Storage Class (Bulk-Only Transport) This section describes the USB Mass Storage Class (Bulk-Only Transport). We hope that it will provide a convenient reference for use when developing USB storage-related systems. For more detailed information on standards, please see (3) and (4) of the section 6 "Documents for Reference".
SH7216 Group USB Function Module: USB Mass Storage Class Bulk-Only Transport With Bulk-Only Transport, data is transferred between the host PC and a function using bulk data transport only. Bulk transport can be divided into two types, depending on the direction in which the data is sent. If data is sent from the host controller to the function, bulk-out transport is used.
SH7216 Group USB Function Module: USB Mass Storage Class The fields are explained below. • dCBWSignature: This field identifies the data packet as a CBW. The value is 43425355h (Little Endian). • dCBWTag: This is the command block tag. It is used to connect the CSW with its corresponding CBW, and is specified by the host PC.
SH7216 Group USB Function Module: USB Mass Storage Class 3.3.3 Data Transport Data transport is used to transfer data between the host PC and the function. For example, with the Read/Write command, the actual data of the various storage sectors is sent using data transport.
Page 11
SH7216 Group USB Function Module: USB Mass Storage Class Sub-Class Code (SCSI Transparent Command Set) The various commands must be processed in response to the sub-class commands in the CBW sent to the function by the host PC. In this sample program, the eleven SCSI commands shown in table 6 are supported. If a command is not supported, the CSW will be used to inform the host PC that the command failed.
(1) SH7216 CPU Board Because this system uses the on-chip ROM and SDRAM, the SH7216 CPU board must be operated in the MCU expansion mode 2 (both on-chip ROM and SDRAM enabled). Therefore, DIP switch SW1 on the SH7216 CPU board must be changed from the factory setting to the setting shown in table 7.
SH7216 Group USB Function Module: USB Mass Storage Class Software Environment Compile, link, and debug the source code with HEW4. To start HEW4, double-click "MSC.hws" in this folder. 4.2.1 Sample Program Files required for the sample program are all stored in the MSC folder. When this entire folder with its contents is moved to a PC on which HEW4 have been installed, the sample program can be used immediately.
The following describes an example in which Windows® XP is used. After the program has been run, the Series B connector of the USB cable is inserted into the SH7216 CPU Board, and the Series A connector on the opposite side is connected to the USB host PC.
Page 15
SH7216 Group USB Function Module: USB Mass Storage Class Changing RAM Disk Settings This section describes how to change the settings of the RAM disk used in this sample program. 4.5.1 Removable/Hard Disk The RAM disk is used as a removable disk in this sample program.
Overview of the Sample Program In this section, features of the sample program and its structure are explained. This sample program runs on the SH7216 CPU Board, which works as a RAM disk, and initiates USB transfers by means of interrupts from the USB function module.
SH7216 Group USB Function Module: USB Mass Storage Class USB Communication State The USB communication state can be further divided into three states according to the transfer type (see figure 6). When an interrupt occurs, first there is a transition to the USB communication state, and then there is further branching to a transfer state according to the interrupt type.
• Startup.c When a power-on reset or manual reset is carried out, the SetPowerOnSection of the Startup.c file is called. At this point, the SH7216 default settings are entered and the RAM area used for bulk transport is cleared. Table 9 Startup.c...
Page 19
During control transfer, commands sent from the host controller are decoded and processed. In this sample program, a vendor ID of H'045B (vendor: Renesas) is used. When the customer develops a product, the customer should obtain a vendor ID at the USB Implementers' Forum. Because vendor commands are not used, DecVenderCommands does not perform any action.
Page 20
SH7216 Group USB Function Module: USB Mass Storage Class • DoRequestBOT_StorageClass.c This function carries out processing according to the USB Mass Storage Class (Bulk-Only Transport) commands (Bulk-Only Mass Storage Reset and Get Max LUN). The Bulk-Only Mass Storage Reset command resets all of the interfaces used in Bulk-Only Transport.
Page 21
Processes SCSI command errors RAM Disk In the sample program provided here, the SD-RAM in the SH7216 CPU Board is selected as the disk device, and the host PC is notified that the SH7216 CPU Board (function) is the disk.
SH7216 Group USB Function Module: USB Mass Storage Class Operation of SCSI Commands That Are Supported Table 17 shows the SCSI commands that are supported by the sample program. Table 17 SCSI Command Operations Transport Command Name Name Operation Content...
SH7216 Group USB Function Module: USB Mass Storage Class Transport Command Name Name Operation Content WRITE (10) This decodes the command and recognizes it as the WRITE (10) command. It then prepares to receive the data of the specified sector volume from the specified write sector in the Disk device open on the SDRAM.
SH7216 Group USB Function Module: USB Mass Storage Class Transport Command Name Name Operation Content VERIFY (10) This decodes the command and recognizes it as the VERIFY (10) command. It then prepares to notify the host PC that the operation has been successfully completed.
Page 25
SH7216 Group USB Function Module: USB Mass Storage Class Transport Command Name Name Operation Content Commands that This decodes the command and, if it is an unsupported are not supported command, specifies INVALID FIELD IN CDB for the returned value of the REQUEST SENSE command. It then prepares to transport the data.
Page 26
SH7216 Group USB Function Module: USB Mass Storage Class Processing If an Error Occurs The errors that may occur during a USB Mass Storage Class (Bulk-Only Transport) transmission between the host PC and function, and how the function operates when an error occurs are described below.
Page 27
SH7216 Group USB Function Module: USB Mass Storage Class Table 20 shows sample error conditions that may be generated. Table 20 Sample Error Conditions Case No. Error Conditions When a READ command is issued from the host PC, the amount of data to be transported in the USB data transport is 0 while the amount of data specified by the SCSI command is a value other than 0.
Page 28
SH7216 Group USB Function Module: USB Mass Storage Class Figures 8 to 10 show the processing when a data transport error occurs. Start CBW is received Is CBW data valid? Command transport EP2 is stalled Amount of data planned by...
Page 29
SH7216 Group USB Function Module: USB Mass Storage Class Bulk-in operation in data transport Amount of data planned b host Amount of data planned by function Data us sent in data transport Amount of data planned b host > Amount of data planned by function...
Page 30
SH7216 Group USB Function Module: USB Mass Storage Class Bulk-out operation in data transport Does the command to be executed by the function match the transport direction in data transport? Amount of data planned by host Amount of data planned by function...
Page 31
SH7216 Group USB Function Module: USB Mass Storage Class When a USB Mass Storage Class (Bulk-Only Transport) transmission is carried out, transport of the CBW initiates a series of data transfers, and when the CSW is transported to the host PC, a series of data transfers is processed. This status contains two items: dCSWStatus that indicates the transport result, and dCSWDataResidue that indicates the number of error bytes.
Documents for Reference • Software Manual (1) SH-2A, SH2A-FPU Software Manual (REJ09B0051) The most up-to-date version of this document is available on the Renesas Technology Website. • Hardware Manual (2) SH7216 Group Hardware Manual (REJ09B0543) The most up-to-date version of this document is available on the Renesas Technology Website.
SH7216 Group USB Function Module: USB Mass Storage Class Website and Support Renesas Technology Website http://www.renesas.com/ Inquiries http://www.renesas.com/inquiry csc@renesas.com Revision Record Description Page Summary Rev. Date 1.00 Jul.15.09 — First edition issued 2.00 Feb.10.10 Operating frequency amended Version of integrated development environment amended Figure 4 amended 4.3 description amended...
Page 34
Please be sure to implement safety measures to guard against the possibility of physical injury, and injury or damage caused by fire in the event of the failure of a Renesas product, such as safety design for hardware and software including but not limited to redundancy, fire control and malfunction prevention, appropriate treatment for aging degradation or any other applicable measures.
Need help?
Do you have a question about the SH7216 and is the answer not in the manual?
Questions and answers