cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMX, USB

Geoffrey1
Associate III
Posted on November 14, 2016 at 20:52

I needed to make a basic bulk device, so the natural starting point appeared to be a CubeMX generated CDC project.   Really, I was stunned by the number of custom files generated:

usb_device.h usbd_desc.h

usbd_cdc_if.h          

usbd_conf.h

usbd_cdc_if.c          usbd_conf.c

usb_device.c            usbd_cdc_if.c

usb_desc.c

After much effort, I finally achieved the result I wanted, but I really think this templating thing has gone too far.     Furthermore,  some of the generated files are virtually empty while others have a lot of stuff that needn't be customized.  Consider usbd_conf.c -- 536 lines of code.  There are only a few procedures in this that need to be customized --

LL_Driver_Init (where the endpoints are created -- btw, in the generated code these are hardwired constants rather that the defined names created in the header files), USBD_static_malloc and USBD_static_free.   

Could you please reconsider this architecture ?  It should be enough to touch a few relatively clean files to create a custom USB configuration.  Obviously the descriptors and endpoints, but most of the rest should be pretty much common.   

As things stand, I wouldn't recommend using the CubeMX generated code as a starting point for USB devices.

Geoffrey .ExternalClassFD6DE0CE53924DB0853762530284C4FB p.p1 {margin:0.0px 0.0px 0.0px 0.0px;font:13.0px Menlo;background-color:#ffefd5;} .ExternalClassFD6DE0CE53924DB0853762530284C4FB span.s1 {;} .ExternalClassFD6DE0CE53924DB0853762530284C4FB span.Apple-tab-span {white-space:pre;}
8 REPLIES 8
Amel NASRI
ST Employee
Posted on November 29, 2016 at 13:44

Hi Geoffrey,

Thanks for sharing your feedback.

We review it internally, and will come back to you as soon as possible.

-Amel-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Brendan McDonnell
Associate II
Posted on December 09, 2016 at 23:01

I'm also finding it challenging to figure out how to create a simple 'custom class' with a bidirectional USB bulk transfer pipe. I'm trying to wrap my brain around

http://www.st.com/resource/en/user_manual/dm00108129.pdf

- it's difficult to understand how all the modules interact, and what I do and don't need to customize.

It would also be helpful if you also provided sample code to setup something like this, to exchange arbitrary data with a host using WinUSB.

Brendan McDonnell
Associate II
Posted on December 09, 2016 at 23:14

Brown.Geoffrey

,

After much effort, I finally achieved the result I wanted

Can you offer any hints, as I'm trying to do the same thing?

Posted on December 09, 2016 at 23:10

I've the WinUSB forF407, not sure it still works, but you can give it a try, if you want to...

Renegade

Posted on December 10, 2016 at 04:10

Here's a github repository of a basic bulk usb example:

https://github.com/geoffreymbrown/stm32usb-bulk

 

It's just a simple echo program.  I did include two test programs that use libusb-1.0.  One that lets you send text (and see the echo) and another that gives some basic endpoint information.   I don't do windows, so I can't help with winusb.    This was a bit slapped together, so I won't make any guarantees for either the functionality or code quality

Posted on December 12, 2016 at 19:41

Looks like you're not using ST's USB library...?

Also, how do I open that as a project? I'm not familiar with GPDSC files. It's associated with Keil uVision on my Windows 10 PC, but uVision doesn't seem to know what to do with it.

Posted on December 12, 2016 at 19:41

Where would I find that? (I did look; haven't found it yet.)

Posted on December 12, 2016 at 19:46

I did use the USB library, but there’s no built-in class for bulk transfer. GPDSC is one of the options for output from CubeMX. There’s also an ioc file so you could use cubemx to generate whatever project files Keil needs. I don’t use an IDE so I can’t help you with that.

Geoffrey