cancel
Showing results for 
Search instead for 
Did you mean: 

UVC+CDC USB Composite device on STM32F411

transistorboy32
Associate II
Posted on August 01, 2016 at 16:02

Overall objective: Using

https://github.com/groupgets/purethermal1-firmware

as a base, add a USB serial port interface (which would replace the DEBUG functionality it has currently). I have read through multiple posts here regarding composite devices and after about a day of work I have an attempt at the modified firmware running on the device. The video device works fine, and Device Manager shows a new COM port with no errors. So far so good. The problem occurs when I try to open the serial port - the terminal software throws an error trying to open the port. I feel like I've almost got it, but I'm not quite there. I haven't implemented certain things like handling GET_LINE_CODING control code, etc. Is that needed to open the port? Should I use [0x00, 0x00, 0x00] (use interface descriptions) or [0xEF, 0x02, 0x01] (misc) for [DeviceClass, SubClass, Protocol] on the main USB description? Doesn't seem to make a difference. I am using two IADs: one for the UVC group and a second for the CDC group. The IADs are [0x0E, 0x03, 0x00] and [2,2,1], respectively. I might have to modify an INI file somewhere, but I'm not sure which one or how. Device Manager shows no errors (although the CDC device does appear as a ''Serial Device'' not a ''Serial Port''). I see the chip I am using (STM32F411CEU6) supports ''4 endpoints'' (that's in the datasheet, but I can't find any more info than that). The original UVC interfaces uses two endpoints (UVC_IN_EP and UVC_CMD_EP) and the CDC interfaces use three (CDC_IN_EP, CDC_OUT_EP, and CDC_CMD_EP). That's 5 endpoints, but only four are IN, and one is OUT. I can't find any info on if one of the endpoints is used by default (EP0), or if the specified max 4 endpoints are actually 4 bidirectional or 8 unidirectional or some combination thereof. One snippit (the original usbd_conf.c):

HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_FS, 0x80);
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 0, 0x40);
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x80);

I assume I need to add a few lines here for the new CDC endpoints, but am not sure exactly which values to use. I've tried:

HAL_PCD_SetTxFiFo(&hpcd_USB_OTG_FS, 2, 0x10);
HAL_PCD_SetTxFiFo(&hpcd_USB_OTG_FS, 3, 0x20);

Tweaking values didn't seem to help. Should I be using different pairs of TX/RX buffers for the UVC/CDC interfaces or just a single buffer pair for the whole USB device? I don't think that should prevent a port from being opened, right? Any help is appreciated. Thanks!
2 REPLIES 2
transistorboy32
Associate II
Posted on August 15, 2016 at 01:01

Are these endpoint values OK:

UVC_IN_EP 0x81
UVC_CMD_EP 0x82
CDC_IN_EP 0x83
CDC_OUT_EP 0x03
CDC_CMD_EP 0x84

I used Wireshark's USB capture and compared it to debug output from the micro's USART output, which has debug messages routed to it (for now). I notice that the setup messages correctly match for the first UVC part:

SET INTERFACE (1)

GET INFO [Brightness]
GET MIN [Brightness]
GET MAX [Brightness]
GET RES [Brightness]
GET DEF [Brightness]
GET INFO [Contrast]
GET MIN [Contrast]
GET MAX [Contrast]
GET RES [Contrast]
GET DEF [Contrast]

but then the host sends:

SET INTERFACE (3)
GET LINE CODING
SET CONTROL LINE STATE
SET LINE CODING
GET LINE CODING

as expected, but the debug messages from the micro do not show these messages, as if they are being lost somehow. I am printing a debug message right when the Setup callback is called on the micro. The first SET INTERFACE (1) call is seen, but the second call (to set interface #3, correctly corresponding to the first interface of the CDC) is ''missed''. Maybe my endpoints are set incorrectly?
MKing
Associate III

Hi,

maybe this is helpful:

alambe94/I-CUBE-USBD-Composite: Create STM32 USB Composite devices with ease. (github.com)

ST, please support this project and promote it, so we all can save lifetime!