This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Multiple bulk in and out endpoints in StarterWare USB

Good afternoon,

I have been trying to get the FT4232H chip to work in my sys/bios project.

I started by integrating the usb library from starterware and getting the mouse demo working and then moved onto the FT232R and I have both of these working well.

Up until today I was making good progress getting the FT4232H going but have now come up against a wall.  The device connects fine and I am able to setup all of the baud rates etc for the 4 ports however I cannot write to the pipes for the extra three ports.  The device reports 4 interfaces and 2 endpoints on each and this is how I have modified the code that allocates the endpoint to accomodate this.

    for(InterfaceNo = 0; (InterfaceNo < pDevice->pConfigDescriptor->bNumInterfaces) && (InterfaceNo < MAX_INTERFACES); InterfaceNo++)
    {
		//
		// Get the interface descriptor.
		//
		pInterface = USBDescGetInterface(pDevice->pConfigDescriptor, InterfaceNo, 0);

		//
		// Loop through the endpoints of the device.
		//
		for(iIdx = 0; iIdx < pInterface->bNumEndpoints; iIdx++)
		{
			//
			// Get the first endpoint descriptor.
			//
			pEndpointDescriptor =
				USBDescGetInterfaceEndpoint(pInterface, iIdx,
											pDevice->ulConfigDescriptorSize);

			//
			// If no more endpoints then break out.
			//
			if(pEndpointDescriptor == 0)
			{
				//
				// should actually never happen
				//
				break;
			}

			//
			// See if this is a bulk endpoint.
			//
			if((pEndpointDescriptor->bmAttributes & USB_EP_ATTR_TYPE_M) ==
			   USB_EP_ATTR_BULK)
			{
				//
				// See if this is bulk IN or bulk OUT.
				//
				if(pEndpointDescriptor->bEndpointAddress & USB_EP_DESC_IN)
				{
					//
					// Allocate the USB Pipe for this Bulk IN endpoint.
					//
					g_USBHFTDIDevice.ulBulkInPipe[InterfaceNo] =
						USBHCDPipeAllocSize(ulIndex, USBHCD_PIPE_BULK_IN, //USBHCD_PIPE_BULK_IN_DMA,
											pDevice->ulAddress,
											pEndpointDescriptor->wMaxPacketSize,
											USBHCDInPipeCallback);
					//
					// Configure the USB pipe as a Bulk IN endpoint.
					//
					USBHCDPipeConfig(ulIndex, g_USBHFTDIDevice.ulBulkInPipe[InterfaceNo],
									 pEndpointDescriptor->wMaxPacketSize,
									 PIPE_BULK_IN_POLLING_INTERVAL,		// polling interval in frames (typically milli seconds)
									 (pEndpointDescriptor->bEndpointAddress &
									  USB_EP_DESC_NUM_M));
				}
				else
				{
					//
					// Allocate the USB Pipe for this Bulk OUT endpoint.
					//
					g_USBHFTDIDevice.ulBulkOutPipe[InterfaceNo] =
						USBHCDPipeAllocSize(ulIndex, USBHCD_PIPE_BULK_OUT, // USBHCD_PIPE_BULK_OUT_DMA,
											pDevice->ulAddress,
											pEndpointDescriptor->wMaxPacketSize,
											0);
					//
					// Configure the USB pipe as a Bulk OUT endpoint.
					//
					USBHCDPipeConfig(ulIndex, g_USBHFTDIDevice.ulBulkOutPipe[InterfaceNo],
									 pEndpointDescriptor->wMaxPacketSize,
									 pEndpointDescriptor->bInterval,
									 (pEndpointDescriptor->bEndpointAddress &
									  USB_EP_DESC_NUM_M));
				}
			}
		}
    }

This part now works and does not report any errors however when ever I try to write to a port other than the first one I get an error at the following point (around line 1112) in usbhostenum.c

            else if(ulEPStatus & USB_HOST_OUT_ERROR)
            {
                g_sUSBHCD[ulIndex].USBOUTPipes[ulPipeIdx].eState = PIPE_ERROR;
                continue;
            }

To get to this point I had to change USBIndexWrite() and USBIndexRead() in usb.c which asserted on any endpoint other than 0-3.  But I cannot see why adding the remaining endpoints would cause a problem.

However if I setup the second interface first then this works and the first doesn't.  Does anybody have any experience with anything similar?

It seems to me that there is a weakness in the Starterware USB library when you try to use more than one set of IN and OUT endpoints, any ideas of what I could try or where I should be looking for the issue?

Many thanks

Sean

  • Sean,

    We will need to look at this question more closely and get back to you. Thanks for your patience.

    Lali
  • Hello Sean,
    Starterware USB library supports all the Endpoints(15 + 1), but minimal changes are required at drivers and USB library level.
    As for my understanding of your requirement AM335x will acts as Host to your FT432H, which has 4 Bulk IN and OUT end points.

    if you look into any example code, Starterware USB uses CPPI DMA for data transfer. I have used Starterware version 02.00.00.01 for my design an year ago. you have to change the CPPI DMA Handler (cppi41dmaendstatus) for supporting multiple end points according to your design. One most important thing is change the number of scheduling table entries of CPPI DMA and add support in cppi41DMA init() API. .

    Changes in the USB Library:
    If you closely look into the FIFO Allocation, There is some mismatch. The FIFO allocation was overwriting the previous FIFO Allocated. I suggest you to understand the USB Library first completely before further proceeding. USB Mass storage Application is good to start for understanding.

    I have done this long before, so i am sharing up to my knowledge.

    Best Regards
    Rama Krishna
  • Hi Rama,

    As you should be able to see from my original post I am not using DMA.  I will look through the FIFO allocation when I am back at work on Tuesday.

    "I suggest you to understand the USB Library first completely before further proceeding. USB Mass storage Application is good to start for understanding."

    Not that it is at all relevant but I implemented a USB mass storage device a few years ago.  This kind of comment in unhelpful and patronising particularly when you know nothing about who you are directing it at.  One of the main reasons we went with this chip was to make the development faster with tools like StarterWare and sys/bios if we suspect there is an issue with the supplied drivers/libraries I do not think it is unreasonable to ask if anyone else has already solved this surely that is the point of this support forum?

    If you have any helpful suggestions or insights I would welcome them but otherwise please don't bother replying.

    Lali, I look forwards to hearing you outcomes..

    Sean

  • Hi,

    Pending some further testing i think I may have fixed it.

    I found a 4 instances in USBHCDPipeConfig() where ulIndex was being referenced when I believe it should be 0, such as:

    g_sUSBHCD[devIndex].USBOUTPipes[ulIndex].ulPipeSpeed = g_sUSBHCD[devIndex].USBDevice[ulIndex].ulDeviceSpeed;

    Where ulIndex is the end point index and USBDevice is a single element array ([1]).

    I have fixed this and now the transmit seems to be working on all four interfaces.

    Many thanks

    Sean

  • Sean,

    Thanks for the update. I had referred your questions to someone more competent in USB, hence the delayed response.

    Appreciate you posting your findings here in case someone encounters the same difficulties in the future.

    If there is anything else you can share about your application or any other improvements, please post here and I can pass it along to the development team.

    Lali