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.
USB Function Module: USB Mass Storage Class Introduction Specifications This document describes how to use the SH7286 USB function module, and how to create the firmware which is compliant to the USB Mass Storage Class specification. Modules Used • Interrupt Controller (INTC) •...
This sample program uses the USB function module (USB) to execute the control IN, control OUT, bulk IN, and bulk OUT transfers. This sample program also processes USB mass storage class commands. The SH7286 USB function module includes the following features: • USB protocol processed automatically •...
Page 4
The host computer and the SH7286 CPU board are connected with USB, an SDRAM on the SH7286 CPU board is used as the RAM disk to allow the host computer to write data to the SDRAM on the SH7286 CPU board, and to read data from the SDRAM.
SH7286 Group USB Function Module: USB Mass Storage Class USB Mass Storage Class (Bulk-Only Transport) Overview This chapter describes the USB Mass Storage Class (Bulk-Only Transport). Use this guide as the reference when you develop the USB storage systems. For more information on the USB specifications, refer to (3) and (4) in 6 References.
Page 6
SH7286 Group USB Function Module: USB Mass Storage Class Bulk-Only Transport Bulk-Only Transport supports bulk transfer only; transfers data between the host computer and the function. Bulk transfer has two different transfer types depending on the direction of the data transfer. Bulk IN transfer is to transfer data from the host controller to the function, and bulk OUT transfer is to transfer data from the function to the host controller.
Page 7
SH7286 Group USB Function Module: USB Mass Storage Class • dCBWSignature: Signature that helps identify this data packet as a CBW. The signature field shall contain the value H'43425355 (little endian). • dCBWTag: A Command Block Tag sent by the host. The dCSWTag is specified by the host, and it associates a CSW with the corresponding CBW.
Page 8
SH7286 Group USB Function Module: USB Mass Storage Class 3.3.3 Data Transport Data transport defines the data transfer between the host and the function. When executing Read/Write command in data transport, the host sends the exact number of bytes of data in sectors to the function, and vice versa.
Page 9
SH7286 Group USB Function Module: USB Mass Storage Class Subclass Codes (SCSI Transparent Command Set) The function must support subclass commands in CBW which are sent from the host computer, and handle commands. This sample program supports 11 SCSI commands listed in Table 6. When the function receives commands which are not supported, it reports to the host computer "Command failed"...
(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.
Page 11
SH7286 Group USB Function Module: USB Mass Storage Class (2) USB host computer Use Windows 2000-, Windows XP-, Windows Vista-, or Mac OS9-based computer with the USB port as the USB host computer. As this system uses the USB Mass Storage Class (Bulk-Only Transport) device driver which comes standard with the operating system, user does not have to install a driver newly.
Page 12
SH7286 Group USB Function Module: USB Mass Storage Class Software Requirements Use the High-performance Embedded Workshop 4 to compile, link, and debug the sample program. Double-click "sh7286_usb_msc.hws" to activate the High-performance Embedded Workshop 4. 4.2.1 Sample Program All sample programs are stored in "sh7286_usb_msc" folder. Copy this folder to the computer where the High- performance Embedded Workshop 4 is installed to use the sample program.
Page 13
Serial Bus controllers node, and RENESAS EX RAN Disk USB Device appears under the Disk drives node. Then, the host computer recognizes the SH7286 CPU board as a storage device to mount the Local Disk drive in My Computer. Next, format the Local Disk drive on the computer.
Page 14
SH7286 Group USB Function Module: USB Mass Storage Class Changing the RAM Disk Setting This section describes how to change the RAM disk setting used in this sample program. 4.5.1 Removable Disk/Fixed Disk This sample program uses the RAM disk as a removable disk. Comment out "#define REMOVABLE_DISK" in SetSystemSwitch.h file, and enable "#undef REMOVABLE_DISK"...
This chapter describes the features and the configuration of the sample program. This sample program operates on the SH7286 CPU board, and the SH7286 CPU board operates as a RAM disk. USB transfer is started by an interrupt from the USB function module.
Page 16
The USB communication state is divided into two states according to the type of data transfer (See Figure 6). When an interrupt occurs, the SH7286 transitions to the USB communication state, and then jumps to each state according to the type of interrupts.
Page 17
CPU initialization program stacksct.h Defines the stack area vect.h Declares the interrupt program vecttbl.c Defines the interrupt handling vector table inc folder iodefine.h SH7286 register definition typedefine.h Common type definition R01AN0063EJ0100 Rev. 1.00 Page 17 of 32 Oct. 22, 2010...
Page 18
Table 9 to Table 16 list functions stored in each file and those functionalities. • main.c Upon power-on reset, resetprg.c CPU initialization program is executed to call main function in main.c. It initializes the SH7286, and clears the RAM area to use in Bulk transfer. Table 9 main.c File Name...
Page 19
During Control transfer, it decodes commands from the host controller and handles the commands according to the type. This sample program sets H'045B (Vendor: Renesas) to the vendor ID. When developing the USB module, the user must get the vendor ID at the USB Implementers Forum. As the vendor command is not used in this sample, DecVendorCommands does not perform any action.
Page 20
SH7286 Group USB Function Module: USB Mass Storage Class • DoBulk.c DoBulk.c handles Bulk transfer. The USB Mass Storage Class (Bulk-Only Transport) does not use the AcrBulkInReady. Table 14 DoBulk.c File Name Funtion Name Description DoBulk.c ActBulkOut Executes Bulk OUT transfer...
Page 21
USB Function Module: USB Mass Storage Class RAM Disk This sample program assumes the SDRAM on the SH7286 CPU board as a disk, and reports to the host computer that the SH7286 CPU board (function) is a disk. The disk (function) includes the Master boot block and Partition 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.
Page 22
SH7286 Group USB Function Module: USB Mass Storage Class Supported SCSI Commands Table 17 to Table 19 describe SCSI commands supported by this sample program. Table 17 SCSI Commands (1/3) Command Transport Description Name Name INQUIRY Decodes the command, acknowledges it is the INQUIRY command, and...
Page 23
SH7286 Group USB Function Module: USB Mass Storage Class Table 18 SCSI Commands (2/3) Command Transport Description Name Name REQUEST Decodes the command, acknowledges it is the REQUEST SENSE command, SENSE and prepares for sending the value (the last SCSI command execution result)
Page 24
SH7286 Group USB Function Module: USB Mass Storage Class Table 19 SCSI Commands (3/3) Command Transport Description Name Name READ Decodes the command, acknowledges it is the READ FORMAT CAPACITY FORMAT command, and recognizes the disk which is executed on SDRAM is CAPACITY formatted.
Page 25
SH7286 Group USB Function Module: USB Mass Storage Class Error Handling This section describes errors occur between the host computer and the function, and error handling by the function when transferring data in the USB Mass Storage Class (Bulk-Only Transport).
Page 26
SH7286 Group USB Function Module: USB Mass Storage Class Table 22 lists examples of possible errors. Table 22 Error Cases CASE Status When the host issues the READ command, the amount of data sent on the USB Data transport is 0, and the amount of data specified by the SCSI command is other than 0...
Page 27
SH7286 Group USB Function Module: USB Mass Storage Class Figure 8 to Figure 10 show flow charts of error on data transfer. Start Receive CBW Command transport CBW data is valid? Stall EP2 Number of data host expects = 0...
Page 28
SH7286 Group USB Function Module: USB Mass Storage Class Behavior in Bulk IN transfer on the Data transport Number of data host expects Number of data function intends Send data on Data transport Number of data host expects > Number of data function intends...
Page 29
SH7286 Group USB Function Module: USB Mass Storage Class Behavior in Bulk OUT transfer on the Data transport Command executed by the function matches the transfer direction on Data transport? Number of data host expects Number of data function intends...
Page 30
SH7286 Group USB Function Module: USB Mass Storage Class When transferring data in the USB Mass Storage Class (Bulk-Only Transport), a series of data transfer starts on the CBW transport, and returns a series of the transfer result (status) to the host computer on the CSW transport. To return the status on the CSW transport, create values in two fields;...
References • Software Manual (1) SH-2A, SH2A-FPU Software Manual Rev. 3.00 (The latest version of software manual can be downloaded from 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.) •...
Page 32
SH7286 Group USB Function Module: USB Mass Storage Class 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. R01AN0063EJ0100 Rev. 1.00 Page 32 of 32 Oct. 22, 2010...
Page 33
Revision Record Description Rev. Date Page Summary 1.00 Oct.22.10 — First edition issued...
Page 34
General Precautions in the Handling of MPU/MCU Products The following usage notes are applicable to all MPU/MCU products from Renesas. For detailed usage notes on the products covered by this manual, refer to the relevant sections of the manual. If the descriptions under General Precautions in the Handling of MPU/MCU Products and in the body of the manual differ from each other, the description in the body of the manual takes precedence.
Page 35
Electronics product for any application categorized as "Specific" without the prior written consent of Renesas Electronics. Further, you may not use any Renesas Electronics product for any application for which it is not intended without the prior written consent of 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"...
Need help?
Do you have a question about the SH7286 and is the answer not in the manual?
Questions and answers