-
Notifications
You must be signed in to change notification settings - Fork 980
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
Add USB MSC + MSC/CDC Composite Class #1088
base: main
Are you sure you want to change the base?
Conversation
#586 (comment) explains what is being done in this PR as well. |
There is progress on the SD card initialization. I've changed it so that the default MSC handler pretends to be busy, and in my marlin implementation the sd card continues to not be ready until a valid capacity can be read. This means that despite the incorrect behaviour of marlin to initialise the SD card first, it is possible to exchange the MSC handler and still use the SD card. Unfortunately it is not possible to do the same for the logical unit numbers. I also found a bad bug in the STM32 MSC SCSI implementation, which seems fixed in later versions. I have been using this feature to perform firmware upgrades on my board by uploading to the SD card and I have to say that it seems to work nicely :) |
Is there a way to disable / change the AStyle check for |
No, the rule is the same for all the repo.
I will update soon the USB middleware, it is in the pipe, see #1027 |
I have now added a new The following is a simple example of what a handler can look like:
The user can then use either of these methods on
@fpistm As the MSC handler has been duplicated because alterations were necessary, an update to the USB middleware is not urgently required yet. |
In fact I will merge it soon as I'm currently validate it. |
@rudihorn |
Is there a reason why
USB.cpp ).
|
yes, IIWR the goal is to init the USB as soon as possible. |
I've added a For the two remaining unchecked points: I can't think of a better way to handle the USB/USBSerial/... so I would suggest we just leave it like this. I've looked over the endpoint buffer configuration code and I think it should produce the same behavior as before, but I'm not entirely sure why there is this number of eps * 8 base offset and I don't have devices to test it. As such I think I am happy for this code to be reviewed / merged, and if there is anything else I can do for this PR to be merged in let me know. |
Although some behaviour does still seem a bit odd, so I will try syncing the MSC and CDC class code to the latest version and will wait until #1027 is merged in. |
@rudihorn Could you also share some use case example ? |
@fpistm Are there any updates on this and what more is required to get this merged? |
Hi @rudihorn |
Status? |
Currently not sorry. |
@rudihorn is there any standard for the |
I'm getting |
|
||
/******************************************************************************* | ||
* Function Name : Write_Memory | ||
* Description : Handle the Write operation to the STORAGE card. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all comments are equal
Any update on if this is going to be added? Or is the PR dead? I did not test it yet but it seems to be a great addition to the core to be able to use Serial and mass storage over USB. |
We are actively using it on Marlin for some boards, together with #1196. |
I tried it today and it indeed worked! I adapted the example to use the SDIO interface and the SD library write/read function in STM32SD.h. It is slow in writing (probably because of the 512 byte blocks) but it works. This example worked in PIO using the black development boards of STM32F407 Ow and for who ever want to try with PIO don forget to put the "-DUSBD_USE_CDC_MSC" in your build_flags Only thing i noticed is the wait until it connects to Serial USB is not working the way it did before. Its not waiting for any connection on my system anymore? Not sure why. It just continues. Another question, is it possible to de-initialize the usb mass storage from software? I want to be able to enable/disable the USB mass storage function from software on some triggers inside the use code. Then the user code can take control of the SD card again to log data to it.
|
Today I found an issue with this PR, when using with a F1 board. This PR add a class called USB... but, we have this on F1:
File: system/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xe.h So we need a new class name... |
What about rename the |
Is this dead? I can help here too. |
This branch have this PR + #1196 working together: https://github.com/rhapsodyv/Arduino_Core_STM32/tree/usb-host-msc-cdc-msc-2, with the USB class name fixed. Yet for 1.9.x. |
It is not dead. I need some free time to review it carefully. I do my best... 😕 |
for (uint32_t i = 0; i < (DEV_NUM_EP + 1); i++) { | ||
HAL_PCDEx_PMAConfig(&g_hpcd, ep_def[i].ep_adress, ep_def[i].ep_kind, ep_def[i].ep_size); | ||
ep_desc_t *pDesc = &ep_dep[i]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo here... ep_dep
=> ep_def
Should it be possible with this PR to connect a G3 Dongle to the USB port of a STM32F4 BlickPill running stm32dunio and open a serial connection to send AT commends etc? Or am I barking up the wrong tree? The dongle presents itself on Linux as a GSM modem /dev/ttyUSB0 and I confirm it responds OK to AT command. It also presents 3 other GSM devices and a mass storage device that is not actually needed. I guess the STM32 would need to enumerate them to get the the correct CDC? Is there an example of this somewhere please? I see examples above of using the MSC but not so much for the CDC. |
Hi |
When is the merge release?? |
@rhapsodyv Sir what files need to be copied and updated to the current version to get CDC/ MSC device working for STM32F1. |
If anyone could share an example project implementing the CDC+MSC composite I would appreciate seeing it all put together. I'm using a STMF4. I can get both working one at a time but struggling with the composite. I like this approach of leaving the classes separate though as i'm currently trying to vector them and it's ugly. |
Apparently this is not compatible with the latest ArduinoSTM32 (4.20200.221104) https://github.com/rhapsodyv/Arduino_Core_STM32/tree/usb-host-msc-cdc-msc-3 …so it cannot yet be used with STM32H743 and others. How hard is that to port over to the latest? |
@fpistm Seems like discussion of this trailed off a few years back. Wondering if the functionality provided by this PR (CDC+MSC composite) was rolled into the core somewhere along the way? As the previous comment mentioned, https://github.com/rhapsodyv/Arduino_Core_STM32/tree/usb-host-msc-cdc-msc-3 doesn't seem t be working any longer, and I haven't had any success, too :( |
This PR is an alternative to #586. It extends the USB profiles with an MSC class and an MSC+CDC composite class.
Summary
pdev->pUserData
andpdev-pClassData
, allowing existing classes to be reused in composite class interfaces.usbd_ep_conf
files have been simplified and improved to prevent redundancy.USE_USB_CDC_MSC
enables this composite class.Validation
The board used has a
STM32F407ZG
, but it should hypothetically work on any currently supported MCU. In particular the MCU's usingHAL_PCDEx_PMAConfig
should probably be tested.Discussion points
USBSerial
/USB
classes. CurrentlyUSBSerial
implicitly enablesUSB
, which may not be desired before MSC has been correctly initialised. Alternatively adding code to reset theUSB
automatically.Code formatting
Closing issues
#586