cwindows-7usbftdi

Wrong USB Location address of the FT4222 on my Windows7


I have a windows 7 laptop (Sony pcg 81113M) with 3 USB ports, When I connect 2 * Ft 4222HQ and I run the "Getting start code for the Ft4222" (C++ Qtcreator) I get a wrong USB location which is 0x00. The same when I connect only one in that specific 2 ports.

enter image description here

I am verifying the USB-location of connected FTDI using the software USBview.

enter image description here

I am using "connect by location" in my program and if I connect two at the same time It will conseder it as one device (cause the Location Id is the same)

The FTDI driver is the latest version and i see all the interfaces in my device manager

enter image description here

Note: the third USB port works normally and I get a correct Location Id:

enter image description here

enter image description here

The os is a win7 64bit, the FTDI code runs on the 32bit (I also get the same result with 64bit)

Do anyone has an Idea about that? is there some other test that I can do it to figure it out the problem?

Here is Getting started FTDI code:

[source] https://www.ftdichip.com/Support/SoftwareExamples/LibFT4222-v1.4.4.zip

void ListFtUsbDevices()
{
    FT_STATUS ftStatus = 0;

    DWORD numOfDevices = 0;
    ftStatus = FT_CreateDeviceInfoList(&numOfDevices);

    for(DWORD iDev=0; iDev<numOfDevices; ++iDev)
    {
        FT_DEVICE_LIST_INFO_NODE devInfo;
        memset(&devInfo, 0, sizeof(devInfo));

        ftStatus = FT_GetDeviceInfoDetail(iDev, &devInfo.Flags, &devInfo.Type, &devInfo.ID, &devInfo.LocId,
                                        devInfo.SerialNumber,
                                        devInfo.Description,
                                        &devInfo.ftHandle);

        if (FT_OK == ftStatus)
        {
            printf("Dev %d:\n", iDev);
            printf("  Flags= 0x%x, (%s)\n", devInfo.Flags, DeviceFlagToString(devInfo.Flags).c_str());
            printf("  Type= 0x%x\n",        devInfo.Type);
            printf("  ID= 0x%x\n",          devInfo.ID);
            printf("  LocId= 0x%x\n",       devInfo.LocId);
            printf("  SerialNumber= %s\n",  devInfo.SerialNumber);
            printf("  Description= %s\n",   devInfo.Description);
            printf("  ftHandle= 0x%x\n",    devInfo.ftHandle);

            const std::string desc = devInfo.Description;
            if(desc == "FT4222" || desc == "FT4222 A")
            {
                g_FT4222DevList.push_back(devInfo);
            }
        }
    }
}

Main program:

int main(int argc, char const *argv[])
{
    ListFtUsbDevices();   

    if(g_FT4222DevList.empty()) {
        printf("No FT4222 device is found!\n");
        return 0;
    }


    ftStatus = FT_OpenEx((PVOID)g_FT4222DevList[0].LocId, FT_OPEN_BY_LOCATION, &ftHandle);
    if (FT_OK != ftStatus)
    {
        printf("Open a FT4222 device failed!\n");
        return 0;
    }
    
    printf("\n\n");
    printf("Init FT4222 as SPI master\n");
    ftStatus = FT4222_SPIMaster_Init(ftHandle, SPI_IO_SINGLE, CLK_DIV_4, CLK_IDLE_LOW, CLK_LEADING, 0x01);
    if (FT_OK != ftStatus)
    {
        printf("Init FT4222 as SPI master device failed!\n");
        return 0;
    }

    printf("TODO ...\n");
    printf("\n");


    printf("UnInitialize FT4222\n");
    FT4222_UnInitialize(ftHandle);

    printf("Close FT device\n");
    FT_Close(ftHandle);
    
    return 0;
}

Solution

  • From https://ftdichip.com/wp-content/uploads/2020/08/TN_152_USB_3.0_Compatibility_Issues_Explained.pdf Section 2.1.2 Location ID Returned As 0

    LocationIDs are not strictly part of the USB spec in the format provided by FTDI. The feature was added as an additional option to back up identifying and opening ports by index, serial number or product description strings.

    When connected to a USB 2.0 port the location is provided on the basis of the USB port that the device is connected to. These values are derived from specific registry keys. As the registry tree for 3rd party USB 3.0 host drivers is different to the Microsoft generic driver the Location ID cannot be calculated.

    There is no workaround to this current issue and as such devices should be listed and opened by index, serial number or product description strings.

    So this is known behaviour. Btw Win 7 EOL date was january 2020. Changing the OS is strongly adviced.