Author Topic: obtaining usb hub port number  (Read 18787 times)

marting@thinklogical.com

  • Member
  • ***
  • Posts: 17
obtaining usb hub port number
« on: October 27, 2011, 01:46:01 pm »
Hi,
We make a product that is built like the following

cpu - usb hub1 - port1 - chip1 ftdi                 
                |----- port2 - chip2 ftdi
                |----- port3 - ST chip
                |----- port4 - hub2 - chipa ftdi

These chips all come up un-configured.
When I talk to this product, I need to make sure that the chip1 gets certain configuration parameters chip2 get others and chipa get still others.
I think I need to find out what port of the first hub these devices are on.
If I could gets something like the hub port number that would be great.
Can that be done?

Thanks,
Martin

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: obtaining usb hub port number
« Reply #1 on: October 27, 2011, 01:49:31 pm »
Are you developing the host firmware?

The way the host learns about attached devices is to request descriptors from each device in turn.

Perhaps I don't understand what you're asking. What hardware and OS if any does the host use?

Jan

marting@thinklogical.com

  • Member
  • ***
  • Posts: 17
Re: obtaining usb hub port number
« Reply #2 on: October 27, 2011, 02:23:22 pm »
I have an application that I wrote in VB6, according to your book (thanks).
I need to send some descriptor info to each of the ftdi chips that gets written into an eeprom.
My VB software will need to do something like enumerate a chip (I can identify via VID/PID), then find out which port of the hub the device is on.
If the device is on the hub port I expect (since this is my hardware on aPC board it cannot move), then I will send that device a certain descriptor....
The basic problem is that windows does not give me the devices in order of the hub ports.
Thanks,
Martin

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: obtaining usb hub port number
« Reply #3 on: October 27, 2011, 03:00:07 pm »
The system's host driver enumerates devices. Applications can only communicate with enumerated devices. FTDI chips should enumerate as-is with the default VID and PID.

See FTDI's D2XX Programmer's Guide for the APIs to use to get a handle and write to the EEPROM.

This might also help:

http://www.ftdichip.com/Support/SoftwareExamples/CodeExamples/VB.htm

Why do you need to know the port number?

Jan
« Last Edit: October 27, 2011, 03:05:28 pm by Jan Axelson »

marting@thinklogical.com

  • Member
  • ***
  • Posts: 17
Re: obtaining usb hub port number
« Reply #4 on: October 27, 2011, 03:07:26 pm »
Hi,
The ftdi chip does not have anything to do with the question.  I have all the ftdi drivers working.
What I need is to be able to figure out which port of the hub the ftdi chip is on.
Thanks

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: obtaining usb hub port number
« Reply #5 on: October 27, 2011, 07:00:09 pm »
Why do you need to know the port numbers? The reason for asking is that it's often difficult or impossible to match port numbers with communication handles and there may be a better approach.

Jan

Tsuneo

  • Frequent Contributor
  • ****
  • Posts: 145
Re: obtaining usb hub port number
« Reply #6 on: October 28, 2011, 05:10:48 am »
Hi Jan,
I believe he is talking about his production system, in which the chips are mounted in factory default. Of course, the chip's EEPROMs for identification may be programmed before mount, but production cost increases. So, he want to program the EEPROMs after mount.


marting@thinklogical,

You'll modify VB Example 1 on this FTDI site for EEPROM programming. This example works on FTD2XX.DLL.
http://www.ftdichip.com/Support/SoftwareExamples/CodeExamples/VB.htm

FT_GetDeviceInfoList of FTD2XX returns location ID, which includes port number. Using location ID, you'll identify each FTDI chip on your board. As hub chips don't have serial number, usually, I believe every board gives the same set of location IDs for FTDI chips.

For the FTDI chips, which come with unique serial number like FT232R, you have to assign IgnoreHWSerNum on Windows registry for this VID/PID, so that the production PC takes location ID to identify each FTDI chip, instead of serial number.

"Ignore Hardware Serial Number" on FTDI Knowledgebase
http://www.ftdichip.com/Support/Knowledgebase/index.html?ignorehardwareserialnumber.htm

Tsuneo

marting@thinklogical.com

  • Member
  • ***
  • Posts: 17
Re: obtaining usb hub port number
« Reply #7 on: October 28, 2011, 08:59:48 am »
I am using the ftdi parts to program fpga's that all need different ids and the files for the fpga's are incompatible.
In manufacturing I have to say chip1 ftdi, put and id value of 0x33 in your eeprom so that I can figure out what file you need, chip2 ftdi put in a value of 0x55......
So to be sure I am putting the proper value into each ftdi eeprom I have to know what port on the hub I am talking to because all the parts are the same and I cannot talk to one at a time to figure out where one lives and what its serial number is.

In reference to Tsuneo's response, I have looked at the location id info before and have no idea what it means.
I have the devices connected to my pc and use usb device viewer from intel to see the hub (I would like to insert the image here but it wontl et me.
When I run the ftStatus = FT_GetDeviceInfoList(info(0), NumDevices)
I get back 100 bytes per device, these are due to the ftdi structure.
typedef struct _ft_device_list_info_node { DWORD Flags; DWORD Type; DWORD ID; DWORD LocId; char SerialNumber[16]; char Description[64]; FT_HANDLE ftHandle; } FT_DEVICE_LIST_INFO_NODE;
FTDI does not explain the locid, I asked them, they were not much help.
I get back that there are 4 devices connected (these ftdi device are listed as 2 serial ports so they show up twice).

For the 4 instances I get in decimal (DWORD is 4 bytes)
inst 1 starting at byte 0 going up to byte 15 = 0 0 0 0 - 4 0 0 0 - 16 96 3 4 - 33 116 0 0
inst 2 starting at byte 0 going up to byte 15 = 0 0 0 0 - 4 0 0 0 - 16 96 3 4 - 49 116 0 0
inst 3 starting at byte 0 going up to byte 15 = 0 0 0 0 - 4 0 0 0 - 16 96 3 4 - 34 116 0 0
inst 4 starting at byte 0 going up to byte 15 = 0 0 0 0 - 4 0 0 0 - 16 96 3 4 - 50 116 0 0

I don't know what to do with the location info

marting@thinklogical.com

  • Member
  • ***
  • Posts: 17
Re: obtaining usb hub port number
« Reply #8 on: October 28, 2011, 03:20:10 pm »
Well my original question is not answered, but I just got this from FTDI based on the input from Tsuneo.

A combination of the location IDs and descriptions can help you.  If you convert the values to hex and flip the order (MSByte first), you'll see a pattern:

0       0       116     33      =       0x00    0x00    0x74    0x21
0       0       116     49      =       0x00    0x00    0x74    0x31
0       0       116     34      =       0x00    0x00    0x74    0x22
0       0       116     50      =       0x00    0x00    0x74    0x32

If you read from left-to-right now you have:
- the 7th motherboard USB root hub
        - the 4th port of the root hub
                - the 2nd port of your internal hub
                        - the 1st port of the first FT2232D
- the 7th motherboard USB root hub
        - the 4th port of the root hub
                - the 3rd port of your internal hub
                        - the 1st port of the second FT2232D
- the 7th motherboard USB root hub
        - the 4th port of the root hub
                - the 2nd port of your internal hub
                        - the 2nd port of the first FT2232D
- the 7th motherboard USB root hub
        - the 4th port of the root hub
                - the 3rd port of your internal hub
                        - the 2nd port of the second FT2232D

The ports of the FT2232D will always be the right-most digit.  Since your hub is "fixed", it will be the second digit from the right.  There could be other digits depending on if you have additional hubs in the chain.  For example if you had a 4 port hub plugged into the root hub, and your circuit was conneted to port 3 of that hub, then you'd have
0x00 0x07 0x43 0x21.

From the location information and description, you can then build a table of which port is where, then open the desired port by location.  I don't recall if you're using an EEPROM, but if you are, you can also read the chip's serial number and work that into the location/description information as well.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: obtaining usb hub port number
« Reply #9 on: October 28, 2011, 06:25:40 pm »
Thanks for posting this information!

Jan