cancel
Showing results for 
Search instead for 
Did you mean: 

stm32f4 multi instance usb cdc device

rm2399
Associate III
Posted on February 03, 2018 at 14:54

For a USB CDC device application I use STM32CubeF4.

It works very well now.

Now I need a second CDC channel, which paralel the 1st CDC transmits a data stream to the host.

How do I create a second USB CDC instance with Cube and how is it used?

I have set the parameter 'USBD_MAX_NUM_INTERFACES (Maximum number of supported interfaces)' to 2 in Cube, but this has changed nothing in the generated files except for the '&sharpdefine USBD_MAX_NUM_INTERFACES 2' in usb_conf.h.

USBD_MAX_NUM_INTERFACES is used only once in the file usbd_ctlreq.c throughout the project.

Is this even possible with Cube / HAL or do I have to venture the new adventure and switch to the ARM middleware library?

There is in the description 'The USB Component allows multiple instances of the CDC class.'

In the STM Cube documentation I did not find any indication that multi instanc CDCe is supported or not.

#cube-stm32f4-multi-instance-usb-cdc-device #stm32f4-multi-instance-usb-cdc-device*
7 REPLIES 7

Sorry, bumping old zombie unanswered questions off my feed

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
BSchm.0
Associate II

I have the same question. If I change the number USBD_MAX_NUM_INTERFACES from 1 to 2 I still have one /dev/ttyACM0. Is it possible to run more then one with different product identifiers ? Who from ST can support this topic ?

MSoli.2
Associate

Same problem for me today with a STM32L072 device...

@MSoli.2​ IIRC this is a Cube startup generator deficiency. To have two or more instances of same device class you need to manually add & initialize the 2nd class "object" (struct).

I had seen that the post was particularly old and I was hoping this aspect had been improved.

Do you have an example to suggest that it is based on the code generated by CubeMX?

Sorry, my mistake. My reply relates to use of some class on two USB controller instances, not to a composite device. For a composite, more complex change is needed: replace set of interface state fields in the "class handle" with arrays of these fields per-interface.

In the class request handlers, check if the request is to interface, if so, retrieve the interface index. Sorry I don't have example for CDC.

For a "serious" project the best option is using a good supported (commercial) USB library. 

MKing
Associate III

Hi,

it is a shame that CubeMX does not support a combination of several device classes. After one day of searching examples i found a "software pack" for CubeMX:

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!

 

MKing_0-1705645332984.png

 

I use:

CubeMX 6.10.0

CubeIDE 1.14.0

Processor: STM32F407VGT