ulixxe / usb_cdc

Single/Multi-channel Full Speed USB interface for FPGA and ASIC designs
MIT License
158 stars 11 forks source link

Question about adding another bulk endpoint #2

Closed RTLhamster closed 11 months ago

RTLhamster commented 1 year ago

Hi ulixxe,

first of all thank you for sharing this nice project! Just bought a cheap ice40 dev board to play around with USB CDC ...and not to fry my more expensive Zynq board (where it should run eventually) I added 33Ohms serial resistors to D+ and D- and 1.5KOhms pull-up resistor on D+ ...the loopback example works quite nicely :)

I plan to have 2 bulk endpoints within the usb_cdc, one for accessing a bus (e.g. APB) and another one for printf from processor. This should be possible, right? That I have one USB host connection and 2 serial devices (one for bus access, one for printf).

By briefly digging into your code, it seems I have to:

Do you know what else I have to change/touch, in order to get this working?

Thanks for your help! RTLhamster

ulixxe commented 1 year ago

Hi RTLhamster, yes, you have to modify the top-level usb_cdc.v by adding another bulk endpoint and the signal multiplexing controlled by endp signal.

You have to change sie.v by adding a second ENDP_BULK parameter. For example, you can change parameter ENDP_BULK = 4'd1, with parameter ENDP_BULK1 = 4'd1, parameter ENDP_BULK2 = 4'd2, and adding the relative code.

In ctrl_endp.v you have to modify both device and configuration descriptors to create a composite device for the two CDC functions. You have to "wrap" them with an Interface Association Descriptor. You can check my USB_DFU, where the USB device is a composite one with CDC and DFU functions.

I hope this can help you. See you

RTLhamster commented 1 year ago

thanks @ulixxe :blush: I will give it a try

ulixxe commented 11 months ago

Hi RTLhamster, I think your request is of general interest. So I implemented it on the codebase by adding the verilog parameter "CHANNELS". Through it you can choose how many channels you need, from 1 (default) to a maximum of 7. See you

RTLhamster commented 11 months ago

thanks ulixxe! I was successful in adding a second channel my self. Most complicated for me was to get the descriptor right. For this I actually took a look into dirty jtag project, which has a vendor specific bulk and a CDC endpoint pair.