MSC + CDC Composite device example (STM32F3 Discovery)

This forum is about you. Feel free to discuss anything is related to embedded and electronics, your awesome projects, your ideas, your announcements, not necessarily related to ChibiOS but to embedded in general. This forum is NOT for support.
geoffrey.brown
Posts: 87
Joined: Thu May 07, 2015 9:47 pm
Has thanked: 3 times
Been thanked: 15 times

MSC + CDC Composite device example (STM32F3 Discovery)

Postby geoffrey.brown » Sat Aug 05, 2017 10:31 pm

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

User avatar
tfAteba
Posts: 547
Joined: Fri Oct 16, 2015 11:03 pm
Location: Strasbourg, France
Has thanked: 91 times
Been thanked: 48 times

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

Postby tfAteba » Sun Aug 06, 2017 4:53 am

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.
regards,

Theo.

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

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

Postby Giovanni » Sun Aug 06, 2017 4:29 pm

He can't move the post, moving.

Giovanni

User avatar
tfAteba
Posts: 547
Joined: Fri Oct 16, 2015 11:03 pm
Location: Strasbourg, France
Has thanked: 91 times
Been thanked: 48 times

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

Postby tfAteba » Sun Aug 06, 2017 8:59 pm

Thanks Giovanni, sorry Geoffrey.brown
regards,

Theo.

geoffrey.brown
Posts: 87
Joined: Thu May 07, 2015 9:47 pm
Has thanked: 3 times
Been thanked: 15 times

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

Postby geoffrey.brown » Sun Aug 06, 2017 11:41 pm

There's nothing to apologize for.
Geoffrey

Polux
Posts: 27
Joined: Thu Apr 28, 2016 11:52 am
Been thanked: 7 times

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

Postby Polux » Mon Aug 07, 2017 7:14 am

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

geoffrey.brown
Posts: 87
Joined: Thu May 07, 2015 9:47 pm
Has thanked: 3 times
Been thanked: 15 times

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

Postby geoffrey.brown » Mon Aug 07, 2017 1:03 pm

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

User avatar
kimmoli
Posts: 27
Joined: Sat Oct 01, 2016 8:02 pm
Has thanked: 11 times
Been thanked: 9 times
Contact:

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

Postby kimmoli » Wed Oct 11, 2017 9:56 pm

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

geoffrey.brown
Posts: 87
Joined: Thu May 07, 2015 9:47 pm
Has thanked: 3 times
Been thanked: 15 times

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

Postby geoffrey.brown » Fri Oct 13, 2017 12:37 am

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

User avatar
kimmoli
Posts: 27
Joined: Sat Oct 01, 2016 8:02 pm
Has thanked: 11 times
Been thanked: 9 times
Contact:

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

Postby kimmoli » Fri Oct 13, 2017 2:55 pm

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.


Return to “User Projects”

Who is online

Users browsing this forum: No registered users and 2 guests