cancel
Showing results for 
Search instead for 
Did you mean: 

USB Bulk Endpoints beyond 0x81/0x02 not working properly

ryedwards
Associate

I am currently working on a project in which my board is a lightweight version of a larger, more expensive unit.  The other unit uses code where endpoint 0x81/0x02 are used for interrupt type.  The endpoints for 0x83/0x04 are used for bulk USB.  I only need to access bulk USB.

I have built the following device descriptor for my device:

 

 

/* USB MYDEV device Configuration Descriptor */
__ALIGN_BEGIN static uint8_t USBD_MYDEV_CfgDesc[USB_MYDEV_CONFIG_DESC_SIZ] __ALIGN_END =
{
  0x09, /* bLength: Configuration Descriptor size */
  USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
  USB_MYDEV_CONFIG_DESC_SIZ,
  /* wTotalLength: Bytes returned */
  0x00,
  0x01,         /*bNumInterfaces: 1 interface*/
  0x01,         /*bConfigurationValue: Configuration value*/
  0x02,         /*iConfiguration: Index of string descriptor describing the configuration*/
  0x80,         /*bmAttributes: bus powered and Supports Remote Wakeup */
  0x32,         /*MaxPower 100 mA: this current is used for detecting Vbus*/
  /* 09 */

  
  /**********  Descriptor of MYDEV interface 0 Alternate setting 0 **************/
	/*---------------------------------------------------------------------------*/
	/* MYDEV Interface Descriptor */
	0x09,                           /* bLength */
	USB_DESC_TYPE_INTERFACE,        /* bDescriptorType */
	0x00,                           /* bInterfaceNumber */
	0x00,                           /* bAlternateSetting */
	0x02,                           /* bNumEndpoints */
	0xFF,                           /* bInterfaceClass: Vendor Specific*/
	0xFF,                           /* bInterfaceSubClass: Vendor Specific */
	0xFF,                           /* bInterfaceProtocol: Vendor Specific */
	0x00,                           /* iInterface */
	/*---------------------------------------------------------------------------*/

	/*---------------------------------------------------------------------------*/
	/* EP1 descriptor */
	0x07,                           /* bLength */
	USB_DESC_TYPE_ENDPOINT,         /* bDescriptorType */
	MYDEV_EPIN_ADDR,              /* bEndpointAddress */
	0x02,                           /* bmAttributes: bulk */
	LOBYTE(MYDEV_EPIN_SIZE),      /* wMaxPacketSize */
	HIBYTE(MYDEV_EPIN_SIZE),
	0x00,                           /* bInterval: */
	/*---------------------------------------------------------------------------*/

	/*---------------------------------------------------------------------------*/
	/* EP2 descriptor */
	0x07,                           /* bLength */
	USB_DESC_TYPE_ENDPOINT,         /* bDescriptorType */
	MYDEV_EPOUT_ADDR,             /* bEndpointAddress */
	0x02,                           /* bmAttributes: bulk */
	LOBYTE(MYDEV_EPOUT_SIZE),     /* wMaxPacketSize */
	HIBYTE(MYDEV_EPOUT_SIZE),
	0x00,                           /* bInterval: */
};

 

 

 

 

 

#define MYDEV_CMD_PACKET_SIZE           64U
#define MYDEV_EPIN_ADDR                 0x83U
#define MYDEV_EPIN_SIZE                 64U
#define MYDEV_EPOUT_ADDR                0x04U
#define MYDEV_EPOUT_SIZE                64U

#define USB_MYDEV_CONFIG_DESC_SIZ       32U

 

  HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData, 0x00, PCD_SNG_BUF, 0x18);
  HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData, 0x80, PCD_SNG_BUF, 0x58);
  HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData, 0x83, PCD_DBL_BUF, 0x009800D8);
  HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData, 0x04, PCD_DBL_BUF, 0x01180158);

When I try to write data to endpoint 0x04 (host to device) I am getting I/O errors (using libusb)

When I change the endpoints to 0x81/0x02 and modify the application to use those endpoints I am able to send and receive data.

Is there something obvious I am missing with the device descriptor or misunderstanding of how endpoints are indexed?

0 REPLIES 0