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.

Host does not sending a device descriptor request during enumeration

Hello Friends,

I developed a USB driver. When I captured the USB traffic during enumeration i am seeing that host is not sending any device descriptor request GET_DEVICE_DESCRIPTOR_FROM_DEVICE) .

I am attaching the snapshot of the USB trace what I got.  Please help me out where could be the problem.

Regards,

Vijay

 

  • Vijay

    Whether OMAPL1x is configured in host mode or device mode?

    Regards

    Ravi B

  • Ravi,

    Happy to see a reply from you.

    I am sorry to say that I am not using OMAPL1x processsor. I am using the ARM processor and it has been configured in Peripheral mode. Certainly host is my personal computer.

    Let me know if you need any further infiormation.

    Vijay

  • Hi

    Which SOC and usb controller you are using. The host is not sending GET_DESC means, that host has not recognized your device, do you see SOF flowing on the bus.

    If you are using musb controller you should set the soft-connect bit to establish connection.

    Regards

    Ravi B

  • I did set the soft connect bit in order to establish a connection. Anyway I am pasting my routine below. have a look at it once and let me know where it went wrong.

    void main

    {

        UsbApp( );

    }

    void UsbApp(void)
    {

        /* Local Declaration. */
        T_DATATRANSFERPARAMS    data_params;

        /* Local Initialization. */
        data_params.parity_enable   = UART_PARITY_DISABLE;
        data_params.even_parity     = UART_PARITY_EVEN_NO;
        data_params.two_stop_bits   = UART_TWO_STOP_BITS_NO;
        data_params.fifo_enable     = UART_FIFO_ENABLE_YES;
        data_params.word_length     = UART_WORD_LEN_8;
        data_params.stick_parity    = UART_STICK_PARITY_NO;
        data_params.baud_rate       = M_UART_BAUD;
        data_params.uart_clk        = UART_CLK_45;

        /* Uart Initialisation. */
        UartInit(M_UART1,data_params);
        UartEnableTransmit(M_UART1);
        UartEnableReceive(M_UART1);
        UartEnable(M_UART1);

        /* Enabling USB Clock. */
        CCU_CLK_EN |= 0x40;

        UartTransmit(M_UART1,"\r\nWelcome Msg From USB\r\n", 23) ;

        UsbTest();

        UartTransmit(M_UART1,"\r\n******** END *******\r\n", 23) ;

        while(1)
        {
            ;
        }

       return;
    }

    void UsbTest(void)
    {
        T_ICDRV_INTRPT t_intrpt;
        T_UINT32       t_index = 0UL;

        /* Interrupt Type. */
        t_intrpt.t_intr_type        = ICDRV_MC_NINT;
        /* Interrupt Priority. */
        t_intrpt.t_intr_prior       = ICDRV_PRIOR_0;
        /* Interrupt Source Type. */
        t_intrpt.t_intr_src_type    = ICDRV_LEVEL;
        /* Interrupt Handler. */
        t_intrpt.t_intr_hndlr       = (T_ICDRV_PT_INTR_HNDLRS)UsbTestIsr;
        t_intrpt.t_intr_clr_func    = (T_ICDRV_PT_INTR_HNDLRS)UsbTesIntrtClr;

        INDEX = 0;         // Selecting Endpoint Point 0
        FADDR &= 0x80;        //0x60000000;8 ;Function address register(READ WRITE : D0-D6,READ ONLY       : D7).
        FlushFifo();

        INDEX = 0;         // Selecting Endpoint Point 0

       /* Initialises the corresponding Interrupts. */
        if ( ICDRV_NO_ERROR == IcDrvEnableInt(t_intrpt))
        {
            /* IntrTxE */
            INTRTxE = 1 ;//|= 0xFF;

            /* IntrRxE */
            INTRRxE |= 0xFE;

            /* IntrUsbE */
            INTRUSBE = 0xF7; //except SOF Interrupt
            /*
             * POWER
             * Clear D5,If not set, the device will only operate in Full-speed mode.
             */
            POWER &= (~M_ICDRV_MAKEMASK1(5));

            /*
             * POWER
             * Clear D6 - Soft Disconnect.
             */
            POWER &= (~M_ICDRV_MAKEMASK1(6));

            /* Delay. */
            for(t_index = 0; t_index <= 0xFF; t_index++);


            /*
             * POWER
             * Set D6 - Soft Connect.
             */
            POWER |= (M_ICDRV_MAKEMASK1(6));

            for(t_index = 0; t_index <= 0xFF; t_index++);

            /* DEVCTL */
           // *((T_UINT8 *)(M_USB_BASE + 0x60UL)) |= 0x1;

        }
        else
        {
            while(1);
        }

        /* Waiting For Reset Interrupt. */
        while(1)
        {
            ;
        }

        return;
    }

    T_UINT32 UsbTesIntrtClr(void)
    {
        t_intrusb   = INTRUSB;
        t_intrTx    = INTRTx;
        t_intrRx    = INTRRx;
    }

    T_UINT32 UsbTestIsr(void)
    {
        T_SINT32 dwIndex,dwDatum,dwCount32,ul_index;
        T_UINT8 dwCount;

        /* If we receive data in EP0. */
        if((t_intrusb) & M_ICDRV_MAKEMASK1(2) )
        {
            FlushFifo();
            StrCpy((T_SINT8*)auc_uart_str,"\r\n************************ ++++ Reset  Detected ++++ ************************\r\n") ;
            UartTransmit(M_UART1,auc_uart_str, StrLen((const T_SINT8 *)auc_uart_str)) ;
        }
        else if(t_intrTx == 0)
        {
            FlushFifo();

            sprintf(auc_uart_str,"\r\n->0x%x ",t_intrusb);
            UartTransmit(M_UART1,auc_uart_str, StrLen((const T_SINT8 *)auc_uart_str)) ;
        }
        else if( 0 == ((t_intrTx) & 0x1) )
        {
            FlushFifo();

            StrCpy((T_SINT8*)auc_uart_str,"\r\n************************Interrupt For Some Other Tx************************\r\n") ;
            UartTransmit(M_UART1,auc_uart_str,StrLen((const T_SINT8 *)auc_uart_str)) ;

            sprintf(auc_uart_str,"                    Interrupt Received as 0x%x ",t_intrTx);
            UartTransmit(M_UART1,auc_uart_str,StrLen((const T_SINT8 *)auc_uart_str)) ;

            StrCpy((T_SINT8*)auc_uart_str,"\r\n***************************************************************************\r\n") ;
            UartTransmit(M_UART1,auc_uart_str,StrLen((const T_SINT8 *)auc_uart_str)) ;
        }
        else if( 0 == (CSR0 & 0x1) )
        {
            FlushFifo();

            StrCpy((T_SINT8*)auc_uart_str,"\r\n**************************RxPktRdy Not Set In CSR0*************************\r\n") ;
            UartTransmit(M_UART1,auc_uart_str,StrLen((const T_SINT8 *)auc_uart_str)) ;

            sprintf(auc_uart_str,"                              CSR0    is 0x%x\r\n",CSR0);
            UartTransmit(M_UART1,auc_uart_str,StrLen((const T_SINT8 *)auc_uart_str)) ;
            sprintf(auc_uart_str,"                              INTRUSB is 0x%x\r\n",t_intrusb);
            UartTransmit(M_UART1,auc_uart_str,StrLen((const T_SINT8 *)auc_uart_str)) ;
            sprintf(auc_uart_str,"                              INTRTx  is 0x%x\r\n",t_intrTx);
            UartTransmit(M_UART1,auc_uart_str,StrLen((const T_SINT8 *)auc_uart_str)) ;
            sprintf(auc_uart_str,"                              INTRRx  is 0x%x\r\n",t_intrRx);
            UartTransmit(M_UART1,auc_uart_str,StrLen((const T_SINT8 *)auc_uart_str)) ;

            StrCpy((T_SINT8*)auc_uart_str,"\r\n***************************************************************************\r\n") ;
            UartTransmit(M_UART1,auc_uart_str,StrLen((const T_SINT8 *)auc_uart_str)) ;
        }
        else
        {
            INDEX = 0;

            StrCpy((T_SINT8*)auc_uart_str,"\r\n***************************************************************************\r\n") ;
            UartTransmit(M_UART1,auc_uart_str,StrLen((const T_SINT8 *)auc_uart_str)) ;

            sprintf(auc_uart_str,"\r\n                        Host Request %d \r\n",Host_req_ul_count) ;
            UartTransmit(M_UART1,auc_uart_str,StrLen((const T_SINT8 *)auc_uart_str)) ;

            StrCpy((T_SINT8*)auc_uart_str,"\r\n***************************************************************************\r\n") ;
            UartTransmit(M_UART1,auc_uart_str,StrLen((const T_SINT8 *)auc_uart_str)) ;

            if(COUNT0 == 0)
            {
                StrCpy((T_SINT8*)auc_uart_str,"\r\n****************************Interrupt With No Data*************************\r\n") ;
                UartTransmit(M_UART1,auc_uart_str,StrLen((const T_SINT8 *)auc_uart_str)) ;

                StrCpy((T_SINT8*)auc_uart_str,"\r\n****************************So We Flush FIFO here**************************\r\n") ;
                UartTransmit(M_UART1,auc_uart_str,StrLen((const T_SINT8 *)auc_uart_str)) ;

                FlushFifo();
            }
            else
            {
                Host_req_ul_count++;

                pDest = (unsigned char *)&t_usb_wwpc_device_request;
                /* Receving The Request. */
                dwCount = COUNT0;

                dwIndex = dwCount-1;

                sprintf(auc_uart_str,"\r\nCSR0 Before Reading Data              -> 0x%x",CSR0);
                UartTransmit(M_UART1,auc_uart_str,StrLen((const T_SINT8 *)auc_uart_str)) ;

                ul_index = 0;

                while(dwIndex >= 0 )
                {
                    test_buffer[dwIndex] = *((volatile unsigned char *)0x60000020);

                    pDest[ul_index] = test_buffer[dwIndex];

                    ul_index++;
                    dwIndex--;
                }

                SendDescriptor();

            }
        }
        return 0;
    }

    void SendDescriptor(void)
    {
        T_SINT32 dwIndex,dwCount;
        T_SINT32 dwDatum;
        T_SINT32 dwCount32;
        T_UINT8  *pSource;
        T_UINT8    t_ret = 0;

        /* Display Received Host Request. */
        t_ret = DisplayHostRequest(&pSource);

        dwCount = (t_usb_wwpc_device_request.uc_wLengthLow & 0xFF)
                    | ( (t_usb_wwpc_device_request.uc_wLengthHigh & 0xFF) << 8 );

        sprintf(auc_uart_str,"\r\nTotal Bytes Of Data Requested by Host -> %d",dwCount);
        UartTransmit(M_UART1,auc_uart_str,StrLen((const T_SINT8 *)auc_uart_str)) ;

        dwIndex = dwCount-1;

        sprintf(auc_uart_str,"\r\nCSR0 Before Sending Data              -> 0x%x",CSR0);
        UartTransmit(M_UART1,auc_uart_str,StrLen((const T_SINT8 *)auc_uart_str)) ;

        sprintf(auc_uart_str,"\r\n\r\nTotal Bytes Of Data We Send           -> %d\r\n\r\n",dwIndex+1);
        UartTransmit(M_UART1,auc_uart_str,StrLen((const T_SINT8 *)auc_uart_str)) ;

        StrCpy((T_SINT8*)auc_uart_str,"\r\n***************************************************************************\r\n");
        UartTransmit(M_UART1,auc_uart_str,StrLen((const T_SINT8 *)auc_uart_str)) ;

        dwDatum = 0;

        while(dwIndex >= 0 )
        {
            *((volatile unsigned char *)0x60000020) = (unsigned char)(pSource[dwDatum]);

            sprintf(auc_uart_str," 0x%02x ",(unsigned char)(pSource[dwDatum]));
            UartTransmit(M_UART1,auc_uart_str,StrLen((const T_SINT8 *)auc_uart_str)) ;

            dwDatum++;
            dwIndex--;
        }

        StrCpy((T_SINT8*)auc_uart_str,"\r\n***************************************************************************\r\n");
        UartTransmit(M_UART1,auc_uart_str, StrLen((const T_SINT8 *)auc_uart_str)) ;

        sprintf(auc_uart_str,"\r\nCSR0, Before Setting to 0x%x         -> 0x%x", M_ICDRV_MAKEMASK1(1) | M_ICDRV_MAKEMASK1(3) , CSR0 );
        UartTransmit(M_UART1,auc_uart_str, StrLen((const T_SINT8 *)auc_uart_str)) ;

        if(t_ret == 0) // If the request is not SET_ADDRESS command.
        {
            /* Setting D1 To Send Data. */
            CSR0 |= M_ICDRV_MAKEMASK1(1);
            /* Setting D3 To Send Last Data. */
            CSR0 |= M_ICDRV_MAKEMASK1(3);
        }
        else
        {
            ;
        }

        sprintf(auc_uart_str,"\r\nCSR0 After Sending                    -> 0x%x",CSR0);
        UartTransmit(M_UART1,auc_uart_str, StrLen((const T_SINT8 *)auc_uart_str)) ;
    }

     

    T_UINT8 DisplayHostRequest(T_UINT8 **ppSource)
    {
        T_UINT8 t_ret = 0;
        T_UINT8 t_dev_addr = 0;

        // DEVICE_DESCRIPTOR_REQ
        if((t_usb_wwpc_device_request.uc_bmRequestType == 0x80) && (t_usb_wwpc_device_request.uc_bRequest == 0x6) )
        {
            //Set D6 to clear D0 after reading the data.
            CSR0 |= M_ICDRV_MAKEMASK1(6);

            *ppSource = (T_UINT8 *)&t_musb_devicedescriptor;
            InitDeviceDescriptor(&t_musb_devicedescriptor);
            strcpy(auc_uart_str,"\r\nDevice Descriptor Request Received\r\n");
            UartTransmit(M_UART1,auc_uart_str, StrLen((const T_SINT8 *)auc_uart_str)) ;

        }
        // DEVICE_DESCRIPTOR_REQ
        else if((t_usb_wwpc_device_request.uc_bmRequestType == 0x0) && (t_usb_wwpc_device_request.uc_bRequest == 0x5) )
        {
            //Decoding the Device Address.
            t_dev_addr = (t_usb_wwpc_device_request.uc_wValueLow & 0xFF)
                        | ( (t_usb_wwpc_device_request.uc_wValueHigh & 0xFF) << 8 );

            //Initialising with New Device Address.
            FADDR = (FADDR & 0x80) | t_dev_addr;

            //Set D6 to clear D0 after reading the data.
            CSR0 |= M_ICDRV_MAKEMASK1(6);
            /* Setting D3 (Indicating that no further data is expected for this request). */
            CSR0 |= M_ICDRV_MAKEMASK1(3);

            strcpy(auc_uart_str,"\r\nDevice Addressed as 0x%x\r\n",t_dev_addr);
            UartTransmit(M_UART1,auc_uart_str, StrLen((const T_SINT8 *)auc_uart_str)) ;

            t_ret = 1;
        }
        // We just send configuration descriptor for all unknown request-This is just for debugging-This is not the protocol.
        else
        {
            *ppSource = (T_UINT8 *)&t_musb_configurationdescriptor;
            InitConfigDescriptor(&t_musb_configurationdescriptor);
            strcpy(auc_uart_str,"\r\nReceived Request is not DEVICE DESCRIPTOR or SET ADDRESS Request.\r\n");
            UartTransmit(M_UART1,auc_uart_str, StrLen((const T_SINT8 *)auc_uart_str)) ;

            //Set D6 to clear D0 after reading the data.
            CSR0 |= M_ICDRV_MAKEMASK1(6);
        }

        /* Sending Data. */
        INDEX = 0;

        // unsigned char   uc_bmRequestType;
        sprintf(auc_uart_str,"\r\n          uc_bmRequestType            -> 0x%x",t_usb_wwpc_device_request.uc_bmRequestType);
        UartTransmit(M_UART1,auc_uart_str, StrLen((const T_SINT8 *)auc_uart_str)) ;

        // unsigned char   uc_bRequest;
        sprintf(auc_uart_str,"\r\n          uc_bRequest                 -> 0x%x",t_usb_wwpc_device_request.uc_bRequest);
        UartTransmit(M_UART1,auc_uart_str, StrLen((const T_SINT8 *)auc_uart_str)) ;

        // unsigned char   uc_wValueLow,
        //                 uc_wValueHigh;
        sprintf(auc_uart_str,"\r\n          uc_wValueLow                -> 0x%x",t_usb_wwpc_device_request.uc_wValueLow);
        UartTransmit(M_UART1,auc_uart_str, StrLen((const T_SINT8 *)auc_uart_str)) ;

        sprintf(auc_uart_str,"\r\n          uc_wValueHigh               -> 0x%x",t_usb_wwpc_device_request.uc_wValueHigh);
        UartTransmit(M_UART1,auc_uart_str, StrLen((const T_SINT8 *)auc_uart_str)) ;

        // unsigned char   uc_wIndexLow,
        //                 uc_wIndexHigh;
        sprintf(auc_uart_str,"\r\n          uc_wIndexLow                -> 0x%x",t_usb_wwpc_device_request.uc_wIndexLow);
        UartTransmit(M_UART1,auc_uart_str, StrLen((const T_SINT8 *)auc_uart_str)) ;

        sprintf(auc_uart_str,"\r\n          uc_wIndexHigh               -> 0x%x",t_usb_wwpc_device_request.uc_wIndexHigh);
        UartTransmit(M_UART1,auc_uart_str, StrLen((const T_SINT8 *)auc_uart_str)) ;

        // unsigned char   uc_wLengthLow,
        //                 uc_wLengthHigh;
        sprintf(auc_uart_str,"\r\n          uc_wLengthLow               -> 0x%x",t_usb_wwpc_device_request.uc_wLengthLow);
        UartTransmit(M_UART1,auc_uart_str, StrLen((const T_SINT8 *)auc_uart_str)) ;

        sprintf(auc_uart_str,"\r\n          uc_wLengthHigh              -> 0x%x\r\n",t_usb_wwpc_device_request.uc_wLengthHigh);
        UartTransmit(M_UART1,auc_uart_str, StrLen((const T_SINT8 *)auc_uart_str)) ;

        return t_ret;
    }

    void FlushFifo(void)
    {
        // Only If D0 and D1 Set.
        if(CSR0 & 0x3 )
        {
            //Set D8 to flush the fifos
            CSR0 |= M_ICDRV_MAKEMASK1(8);
        }
        else
        {
            ;
        }
    }

    void InitDeviceDescriptor(MUSB_DeviceDescriptor  *pt_device_desc)
    {
        pt_device_desc->bLength             = 0x12; //18;
        pt_device_desc->bDescriptorType     = 0x01;
        pt_device_desc->bcdUSB              = 0x200;
        pt_device_desc->bDeviceClass        = 0x00;
        pt_device_desc->bDeviceSubClass     = 0xFF;
        pt_device_desc->bDeviceProtocol     = 0xFF;
        pt_device_desc->bMaxPacketSize0     = 0x40; //64
        pt_device_desc->idVendor            = 0xD604;
        pt_device_desc->idProduct           = 0x3322;
        pt_device_desc->bcdDevice           = 0x0002;
        pt_device_desc->iManufacturer       = 0x00;
        pt_device_desc->iProduct            = 0x00;
        pt_device_desc->iSerialNumber       = 0x00;
        pt_device_desc->bNumConfigurations  = 0x01;
    }

     

    Please help me out by seeing the code. My gut feeling is that, we are not setting some bit at proper time (or) we are not sending the ACK packet in correct time.

    Waiting for your reply

     

    Regards,

    Vijay