打印

项目紧急,请教香主以及各位高手关于U盘模拟CDROM问题!

[复制链接]
2496|5
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
本帖最后由 abin_gha 于 2010-11-1 23:50 编辑

项目需要实现CDROM+HID功能,主芯片为STM32F103RC,U盘存储器使用的是TFlash卡,目前已经实现了U盘+HID功能。通过修改Scsi_data.c文件中的Standard_Inquiry_Data如下,修改完后,PC机能够看到CD-ROM,但是双击cdrom后,无法打开,弹出一个错误提示框,如附件。请大家指点,多谢啦!
uint8_t Standard_Inquiry_Data[] =
  {
#if 0
    0x00,          /* Direct Access Device */
#else
    0x05,          /* Direct Access Device  CDROM*/
#endif   
    0x80,          /* RMB = 1: Removable Medium */
    0x02,          /* Version: No conformance claim to standard */
    0x02,

    36 - 4,          /* Additional Length */
   #if 0
    0x00,          /* SCCS = 1: Storage Controller Component */
   #else
  0x01,          /* SCCS = 1: Storage Controller Component */
   #endif
    0x00,
    0x00,
    /* Vendor Identification */
    'S', 'T', 'M', ' ', ' ', ' ', ' ', ' ',
    /* Product Identification */
    'S', 'D', ' ', 'F', 'l', 'a', 's', 'h', ' ',
    'D', 'i', 's', 'k', ' ', ' ', ' ',
    /* Product Revision Level */
    '1', '.', '0', ' '
}

另外,配置描述符为:
const uint8_t MASS_ConfigDescriptor[MASS_SIZ_CONFIG_DESC] =
  {

    0x09,   /* bLength: Configuation Descriptor size */
    0x02,   /* bDescriptorType: Configuration */
    MASS_SIZ_CONFIG_DESC,

    0x00,
    0x02, //0x01,   /* bNumInterfaces: 1 interface */
    0x01,   /* bConfigurationValue: */
    /*      Configuration value */
    0x00,   /* iConfiguration: */
    /*      Index of string descriptor */
    /*      describing the configuration */
    0xC0,   /* bmAttributes: */
    /*      bus powered */
    0x32,   /* MaxPower 100 mA */

   /*09*/   

    /************** Descriptor of Custom HID interface ****************/
    0x09,         /* bLength: Interface Descriptor size */
    0x04,/* bDescriptorType: Interface descriptor type */
    0x00,        /* bInterfaceNumber: Number of Interface */
    0x00,         /* bAlternateSetting: Alternate setting */
    0x02,         //??/* bNumEndpoints */
    0x03,         /* bInterfaceClass: HID */
    0x00,         /* bInterfaceSubClass : 1=BOOT, 0=no boot */
    0x00,         /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */
    0,            /* iInterface: Index of string descriptor */
    /******************** Descriptor of Custom HID HID ********************/
    /* 18 */
    0x09,         /* bLength: HID Descriptor size */
    HID_DESCRIPTOR_TYPE, /* bDescriptorType: HID */
    0x10,         /* bcdHID: HID Class Spec release number */
    0x01,
    0x00,         /* bCountryCode: Hardware target country */
    0x01,         /* bNumDescriptors: Number of HID class descriptors to follow */
    0x22,      //report   /* bDescriptorType */
    CUSTOMHID_SIZ_REPORT_DESC,/* wItemLength: Total length of Report descriptor */
    0x00,
    /******************** Descriptor of Custom HID endpoints ******************/
    /* 27 */
    0x07,          /* bLength: Endpoint Descriptor size */
    0x05,//USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: */

    0x82,          /* bEndpointAddress: Endpoint Address (IN) */               
                   // bit 3...0 : the endpoint number
                   // bit 6...4 : reserved
                    // bit 7     : 0(OUT), 1(IN)
    0x03,          /* bmAttributes: Interrupt endpoint */
    0x40,//0x02,          /* wMaxPacketSize: 20 Bytes max */
    0x00,
    0x20,          /* bInterval: Polling Interval (21 ms) */
    /* 34 */
        
    0x07,    /* bLength: Endpoint Descriptor size */
    0x05,//USB_ENDPOINT_DESCRIPTOR_TYPE,    /* bDescriptorType: */
            /*    Endpoint descriptor type */
    0x02,    /* bEndpointAddress: */
            /*    Endpoint Address (OUT) */
    0x03,    /* bmAttributes: Interrupt endpoint */
    0x40,//0x02,    /* wMaxPacketSize: 20 Bytes max  */
    0x00,
    0x20,    /* bInterval: Polling Interval (32 ms) */
  

    /******************** Descriptor of Mass Storage interface ********************/
    /*41 */
    0x09,   /* bLength: Interface Descriptor size */
    0x04,   /* bDescriptorType: */
    /*      Interface descriptor type */
    0x01,   /* bInterfaceNumber: Number of Interface */
    0x00,   /* bAlternateSetting: Alternate setting */
    0x02,  /* bNumEndpoints*/
    0x08,   /* bInterfaceClass: MASS STORAGE Class */
    0x06,   /* bInterfaceSubClass : SCSI transparent*/
    0x50,   /* nInterfaceProtocol */
    4,    /* iInterface: */
    /* 50 */
    0x07,   /*Endpoint descriptor length = 7*/
    0x05,   /*Endpoint descriptor type */
    0x81,   /*Endpoint address (IN, address 1) */
    0x02,   /*Bulk endpoint type */
    0x40,   /*Maximum packet size (64 bytes) */
    0x00,
    0x00,   /*Polling interval in milliseconds */
    /* 57 */
    0x07,   /*Endpoint descriptor length = 7 */
    0x05,   /*Endpoint descriptor type */
    0x01,   /*Endpoint address (OUT, address 2) */
    0x02,   /*Bulk endpoint type */
    0x40,   /*Maximum packet size (64 bytes) */
    0x00,
    0x00,     /*Polling interval in milliseconds*/
    /*64*/
  };




  };

CDROM无法访问.JPG (21.07 KB )

CDROM无法访问.JPG
沙发
香水城| | 2010-11-2 08:50 | 只看该作者
我不知道具体怎么做只能给,但可以给你一点提示:CDROM的文件系统格式与U盘的格式不同。

使用特权

评论回复
板凳
IJK| | 2010-11-2 09:17 | 只看该作者
如果LZ会用BusHound,问题就容易解决:用它来抓类似的 U盘模拟CDROM,然后仿照它来做。
如果LZ有硬件的USB分析仪,当然就更好。

使用特权

评论回复
地板
abin_gha|  楼主 | 2010-11-2 12:50 | 只看该作者
3# IJK

我不会用BusHound,也没有USB分析仪,时间紧,来不及研究它了,不过还是要谢谢你

使用特权

评论回复
5
abin_gha|  楼主 | 2010-11-2 12:54 | 只看该作者
2# 香水城
谢谢香主的提示:),以前,U盘存储器使用nandflash的时候,修改Standard_Inquiry_Data,就可以实现CD-ROM功能,现在改成sd卡后,就不行了,不知道怎么搞了!

使用特权

评论回复
6
IJK| | 2010-11-2 13:38 | 只看该作者
2# 香水城
谢谢香主的提示:),以前,U盘存储器使用nandflash的时候,修改Standard_Inquiry_Data,就可以实现CD-ROM功能,现在改成sd卡后,就不行了,不知道怎么搞了! ...
abin_gha 发表于 2010-11-2 12:54


既然实现过CD-ROM功能,那应该不难,另外跟底层是sd卡、还是NAND FLASH没有多大关系

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

0

主题

3

帖子

1

粉丝