This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

RL-ARM mass storage sample and CD-ROM

Hi my friends!

I've used RL-ARM mass storage code from sample codes of KEIL 4.03 on AT91SAM7S256.
when I attach it to PC , the system recognizes it as a flash disk, correctly;

now I want to change it to apear as a CD-ROM in windows.

I want to know any changes in code.

can anyone help me?

thanks for your help!

Parents
  • > first question is that in mscuser.c , we have SCSI_READ10 in definition of function MSC_BulkIn() , we must change it to 12 or not?

    READ10 or READ12?
    USB MSC compliance (*1) defines READ12 is required, and READ10 is optional for CD/DVD.
    But Major OS (Windows/Linux/MacOSX) issues READ10 first. When READ10 fails, READ12 is applied. Therefore, you may support both of them; READ12 for compliance, READ10 for performance.

    The difference of READ10 and READ12 lies in the size and location of TRANSFER LENGTH parameter.
    READ10: two bytes (byte 7, 8 - starting from 0)
    READ12: four bytes (byte 6, 7, 8, 9)
    In the KEIL MSC implementation, MSC_RWSetup() picks up TRANSFER LENGTH from the CB (Command Block)

    To support both of READ10 and READ12,
    - Don't need to touch to SCSI_READ10 label and MSC_RWSetup()
    - Add extra SCSI_READ12 label and MSC_RWSetup12(), which are copied from READ10 implementation, and modified.

    mscuser.c
    void MSC_GetCBW (void) {
       ...
       ...
          switch (CBW.CB[0]) {
            ...
            ...
            case SCSI_READ10:         // <--- don't need to touch to
              ...
              // no change
              ...
            case SCSI_READ12:         // <--- Add this label and contents
              if (MSC_RWSetup12()) {  // <--- replace to MSC_RWSetup12, the rest is same as READ10
                if ((CBW.bmFlags & 0x80) != 0) {
                  AT91C_BASE_PIOA->PIO_CODR = LED1;  /* Turn On Read LED */
                  BulkStage = MSC_BS_DATA_IN;
                  MSC_MemoryRead();
                } else {
                  USB_SetStallEP(MSC_EP_OUT);
                  CSW.bStatus = CSW_PHASE_ERROR;
                  MSC_SetCSW();
                }
              }
              break;
    

    BOOL MSC_RWSetup (void) {
      ...
      // no change
      ...
    }
    
    BOOL MSC_RWSetup12 (void) {
      ...                            // <---  copy the contents of MSC_RWSetup()
      ...
      /* Number of Blocks to transfer */
    //  n = (CBW.CB[7] <<  8) |      // <--- modify these lines
    //      (CBW.CB[8] <<  0);
    
      n =   (CBW.CB[6] << 24)
          | (CBW.CB[7] << 16)
          | (CBW.CB[8] <<  8)
          | (CBW.CB[9] <<  0);
     ...
    }
    

    (*1) USB Mass Storage Class Compliance Test Specification
    www.singlix.org/.../MSC-compliance-0_9a.pdf
    4.2 Command Set Information

    Tsuneo

Reply
  • > first question is that in mscuser.c , we have SCSI_READ10 in definition of function MSC_BulkIn() , we must change it to 12 or not?

    READ10 or READ12?
    USB MSC compliance (*1) defines READ12 is required, and READ10 is optional for CD/DVD.
    But Major OS (Windows/Linux/MacOSX) issues READ10 first. When READ10 fails, READ12 is applied. Therefore, you may support both of them; READ12 for compliance, READ10 for performance.

    The difference of READ10 and READ12 lies in the size and location of TRANSFER LENGTH parameter.
    READ10: two bytes (byte 7, 8 - starting from 0)
    READ12: four bytes (byte 6, 7, 8, 9)
    In the KEIL MSC implementation, MSC_RWSetup() picks up TRANSFER LENGTH from the CB (Command Block)

    To support both of READ10 and READ12,
    - Don't need to touch to SCSI_READ10 label and MSC_RWSetup()
    - Add extra SCSI_READ12 label and MSC_RWSetup12(), which are copied from READ10 implementation, and modified.

    mscuser.c
    void MSC_GetCBW (void) {
       ...
       ...
          switch (CBW.CB[0]) {
            ...
            ...
            case SCSI_READ10:         // <--- don't need to touch to
              ...
              // no change
              ...
            case SCSI_READ12:         // <--- Add this label and contents
              if (MSC_RWSetup12()) {  // <--- replace to MSC_RWSetup12, the rest is same as READ10
                if ((CBW.bmFlags & 0x80) != 0) {
                  AT91C_BASE_PIOA->PIO_CODR = LED1;  /* Turn On Read LED */
                  BulkStage = MSC_BS_DATA_IN;
                  MSC_MemoryRead();
                } else {
                  USB_SetStallEP(MSC_EP_OUT);
                  CSW.bStatus = CSW_PHASE_ERROR;
                  MSC_SetCSW();
                }
              }
              break;
    

    BOOL MSC_RWSetup (void) {
      ...
      // no change
      ...
    }
    
    BOOL MSC_RWSetup12 (void) {
      ...                            // <---  copy the contents of MSC_RWSetup()
      ...
      /* Number of Blocks to transfer */
    //  n = (CBW.CB[7] <<  8) |      // <--- modify these lines
    //      (CBW.CB[8] <<  0);
    
      n =   (CBW.CB[6] << 24)
          | (CBW.CB[7] << 16)
          | (CBW.CB[8] <<  8)
          | (CBW.CB[9] <<  0);
     ...
    }
    

    (*1) USB Mass Storage Class Compliance Test Specification
    www.singlix.org/.../MSC-compliance-0_9a.pdf
    4.2 Command Set Information

    Tsuneo

Children
No data