cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 Generic USB Advice

oli2
Associate II
Posted on December 12, 2011 at 09:09

Hi all,

I'm completely new to ARM and ST, having mainly used Microchips offering previously. Thinking it was time to branch out a bit and liking the look of the new ST stuff, I grabbed the new F4 Discovery board a few days ago.  

Anyway, I have got a few examples up and running and am beginning to find my way around the documentation and chip. 

The project I am planning to use the F4 in would require a generic USB OTG interface, so I am looking for any good examples/documentation for this.

For example, with the PIC32 I used the Generic MCHPUSB, LibUSB and WinUSB drivers, so something along these lines which doesn't require writing a new driver would be useful.

I read that there is an ST driver available in

http://www.st.com/internet/com/CORPORATE_RESOURCES/COMPANY/DIVISIONAL_PRESENTATION/Nuremberg_Workshop_USB.pdf

 (page 72) which is also used for DFU. Since our project would require DFU this would fit well, but it doesn't actually mention the name of the driver in the document and I cannot find anything about it on ST's website.  

Could anyone point me in the right direction please? Any help would be much appreciated. Example firmware (I'm using Atolic for now) or documentation, relevant links from St's site, etc. I've not got to know my way around any of this yet so am probably missing plenty.

Thanks.

#usb-stm32f4
8 REPLIES 8
maheshkuruganti
Associate
Posted on December 17, 2011 at 04:45

The driver is available in the firmware package. It in the Peripheral Drivers section. All the USB Drivers are available there. Good Luck

oli2
Associate II
Posted on January 11, 2012 at 14:43

Thanks for the reply.

I probably wasn't quite clear enough - I was looking for firmware examples for a generic driver like WinUSB or LibUSB. This would make it easy to get started with quickly as I don't know my way around the USB stack yet.  

In any case, I couldn't find anything so I hacked around with the HID example and got it working with LibUSB. Took longer, but now I know my way around the stack a bit better so all is well 🙂

flyer31
Senior
Posted on January 12, 2012 at 07:01

That's exactly what I am also looking for, best a bulk transfer test firmware for device mode (Just accepting bulk transfers with highest possible speed and then showing the transfer rate in some small Windows application window based on WinUSB (or LibUSB - thanks for this hint, I did not know it before), with the source code of this small Windows app available).

Unfortunately they only provide these standard driver examples like HID, MSC, CDC-VCP (I assume you got the ''STM32_F105-07_F2xx_USB-Host-Device_Lib_V2.0.0'' - you can download this somewhere from the ST homepage). Presumably they did not want to write a small Windows software themselves, so they rely on these standard drivers, but this makes it very cumbersome for anybody, who wants to use their USB for some customized data transfer.

I found the CDC-VCP example quite useful - I got this running on STM32F4 Discovery now, so that it operates with HyperTerminal in an Echo mode. Just this is not suitable to test the transfer speed.

This STM32F1-F2-LIB comes with full source code, but unfortunately does not contain a ''custom class''. The User manual UM1021 just has a brief paragraph 6.7.5 ''Adding a custom class''. So I think this is the way to go ... . If you have any results, I would be very interested.

raffael
Associate II
Posted on January 16, 2012 at 11:08

Update:

I just managed to get the example running on STM32F4 Discovery...

Hello Bil

I'm struggling to implement CDC-VCP on the STM32F4 Discovery. (And some others too, I guess.)

Most of the time the application on the STM32F4 crashes when I connect USB and Windows states ''usb device not recognized...'' and ''Unknown Device'' respectively.

Could you give some hints on how to port the VCP example (STM32_F105-07_F2xx_USB-Host-Device_Lib_V2.0.0) to the STM32F4?

If you could share (parts of) your code this would be very nice.

Thanks and Best regards,

Raffael

oli2
Associate II
Posted on January 23, 2012 at 07:51

From: bil.til

 

Posted: Thursday, January 12, 2012 7:01 AM

 

Subject: STM32F4 Generic USB Advice

 

 

This STM32F1-F2-LIB comes with full source code, but unfortunately does not contain a ''custom class''. The User manual UM1021 just has a brief paragraph 6.7.5 ''Adding a custom class''. So I think this is the way to go ... . If you have any results, I would be very interested.

I read the part about the custom class and used what little there was to go on to alter the HID example accordingly. It worked fine with a small test program knocked together in C# using LibUSBs supplied library.  

I am working on other things currently (having problems with libraries :( see my latest post) but if you are still having problems and would like to see my project just let me know and I will dig it out and send it to you (also have a basic Visual Studio program - press button to toggle LED on discovery board)

flyer31
Senior
Posted on January 23, 2012 at 10:20

Wow, that would be great.

I meanwhile succeeded in porting the CDC example first the ST4Discovery in FS-Mode, then to Keil MCBSTM32F400 in FS-Mode, and then also to Keil MCBSTM32F400 in HS mode.

Just to my disappointment the STMCDC.INF ''driver'' seems to be somehow linked to other software of STM, and I do not find this link. In the STMCDC.INF file I see only invocations of Standard / Microsoft drivers - so I have no idea why this driver gives a message as ''STMicroelectronics Virtual COM Port'', even after I customized all ''STM''-texts in the firmware and in the driver INF file. Even worse, it does not seem to allow to change VID/PID - after such a change, the INF will not work anymore (of course I also change the VID/PID also in the INF to the same value). Further if I keep the original VID/PID, then this driver does NOT work on some other ''virgin'' PC - I assume somehow this STMCDC.INF driver has some ''hidden bridge'' to any other drivers, which maybe are installed together with ST-LINK for ST4Discovery ... .

So now I will skip any further work on the CDC, and I just last night decided to continue with this custom firmware class, and then use WINUSB, perhaps again first on ST4Discovery, then on Keil FS and finally (hopefully) on Keil HS.

If you could show me your firmware code for the customs class, and possibly also a VB WINUSB application, this would save very much work for me.

oli2
Associate II
Posted on January 23, 2012 at 21:31

Okay, I attached the project structure, the main.c/h from it, the LibUSB device class and a (very) rough old app I altered slightly to test it. In the app, you click ''open USB'' then ''Single Shot'' to toggle the LED on the discovery board (none of the other buttons will do anything)

The toggle is simply coded directly into the receive routine in the LibUSB class (USBD_LibUSB_DataOut -normally of course you would pass to your main app)

It's all a mess as I was rushing, as soon as I proved it worked I moved on. Hopefully you can make some sense of it though. The project was an adaptation of the Discovery demo, and all the files were linked so I couldn't just zip and post that. Instead I took the most important bits out. You should be able to start a project, add the USB libraries and drop the main/LibUSB in.

Hope it helps a bit.

________________

Attachments :

LibUSB.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtXa&d=%2Fa%2F0X0000000aRU%2FLd8y8FCr1amiCdNqBwA7eZwPTOmc9Ub6zaqPx5ItZ2s&asPdf=false

main.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtXf&d=%2Fa%2F0X0000000aRV%2FETCnu0fO.L.ZlLtuKUP0zikGJ9OwM0uUksbD.gKoBNk&asPdf=false

STM32_Custom_USB_Test.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtXk&d=%2Fa%2F0X0000000aRX%2FNbnHzQebAgUb2AFx0Yi00CvOpGy2AYysBNxY58aSr1o&asPdf=false

STM32_USB_Test.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtXg&d=%2Fa%2F0X0000000aRW%2FJypyM2BXNlyrIV8WSMy5DReluEsHVFF99nSUEgDO2Mc&asPdf=false
iamhighlander
Associate
Posted on November 12, 2012 at 22:16

With regards to the project files you posted,  is there any way you could maybe go into more detail with how I might run your device driver and PC side application together?  I've been combing through it and trying to get something to work, but I'm stuck.

Edit:  To be more clear, can you be more explicit about how to compile the files and get everything to run?