Page 1 of 2

MSC + CDC Composite device example (STM32F3 Discovery)

Posted: Sat Aug 05, 2017 10:31 pm
by geoffrey.brown
I've put an example project with a MSC/CDC composite device here:

https://github.com/geoffreymbrown/STM32 ... ry-CDC-MSD

all my testing has been on OS X, but an earlier version did work on Linux. Windows will take some effort by somebody who knows about USB composite devices an INF files. It's all pretty lightly tested, so don't expect production code.

The code is based upon the MSC code in ChibiOS-Contrib, with a small change needed to make it compile without a USB OTG device.


Geoffrey Brown

Re: MSC + CDC Composite device example (STM32F3 Discovery)

Posted: Sun Aug 06, 2017 4:53 am
by tfAteba
Hi Geoffrey.brown

Thanks for sharing you project with us. It is an interresting topic that you have here :)

Please can you move this post under User Projects because it is the best place to talk about projects and exchange about it.

Thank you.

Re: MSC + CDC Composite device example (STM32F3 Discovery)

Posted: Sun Aug 06, 2017 4:29 pm
by Giovanni
He can't move the post, moving.

Giovanni

Re: MSC + CDC Composite device example (STM32F3 Discovery)

Posted: Sun Aug 06, 2017 8:59 pm
by tfAteba
Thanks Giovanni, sorry Geoffrey.brown

Re: MSC + CDC Composite device example (STM32F3 Discovery)

Posted: Sun Aug 06, 2017 11:41 pm
by geoffrey.brown
There's nothing to apologize for.
Geoffrey

Re: MSC + CDC Composite device example (STM32F3 Discovery)

Posted: Mon Aug 07, 2017 7:14 am
by Polux
Hi,
Correct me if I am wrong. No .INF file will be needed for Windows, as CDC and MSD are natively supported by the system.
Long time ago, I did this on a LPC1769 and everything was automaticaly detected. But I can't remember if it was with MSD+CDC or 2xCDC.

Angelo

Re: MSC + CDC Composite device example (STM32F3 Discovery)

Posted: Mon Aug 07, 2017 1:03 pm
by geoffrey.brown
You could well be right. I'm not a windows kind of guy and don't have and windows machines to try this on.

Geoffrey

Re: MSC + CDC Composite device example (STM32F3 Discovery)

Posted: Wed Oct 11, 2017 9:56 pm
by kimmoli
Thanks for the great job here, this was just what i was looking for.

I took the ChibiOS-Contributions HAL_USB_MSD and Geoffreys STM32F3-Discovery-CDC-MSD example from github, tinkered it on top of my other code, and got it finally working on Windows.

I now have a composite device with mass storage and virtual serial port, which works on Windows and on Linux. (These i have to test with)

The ChibiOS-Contributions SCSI library is missing the vital product data inquiry (page 80h unit serial number response) response. Windows tries this three times when attaching device. Seems each fail to read this causes a 20 sec delay, so it takes 1 minute to mount the device. This is now fixed, pull-request soon in github.

This also touches the MSD hal as it initialises SCSI device. Unit serial number inquiry response struct can be passed through msdStart() as argument, just like the scsi_inquiry_response. We could also use always the default one and not allow user to override it. This would not break existing code using msdStart(). (?)

Also, Geoffreys' example had some differences to a working VCP demo, so i tweaked it just a bit to get VCP up on windows.
One was that the IAD block is not needed for the mass storage device, only for the VCP.
Second, i changed USB_EVENT_SUSPEND and USB_EVENT_WAKEUP event handlers as they are in working VCP demo.
I will throw you a pullrequest also if you want.

Windows .inf file for the composite device was after all 'easy'. Take a copy of ST VCP .ing file, and add two rows there, same in both [DeviceList...]
(DEAD/BEEF your VID/PID)

Code: Select all

[DeviceList.***]
%DESCRIPTION%=DriverInstall,USB\VID_0483&PID_5740
%DESCRIPTION%=DriverInstall,USB\VID_DEAD&PID_BEEF&MI_01 ; add this


EDIT: AFAIK the Windows native CDC drivers are crap, and ST provides drivers that is compatible with this solution, and they seem to be reliable(ish).

EDIT: The Contributions PR is here https://github.com/ChibiOS/ChibiOS-Contrib/pull/129

Re: MSC + CDC Composite device example (STM32F3 Discovery)

Posted: Fri Oct 13, 2017 12:37 am
by geoffrey.brown
That's terrific ! Thanks for taking it to 11 ! If you'll do a pull request on my repo, I'd love to integrate your fixes.

Geoffrey

Re: MSC + CDC Composite device example (STM32F3 Discovery)

Posted: Fri Oct 13, 2017 2:55 pm
by kimmoli
I need to study this a bit more, the board surprise-reboots a few times per day.
I have most of CH_DBG_* on and no watchdog active, but still it just reboots.