cancel
Showing results for 
Search instead for 
Did you mean: 

USB Superspeed Peripherals

yaqi_4776616
New Contributor II

Hello

I have a CX3 project and now I need to do UART debugging, but my hardware does not have the UART wired out. The alternative I found in the community is to add a CDC interface to the UVC project. I have tried to find a way to add it myself on Cypress community, but I failed, I don't know how to add it and what information I need to change in the firmware, can you tell me exactly what to change or just help me to change it to create a CDC interface? Thank you very much!The following file is a project to which I have not added the CDC interface,I would like to add CDC interface on top of that.

Best Regards

Yaqi

0 Likes
1 Solution
JayakrishnaT_76
Moderator
Moderator

Hello Yaqi,

We are glad to hear that you are able to get the debug prints now.  

Regarding the modifications,  please find the part of code that you have missed in your response below:

1. In cycx3_uvc.c file:

Please add the following lines of code after the line status = CyU3PSetEpConfig(0x81, &endPointConfig);

 

        /* Flush the Endpoint memory */
        CyU3PUsbFlushEp(0x81);

        status = CyU3PDebugInit (CY_FX_EP_DEBUG_SOCKET, 8);
        if (status != CY_U3P_SUCCESS)
        {
            CyU3PDeviceReset(CyFalse);
        	//CyFxAppErrorHandler (status);
        }

        CyU3PThreadSleep (1000);

 

2. Inside the descriptor file, you missed the interface descriptors for the CDC interface. This comes after Super Speed Endpoint Companion Descriptor in CyCx3USBSSConfigDscr and is given below:

 

    /*CDC Interface*/
    /* Interface Association Descriptor */
           0x08,                           /* Descriptor Size */
           CX3_INTRFC_ASSN_DESCR,      /* Interface Association Descr Type: 11 */
           0x02,                           /* I/f number of first CDC i/f */
           0x02,                           /* Number of CDC i/f */
           0x02,                           /*  CDC i/f class code */
           0x02,                           /*  Subclass code */
           0x01,                           /* Protocol : Not used */
           0x00,                           /* String desc index for interface */

           /* Communication Interface descriptor */
           0x09,                           /* Descriptor size */
           CY_U3P_USB_INTRFC_DESCR,        /* Interface Descriptor type */
           0x02,                           /* Interface number */
           0x00,                           /* Alternate setting number */
           0x01,                           /* Number of endpoints */
           0x02,                           /* Interface class : Communication interface */
           0x02,                           /* Interface sub class */
           0x01,                           /* Interface protocol code */
           0x00,                           /* Interface descriptor string index */

           /* CDC Class-specific Descriptors */
           /* Header functional Descriptor */
           0x05,                           /* Descriptors length(5) */
           0x24,                           /* Descriptor type : CS_Interface */
           0x00,                           /* DescriptorSubType : Header Functional Descriptor */
           0x10,0x01,                      /* bcdCDC : CDC Release Number */

           /* Abstract Control Management Functional Descriptor */
           0x04,                           /* Descriptors Length (4) */
           0x24,                           /* bDescriptorType: CS_INTERFACE */
           0x02,                           /* bDescriptorSubType: Abstract Control Model Functional Descriptor */
           0x02,                           /* bmCapabilities: Supports the request combination of Set_Line_Coding,
                                              Set_Control_Line_State, Get_Line_Coding and the notification Serial_State */

           /* Union Functional Descriptor */
           0x05,                           /* Descriptors Length (5) */
           0x24,                           /* bDescriptorType: CS_INTERFACE */
           0x06,                           /* bDescriptorSubType: Union Functional Descriptor */
           0x02,                           /* bMasterInterface */
           0x03,                           /* bSlaveInterface */

           /* Call Management Functional Descriptor */
           0x05,                           /*  Descriptors Length (5) */
           0x24,                           /*  bDescriptorType: CS_INTERFACE */
           0x01,                           /*  bDescriptorSubType: Call Management Functional Descriptor */
           0x00,                           /*  bmCapabilities: Device sends/receives call management information
                                               only over the Communication Class Interface. */
           0x03,                           /*  Interface Number of Data Class interface */

           /* Endpoint Descriptor(Interrupt) */
           0x07,                           /* Descriptor size */
           CY_U3P_USB_ENDPNT_DESCR,        /* Endpoint descriptor type */
           0x81,			                /* Endpoint address and description */
           CY_U3P_USB_EP_INTR,             /* Interrupt endpoint type */
           0x40,0x00,                      /* Max packet size = 1024 bytes */
           0x02,                           /* Servicing interval for data transfers */

           /* Super speed endpoint companion descriptor for interrupt endpoint */
           0x06,                           /* Descriptor size */
           CY_U3P_SS_EP_COMPN_DESCR,       /* SS endpoint companion descriptor type */
           0x00,                           /* Max no. of packets in a Burst : 1 */
           0x00,                           /* Mult.: Max number of packets : 1 */
           0x40,0x00,                      /* Bytes per interval : 1024 */

           /* Data Interface Descriptor */
           0x09,                           /* Descriptor size */
           CY_U3P_USB_INTRFC_DESCR,        /* Interface Descriptor type */
           0x03,                           /* Interface number */
           0x00,                           /* Alternate setting number */
           0x02,                           /* Number of endpoints */
           0x0A,                           /* Interface class: Data interface */
           0x00,                           /* Interface sub class */
           0x00,                           /* Interface protocol code */
           0x00,                           /* Interface descriptor string index */

           /* Endpoint Descriptor(BULK-PRODUCER) */
           0x07,                           /* Descriptor size */
           CY_U3P_USB_ENDPNT_DESCR,        /* Endpoint descriptor type */
           0x05,                           /* Endpoint address and description */
           CY_U3P_USB_EP_BULK,             /* BULK endpoint type */
           0x00,0x04,                      /* Max packet size = 1024 bytes */
           0x00,                           /* Servicing interval for data transfers */

           /* Super speed endpoint companion descriptor for producer ep */
           0x06,                           /* Descriptor size */
           CY_U3P_SS_EP_COMPN_DESCR,       /* SS endpoint companion descriptor type */
           0x00,                           /* Max no. of packets in a burst : 1 */
           0x00,                           /* Mult.: Max number of packets : 1 */
           0x00,0x00,                      /* Bytes per interval : 1024 */

           /* Endpoint Descriptor(BULK- CONSUMER) */
           0x07,                           /* Descriptor size */
           CY_U3P_USB_ENDPNT_DESCR,        /* Endpoint descriptor type */
           0x85,                           /* Endpoint address and description */
           CY_U3P_USB_EP_BULK,             /* BULK endpoint type */
           0x00,0x04,                      /* Max packet size = 1024 bytes */
           0x00,                           /* Servicing interval for data transfers */

           /* Super speed endpoint companion descriptor for consumer ep */
           0x06,                           /* Descriptor size */
           CY_U3P_SS_EP_COMPN_DESCR,       /* SS endpoint companion descriptor type */
           0x00,                           /* Max no. of packets in a burst : 1 */
           0x00,                           /* Mult.: Max number of packets : 1 */
           0x00,0x00,                      /* Bytes per interval : 1024 */


 

3. Also in the cycx3_uvc.h,  please add the following line of code:

#define CY_FX_EP_DEBUG_SOCKET CY_U3P_UIB_SOCKET_CONS_5 

Best Regards,
Jayakrishna

View solution in original post

0 Likes
14 Replies
JayakrishnaT_76
Moderator
Moderator

Hello,

Please refer to the following thread which has interactions that mentions how to add CDC interface to obtain debug prints for a CX3 device:

https://community.cypress.com/t5/USB-Superspeed-Peripherals/Stream-RAW10-with-24bit-output-format/m-...

The response posted on Jul 20, 2020 11:14 PM provides the instructions. There is a sample project attached in the same thread which was developed by modifying the SDK example CX3UvcOV5640 by following the same instructions. This project is added along with the interaction on  ‎Jul 21, 2020 01:05 AM. 

Please have a look at this and let me know if you face any issues.

Best Regards,
Jayakrishna
0 Likes
yaqi_4776616
New Contributor II

Hi

I have looked at this project and I know the exact steps to add the CDC interface to UVC are as follows:

yaqi_4776616_0-1620283828002.png

I referred back to the modified CX3UvcOV5640 example project and found that only this part of the descriptor had modified parameters.

yaqi_4776616_1-1620284271777.png

But how should I change the descriptors in my project?

yaqi_4776616_2-1620284452588.png

This is the problem that I am facing now.

Best Regards,

Yaqi

0 Likes
JayakrishnaT_76
Moderator
Moderator

Hello Yaqi,

As per my understanding, in the default project, the descriptors are written to enumerate the device as a UVC device (2 interfaces). But, in order to enumerate the device with UVC and CDC interfaces, the descriptors need to be modified. You can refer to the project shared in the thread and edit the configuration descriptor structure  in your project. Please let me know if you have any queries in this. 

Best Regards,
Jayakrishna
0 Likes
yaqi_4776616
New Contributor II

Hi Jayakrishna

I really don't know how to modify the corresponding descriptor part in order to add the CDC interface.

First of all, the descriptors in this section are the descriptors from the OV5640 sample project that I imported directly:

yaqi_4776616_0-1620291564732.png

Here are the descriptors modified in the thread:

yaqi_4776616_1-1620291624440.png

And the descriptors in the project I created myself look like this

yaqi_4776616_2-1620291690712.png

I am really clueless as to how to modify it. Please help me.

Best Regards,

Yaqi

0 Likes
JayakrishnaT_76
Moderator
Moderator

Hello Yaqi,

Please replace the descriptor file used in your project with the descriptor file attached along with this response. After this, build and program the firmware to the CX3 device and let me know if you are able to see a COM port enumerated on the host.

Best Regards,
Jayakrishna
0 Likes
yaqi_4776616
New Contributor II

Hi Jayakrishna,

I have replaced the descriptor file and I was able to see the COM ports enumerated on the host in a flash. Maybe there is something wrong with my cycx3_uvc.c file modification that is causing the camera to not enumerate properly either.

I am following the steps below, and the OV5640 example project to make the changes

yaqi_4776616_0-1620302688799.png

Only step 4 I can't modify,I will upload my project, please help me to see, thank you.

Best Regards,

Yaqi

0 Likes
JayakrishnaT_76
Moderator
Moderator

Hello Yaqi,

Please find the attached project which has all the modifications to obtain the debug prints using CDC interface. I have tested this project using Denebola kit and was able to get the prints using the CDC interface. Please test this at your end. Please note that I have commented out the function CyCx3UvcAppImageSensorSetVideoResolution () called inside the function CyCx3UvcAppHandleSetCurReq () for testing.

Best Regards,
Jayakrishna
0 Likes
yaqi_4776616
New Contributor II

Hi Jayakrishna,

My problem has not been solved yet.

I pasted your sample project file directly into my project and when I downloaded the release version of the .img file to my hardware, serial COM5 appeared on the PC, but my camera would fail to drive and COM5 disappeared at the same time.

What's going on here?

Best Regards,

Yaqi

0 Likes
JayakrishnaT_76
Moderator
Moderator

Hello,

Please follow the steps given below:

1. Import the project that I shared directly into EZ USB Suite.

2. Clean the project once.

3. Build the project again.

4. Check the Date and Time modified of the .img file when downloading the firmware into the device. This is to ensure that the latest build is downloaded into the device and not an older version.

I have performed the above steps at my end on Denebola kit and found that it is working properly. Please find a snapshot of the tera term Application showing some debug logs that were captured by running your firmware below:

JayakrishnaT_76_0-1620702490363.png

Also, I have tested both debug and release builds and found that both of them worked properly at my end. Please try the steps that I mentioned in this response and let me know if it helps.

Best Regards,
Jayakrishna
0 Likes
yaqi_4776616
New Contributor II

Hi Jayakrishna,

I tried your method although the serial port appears, but still the driver camera fails.Can you re-modify it for me in my uploaded project, my new project has only modified the sensor.c file

0 Likes
JayakrishnaT_76
Moderator
Moderator

Hello,

Please find the attached project. I tested the same on denebola kit and found that it is working. Please refer to the snapshot attached below:

JayakrishnaT_76_0-1620705288536.png

Best Regards,
Jayakrishna
0 Likes
yaqi_4776616
New Contributor II

 

Hi Jayakrishna

Thank you very much, I finally got the print results

yaqi_4776616_3-1620722319017.png

Although it worked this time, I'd like to know what changes you made to my file because I have to create another project. I compared the sample project you posted before and I found that only these three changes were made, right?

1、cycx3_uvc.c 

CyCx3UvcAppInit ()

yaqi_4776616_0-1620718717842.png

2、CyCx3UvcAppDebugInit ()

yaqi_4776616_1-1620718812212.png

3、cycx3_uvcdscr.c

yaqi_4776616_2-1620719239869.png

Best Regards,

Yaqi

0 Likes
JayakrishnaT_76
Moderator
Moderator

Hello Yaqi,

We are glad to hear that you are able to get the debug prints now.  

Regarding the modifications,  please find the part of code that you have missed in your response below:

1. In cycx3_uvc.c file:

Please add the following lines of code after the line status = CyU3PSetEpConfig(0x81, &endPointConfig);

 

        /* Flush the Endpoint memory */
        CyU3PUsbFlushEp(0x81);

        status = CyU3PDebugInit (CY_FX_EP_DEBUG_SOCKET, 8);
        if (status != CY_U3P_SUCCESS)
        {
            CyU3PDeviceReset(CyFalse);
        	//CyFxAppErrorHandler (status);
        }

        CyU3PThreadSleep (1000);

 

2. Inside the descriptor file, you missed the interface descriptors for the CDC interface. This comes after Super Speed Endpoint Companion Descriptor in CyCx3USBSSConfigDscr and is given below:

 

    /*CDC Interface*/
    /* Interface Association Descriptor */
           0x08,                           /* Descriptor Size */
           CX3_INTRFC_ASSN_DESCR,      /* Interface Association Descr Type: 11 */
           0x02,                           /* I/f number of first CDC i/f */
           0x02,                           /* Number of CDC i/f */
           0x02,                           /*  CDC i/f class code */
           0x02,                           /*  Subclass code */
           0x01,                           /* Protocol : Not used */
           0x00,                           /* String desc index for interface */

           /* Communication Interface descriptor */
           0x09,                           /* Descriptor size */
           CY_U3P_USB_INTRFC_DESCR,        /* Interface Descriptor type */
           0x02,                           /* Interface number */
           0x00,                           /* Alternate setting number */
           0x01,                           /* Number of endpoints */
           0x02,                           /* Interface class : Communication interface */
           0x02,                           /* Interface sub class */
           0x01,                           /* Interface protocol code */
           0x00,                           /* Interface descriptor string index */

           /* CDC Class-specific Descriptors */
           /* Header functional Descriptor */
           0x05,                           /* Descriptors length(5) */
           0x24,                           /* Descriptor type : CS_Interface */
           0x00,                           /* DescriptorSubType : Header Functional Descriptor */
           0x10,0x01,                      /* bcdCDC : CDC Release Number */

           /* Abstract Control Management Functional Descriptor */
           0x04,                           /* Descriptors Length (4) */
           0x24,                           /* bDescriptorType: CS_INTERFACE */
           0x02,                           /* bDescriptorSubType: Abstract Control Model Functional Descriptor */
           0x02,                           /* bmCapabilities: Supports the request combination of Set_Line_Coding,
                                              Set_Control_Line_State, Get_Line_Coding and the notification Serial_State */

           /* Union Functional Descriptor */
           0x05,                           /* Descriptors Length (5) */
           0x24,                           /* bDescriptorType: CS_INTERFACE */
           0x06,                           /* bDescriptorSubType: Union Functional Descriptor */
           0x02,                           /* bMasterInterface */
           0x03,                           /* bSlaveInterface */

           /* Call Management Functional Descriptor */
           0x05,                           /*  Descriptors Length (5) */
           0x24,                           /*  bDescriptorType: CS_INTERFACE */
           0x01,                           /*  bDescriptorSubType: Call Management Functional Descriptor */
           0x00,                           /*  bmCapabilities: Device sends/receives call management information
                                               only over the Communication Class Interface. */
           0x03,                           /*  Interface Number of Data Class interface */

           /* Endpoint Descriptor(Interrupt) */
           0x07,                           /* Descriptor size */
           CY_U3P_USB_ENDPNT_DESCR,        /* Endpoint descriptor type */
           0x81,			                /* Endpoint address and description */
           CY_U3P_USB_EP_INTR,             /* Interrupt endpoint type */
           0x40,0x00,                      /* Max packet size = 1024 bytes */
           0x02,                           /* Servicing interval for data transfers */

           /* Super speed endpoint companion descriptor for interrupt endpoint */
           0x06,                           /* Descriptor size */
           CY_U3P_SS_EP_COMPN_DESCR,       /* SS endpoint companion descriptor type */
           0x00,                           /* Max no. of packets in a Burst : 1 */
           0x00,                           /* Mult.: Max number of packets : 1 */
           0x40,0x00,                      /* Bytes per interval : 1024 */

           /* Data Interface Descriptor */
           0x09,                           /* Descriptor size */
           CY_U3P_USB_INTRFC_DESCR,        /* Interface Descriptor type */
           0x03,                           /* Interface number */
           0x00,                           /* Alternate setting number */
           0x02,                           /* Number of endpoints */
           0x0A,                           /* Interface class: Data interface */
           0x00,                           /* Interface sub class */
           0x00,                           /* Interface protocol code */
           0x00,                           /* Interface descriptor string index */

           /* Endpoint Descriptor(BULK-PRODUCER) */
           0x07,                           /* Descriptor size */
           CY_U3P_USB_ENDPNT_DESCR,        /* Endpoint descriptor type */
           0x05,                           /* Endpoint address and description */
           CY_U3P_USB_EP_BULK,             /* BULK endpoint type */
           0x00,0x04,                      /* Max packet size = 1024 bytes */
           0x00,                           /* Servicing interval for data transfers */

           /* Super speed endpoint companion descriptor for producer ep */
           0x06,                           /* Descriptor size */
           CY_U3P_SS_EP_COMPN_DESCR,       /* SS endpoint companion descriptor type */
           0x00,                           /* Max no. of packets in a burst : 1 */
           0x00,                           /* Mult.: Max number of packets : 1 */
           0x00,0x00,                      /* Bytes per interval : 1024 */

           /* Endpoint Descriptor(BULK- CONSUMER) */
           0x07,                           /* Descriptor size */
           CY_U3P_USB_ENDPNT_DESCR,        /* Endpoint descriptor type */
           0x85,                           /* Endpoint address and description */
           CY_U3P_USB_EP_BULK,             /* BULK endpoint type */
           0x00,0x04,                      /* Max packet size = 1024 bytes */
           0x00,                           /* Servicing interval for data transfers */

           /* Super speed endpoint companion descriptor for consumer ep */
           0x06,                           /* Descriptor size */
           CY_U3P_SS_EP_COMPN_DESCR,       /* SS endpoint companion descriptor type */
           0x00,                           /* Max no. of packets in a burst : 1 */
           0x00,                           /* Mult.: Max number of packets : 1 */
           0x00,0x00,                      /* Bytes per interval : 1024 */


 

3. Also in the cycx3_uvc.h,  please add the following line of code:

#define CY_FX_EP_DEBUG_SOCKET CY_U3P_UIB_SOCKET_CONS_5 

Best Regards,
Jayakrishna

View solution in original post

0 Likes
yaqi_4776616
New Contributor II

Hi Jayakrishna

Thank you for being so patient and helping me.

Best Regards,

Yaqi

0 Likes