-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MSC configuration #9
Comments
As long as all the pointers are set correctly in your application, there shouldn't be any HardFaults caused by the library. In this case please post it as a ticket with relevant stack trace and a way to reproduce. According to the documentation of The const USBD_SCSI_StdInquiryType inquiry = {
.PeriphType = SCSI_PERIPH_SBC_2,
.RMB = 1,
.Version = 2,
.RespDataFormat = 2,
.AddLength = sizeof(USBD_SCSI_StdInquiryType) - 4,
.VendorId = "IC",
.ProductId = "Mass Storage",
.VersionId = "1.00"
}; Keep in mind that the string lengths are fixed in this struct. |
Sorry for disturbed you, I have just thought you may have a working configuration which may be used as an example. Anyway, my basic configuration was good including setting of inquiry, however, I have replaced inquiry with your code later because I still don't know if the change of ID strings may cause problems for example under Windows. The hardfault happened when host tried to enumerate the device. The last step before HardFault was the second call of this cycle of init in usbd_msc.c: The cause was in the configuration of my MSC interface itself by setting Config.MaxLUN to 1 which should has been 0 in my case. Here is a skeleton for anyone who wants a starting point of MSC device setup (you may put in the project in this or modified form): Correctly adding another LU also works under Linux (not tested further). I have an SPI flash on my board in the size of 64 Mbit. Currently, I have two VCPs and one MSC on the same board which all work perfectly and simultaneously. They also work under Windows 10, but Windows 7 and Windows XP drivers don't really seem to like my two VCP interfaces anyway. However, they work if I only have one VCP interface attached. Thank you your reply and sorry for disturbed you. |
Since the MSC LU implementations heavily depend on the medium type it wouldn't have made much sense to send a solution most of which you will have to rewrite anyway. I have quickly checked your msc_if skeleton, I have one comment to add: do not initialize the interface structure this way: USBD_MSC_IfHandleType hmsc_if = {
.Base.AltCount = 1,
.LUs=msc_lu,
/* all other fields are implicitly set to zero, initial value stored in flash */
}, *const msc_if = &hmsc_if; As this implicitly defines all other fields of the struct (which includes a 512 bytes buffer) as zeroes, and stores the entire initial value in flash, therefore wasting more than half kB of program memory. A better solution is to define the variable without an initial value and set all necessary fields of the interface structure during startup, before calling the |
You are correct, thank you. Anyway, I think providing similar code as example may be useful as starting point even if the code is not complete as at least device-specific handlers are missing. |
I am trying to get a MSC + CDC composite that must work against MS Windows. Currently the device is enumerated and some descriptors are read (I have an USB analyzer) the VCP is detected I see on bus just after set configuration some line coding commands. However the MSC is not started (usually a "get max LUN" I saw on other devices..,) `/* Initialize the device */
` So can you give some suggestion or working example? |
I don't have a public project with MSC, but others have successfully integrated it, e.g. https://github.com/Smoothieware/SmoothieV2/blob/master/Firmware/Hal/usb/msc_if.c |
I have msc_if->Base.AltCount = 1 and msc_if->LUs properly setted. |
Hello,
Could you please help me how to configure an MSC device properly?
I hope you may have something which may be used as example configuration showing basic requirements of device setup.
I think I miss some configuration to define or doing it completely wrong as my MCU generates HardFault.
So, if you may have something which can be used for proper device initialization, I would be happy.
Thank you your help in advance.
The text was updated successfully, but these errors were encountered: