background image

Renesas USB Device 

USB Host Mass Storage Class Driver(HMSC) 

R01AN0513EJ0110  Rev.1.10 

 

Page 2 of 55 

Aug 10, 2011 

 

1. Overview 

1.1 Overview 

This document is a manual describing use of the USB host mass storage class driver (HMSC) and Sample driver with 
Renesas USB Device. 

 

1.2 

Functions and Features 

The USB host mass storage class driver comprises a USB mass storage class Bulk-Only Transport (BOT) protocol. 
When combined with a file system and storage device driver, it enables communication with a BOT-compatible USB 
storage device. 

 

1.3 Related 

Documents 

[1]  USB Revision 2.0 Specification 
[2]  USB Mass Storage Class Specification Overview Revision 1.1 
[3]  USB Mass Storage Class Bulk-Only Transport Revision 1.0 

[http://www.usb.org/developers/docs/] 

 
[4]  RX62N Group, RX621 Group User’s Manual: Hardware (Document No.R01UH0033EJ) 
[5] R8A66597 Datasheet (Document No. REJ03F0229) 
[6] Renesas USB Device USB Basic Firmware Application note (Document No.R01AN0512EJ) 
[7] RX600 Series USB Host Mass Storage Class Driver Installation Guide (Document No R01AN0523EJ) 

Renesas Electronics Website  

[http:// www.renesas.com/] 

USB Devices Page 

[http://www.renesas.com/prod/usb/] 

 
 

1.4 

Terms and Abbreviations 

USB: Universal 

Serial 

Bus 

USB-BASIC-F/W: 

USB basic firmware for Renesas USB Device 

Hardware: 

Renesas USB Device 

HEW 

 

 

      High-performance Embedded Workshop 

RX62N-RSK 

 

      Renesas Starter Kit + for RX62N 

non-OS   

 

      USB Basic firmware for OS less system 

µITRON 

 

      USB Basic firmware for µITRON system 

HCD: 

Host control driver of Renesas USB Device (USB-BASIC-F/W) 

MGR: 

Peripheral device state manager of HCD 

HUBCD: 

Sample USB hub class driver 

HMSCD: 

USB host mass storage class driver 

HMSDD: 

Sample host mass storage device driver 

HDCD: 

Host device class driver (HMSDD + HMSCD) 

MSDCD: 

Mass storage device class driver (HDCD) 

BOT: 

USB mass storage class bulk only transport 

APL: User 

application 

program 

FSL: 

FAT file system library 

TFAT: 

FAT File System Software for Microcontrollers (M3S-TFAT-Tiny-RX) 

Содержание R8A66597

Страница 1: ...have the same USB module as the RX62N Group microcontrollers When using this code in an end product or other application its operation must be tested and evaluated thoroughly Contents 1 Overview 2 2...

Страница 2: ...nesas USB Device USB Basic Firmware Application note Document No R01AN0512EJ 7 RX600 Series USB Host Mass Storage Class Driver Installation Guide Document No R01AN0523EJ Renesas Electronics Website ht...

Страница 3: ...uler Macro Macro for calling the scheduler function non OS only SW1 SW2 SW3 User switches on the RX62N RSK Caution 1 Function call capital letter command Storage device control command Caution 1 When...

Страница 4: ...D USB host mass storage class driver Its main functions are as follows 1 Activating HMSCD 2 Verifying connected devices 3 Checking drive information 4 Mounting drives 5 Accessing USB mass storage devi...

Страница 5: ...unctionality Created by the customer to match the system specifications FSL FAT file system with specifications defined by the user FSI FSL HMSDD interface functions They should be modified to match F...

Страница 6: ...bc_cstd_ MainTask usb_hmsc_ MainInit usb_hmsc_ MainLoop usb_hmsc_MainInit Initialize target system Initialize USB function Initialize scheduler function Set priority Register driver Return usb_hmsc_ M...

Страница 7: ...SB0 and USB1 include HMSC Common header file common header file for MSCFW and MSC2FW MSC2FW For USB1 Configuration is the same as MSCFW RI600_4 ITRON Folder not included in non OS version config_Hmsc...

Страница 8: ...xternal reference header file TFAT lib_src r_tfat_drv_if c TFAT interface functions Sample skip USB1 2 5 System Resources 2 5 1 System Resource Definitions when Running ITRON Version The uITRON resour...

Страница 9: ...USBC_PRI_3 3 Scheduler registration task USB_HMSCSMP_TSK usb_hmsc_SampleAplTask Storage Device Driver Task Task ID default value USBC_TID_5 Task priority USB_HSTRG_PRI default value USBC_PRI_3 USB_HM...

Страница 10: ...HCD read_sector R_usb_hmsc_ StrgReadSector R_usb_hmsc_ Read10 Read sector R_usb_hstd_ SetPipeRegistration transmission usb_hmsc_Submitutr CBW R_usb_hstd_ SetPipeRegistration recipition usb_hmsc_Submit...

Страница 11: ...nt drives Drive number All drives All units Unit count FSL FSI Drive mount R_usb_hmsc_ StrgTaskOpen R_usb_hmsc_ TaskOpen R_usb_hmsc_StorageOpen callback devconfig R_usb_hmsc_ StrgDriveSearch Initializ...

Страница 12: ...ed when HCD is changed This can use Host mass storage class driver without changing it HMSCD supports storage commands necessary for accessing USB storage devices and sample storage commands HMSCD has...

Страница 13: ...ration flag 3 6 HMSCD Functions Table 3 3 lists the functions of HMSCD Table 3 3 HMSCD Functions Function Name Description 1 usb_hmsc_SmpBotDescriptor Confirms mass storage class and BOT protocol 2 us...

Страница 14: ...ansfer Length Data length of transmit receive data uint8_t bmCBWFlags CBW Direction Data transmit receive direction uint8_t bCBWLUN Logical Unit Number Unit number uint8_t bCBWCBLength CBWCB Length Co...

Страница 15: ...status Storage command OK USBC_MSC_CSW_OK 0x00 Storage command FAIL USBC_MSC_CSW_NG 0x01 2 Phase error USBC_MSC_CSW_PHASE_ERR 0x02 Descriptor check USBC_ATAPI 0x05 USB subclass code USBC_SCSI 0x06 US...

Страница 16: ...MBR record code USBC_MBR_ADDR 0x02 EMBR record code USBC_EMBR_ADDR 0x03 4 Boot record error code USBC_BOOT_ERROR 0x05 Boot record Recorder identification signature code USBC_BOOTRECORD_SIG 0xAA55 USB...

Страница 17: ...ipeInfo uint8_t table uint16_t msgnum uint16_t speed uint16_t length uint8_t table Interface descriptor table address uint16_t msgnum Pipe information table offset uint16_t speed Communication speed A...

Страница 18: ...Notes Table 3 12 usb_hmsc_DataOut Name TRANSMIT DATA Command Execution Call format uint16_t usb_hmsc_DataOut uint16_t drvnum uint8_t buff uint32_t size uint16_t drvnum Drive number uint8_t buff Transm...

Страница 19: ...Driver number Return values void Description Updates usb_ghmsc_CbwTagNo in the global area Notes When usb_ghmsc_CbwTagNo 0 the value is incremented by 1 Table 3 16 usb_hmsc_CheckCsw Name Check CSW Ca...

Страница 20: ...eration State Call format uint16_t R_usb_ hmsc_Information uint16_t pipe_offset Arguments uint16_t pipe_offset Return values uint16_t Pipe information table Description Returns the value of the pipe i...

Страница 21: ...t16_t usb_ghmsc_OutPipe USBC_MAXSTRAGE 2 Pipe number using OUT direction endpoint 5 uint16_t usb_ghmsc_InPipe USBC_MAXSTRAGE 2 Pipe number using IN direction endpoint 6 uint8_t usb_ghmsc_Data 5120 Dat...

Страница 22: ...l back run function uint8_t errcnt Error count Error information area used by HCD uint8_t segment Segment information Continuous communication determination 4 5 HCI Function Details Table 4 4 usb_hmsc...

Страница 23: ...e CSW Call format uint16_t usb_hmsc_GetCsw uint16_t drvnum Arguments uint16_t drvnum Drive number Return values uint16_t USBC_HMSC_OK Normal end USBC_HMSC_CSW_ERR CBW transfer error USBC_HMSC_SUBMIT_E...

Страница 24: ...Notes Table 4 10 R_usb_hmsc_MassStorageReset Name MassStorageReset Request Execution Call format uint16_t R_usb_hmsc_MassStorageReset uint16_t drvnum for uITRON Arguments uint16_t drvnum Drive number...

Страница 25: ...ocessWaitTmo void Arguments uint16_t tmo Timeout duration ms Return values uint16_t Status Description Uses the TRCV_MSG system call to wait for receipt of a message Notes The message in the HMSCD are...

Страница 26: ...on in the MGR classcheck call back or call it from a function registered in the classcheck call back 3 R_usb_hmsc_TaskOpen Starts HMSCD This function is called by the R_usb_hmsc_StrgTaskOpen function...

Страница 27: ...e count and drive count and analyzes the interface descriptor table Confirms that the items listed below match HMSCD and reads the serial number if operation is possible Updates the pipe information t...

Страница 28: ...nd is executed to get error information Table 5 7 R_usb_hmsc_Write10 Name WRITE10 command executed Call format uint16_t R_usb_hmsc_Write10 uint16_t side uint8_t buff uint32_t secno uint16_t seccnt uin...

Страница 29: ...buff uint16_t side Drive number Arguments uint8_t buff Receive data area Return values uint16_t Error code Description Creates and executes the INQUIRY command Notes When a command error occurs the RE...

Страница 30: ...de Drive number Arguments uint8_t buff Transmit data area Return values uint16_t Error code Description Creates and executes the MODE_SELECT6 command Notes When a command error occurs the REQUEST_SENS...

Страница 31: ..._tfat_disk_write Writes data 5 usb_hmsc_SmpFsiSectorInitialized Initializes global variable of FSL 6 usb_hmsc_SmpFsiOffsetSectorRead Gets the offset sector 7 usb_hmsc_SmpFsiFileSystemInitialized Sets...

Страница 32: ...ulates the logical block address from the sector number It calculates the read data count from the sector count and sector size global variables Table 6 5 write_sector R_tfat_disk_write Name Write Sec...

Страница 33: ...s Table 6 7 usb_hmsc_SmpFsiOffsetSectorRead Name Read Offset Sector Call format uint32_t usb_hmsc_SmpFsiOffsetSectorRead uint16_t side Arguments uint16_t side Drive number Return values uint32_t Offse...

Страница 34: ...to one partition in case of TFAT can be connected The max unit count and max partition count can be changed in the header file A device that does not respond to the GetMaxUnit request operates as a s...

Страница 35: ...ice address 17 usb_hmsc_SmpCheckAddr Returns the device address of the drive or an error if the drive is unused 18 usb_hmsc_SmpDrive2Msgnum Changes drive number to device number 20 R_usb_hmsc_StrgTask...

Страница 36: ...l response are checked up to three times The function reads the logical block address 0x00 area of all accessible units and increments the drive count for each Notes When a GetMaxUnit request produces...

Страница 37: ...The data that is read is used to determine whether the partition type is PBR or MBR The determination covers all four partition types and the block address is set When an extended partition exists the...

Страница 38: ...r uint16_t seccnt Sector count Arguments uint32_t trans_byte Transfer data length Return values uint16_t USBC_DONE Normal end USBC_ERROR Error end Description Reads the sector information of the drive...

Страница 39: ...access to logical unit PREVENT_ALLOW Enable disable media removal READ_FORMAT_CAPACITY Get formattable capacity READ_CAPACITY Get capacity information of logical unit READ10 Read data WRITE10 Write da...

Страница 40: ...evice address Notes Table 7 20 usb_hmsc_SmpCheckAddr Name Check Drive Number Call format uint16_t usb_hmsc_SmpCheckAddr uint16_t side Arguments uint16_t side Drive number Return values uint16_t Device...

Страница 41: ...xample the drives are managed as shown below when USBC_DRIVE is set to 1 the USB storage device has three units unit 0 has three partitions total of three partitions including extensions unit 1 has no...

Страница 42: ...ple Operating Environment 8 1 2 Overview of Application Program Functions The HMSC bundles a sample application APL intended for switch operation on the board such as RX62N RSK After enumeration the p...

Страница 43: ...gistration API R_usb_hmsc_Registration function is used to register the open function For details of the HMSC registration API see table5 17 The HMSC registration API should be called in the initializ...

Страница 44: ...for mount drive USBC_HMSC_FILEWRITE 0x1002 Sequence for write once hmscdemo txt file in the MSC device USBC_HMSC_FILEREAD 0x1001 Sequence for read once hmscdemo txt file from the MSC device USBC_KEY_...

Страница 45: ...msc_MainInit Host MSC initialization function usb_hmsc_MainLoop Host MSC main loop usb_hmsc_SetTaskPri Task Priority Setting Processing Only non OS usb_hmsc_sample Application Task Processing Only uIT...

Страница 46: ...ocessing Call format usb_hmsc_MainInit Arguments void Return values void Description The initialization processing includes the following Interrupt settings DMA initialization settings USB block opera...

Страница 47: ...he a data of 512 bytes is written in hmscdemo txt file 5 hmscdemo txt file is read until the file operation switch is pushed 6 During the Read process each time the device is read 100 times LED0 3 on...

Страница 48: ...ferring to usb_shmsc_SmpAplProcess Notes Table 8 12 R_usb_hmsc_AplClear Name Application Global Variable Initialization Processing Call format R_usb_hmsc_AplClear Arguments void Return values void Des...

Страница 49: ...ce Attach detection USB Reset usbc cstd MainTask SET_CONFIGURATION usb2 hmsc MainLoop USB device Task process flag set Return usb2 hmsc MainLoop Yes No usb2 hstd HcdTask usb2 hstd MgrTask usb2 hmsc St...

Страница 50: ...add it to the project file Delete these lines GLB __RI_DEFAULT_FINTHDR_0 to GLB __RI_DEFAULT_FINTHDR_19 LWORD __RI_DEFAULT_FINTHDR_0 to LWOR __RI_DEFAULT_FINTHDR_19 9 1 1 MSC Registration In the samp...

Страница 51: ...Aug 10 2011 9 1 4 MSC Memory Pool Registration In the sample program the MSC memory pool is registered as follows memorypool name USB_HMSC_MPL wait_queue TA_TFIFO section BRI_HEAP siz_block 64 num_bl...

Страница 52: ..._TID_4 Task ID define USB_HMSC_PRI USBC_PRI_3 Priority define USB_HMSC_MBX USB2_HMSC_TSK Mailbox ID define USB_HMSC_MPL USB2_HMSC_TSK Memorypool ID Host Sample Task define USB_HSTRG_TSK USBC_TID_5 Tas...

Страница 53: ...n In the usb_hmsc_MainLoop function of r_usb_HMSC_apl c the task is called as follows void usb_hmsc_MainLoop void if R_usbc_cstd_CheckSchedule USBC_FLGSET usb_hstd_HcdTask USBC_VP_INT 0 HCD Task usb_h...

Страница 54: ...of members of different types Depending on the compiler the address alignment of the structure members may be shifted 3 When there is no response to a GetMaxUnit request for three seconds or more the...

Страница 55: ...iver R01AN0513EJ0110 Rev 1 10 Page 55 of 55 Aug 10 2011 Website and Support Renesas Electronics Website http www renesas com Inquiries http www renesas com inquiry All trademarks and registered tradem...

Страница 56: ......

Страница 57: ...010 First edition issued 1 10 Aug 10 2011 Add Target device R8A66597 2 Add 1 3 Related Documents 7 8 Add 2 4 1 Folder Structure Update 2 4 2 File Structure 9 Add 2 5 2 System Resource Definitions when...

Страница 58: ...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 sup...

Страница 59: ...artificial 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 shou...

Отзывы: