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
MSC + CDC Composite device example (STM32F3 Discovery)
-
- Posts: 87
- Joined: Thu May 07, 2015 9:47 pm
- Has thanked: 3 times
- Been thanked: 15 times
- 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)
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.
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.
Theo.
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
-
- 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)
There's nothing to apologize for.
Geoffrey
Geoffrey
Re: MSC + CDC Composite device example (STM32F3 Discovery)
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
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
-
- 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)
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
Geoffrey
- 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)
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)
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
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
-
- 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)
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
Geoffrey
- 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)
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.
I have most of CH_DBG_* on and no watchdog active, but still it just reboots.
Who is online
Users browsing this forum: No registered users and 31 guests