-
-
Notifications
You must be signed in to change notification settings - Fork 19.2k
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
[FR] STM32 USB CDC + MSC Composite #18157
Comments
I've submitted a further PR for stm32duino stm32duino/Arduino_Core_STM32#1088, which works with an experimental branch of mine with Marlin https://github.com/rudihorn/Marlin/tree/usb-core. To compile it:
|
HAL STM32 already has experimental support CDC + MSC Composite. |
stm32duino PR 582 is stuck in a black hole. I'm hoping the code in this PR and stm32duino 1088 is a better way to go. I'm hoping to start playing with it this weekend. |
Yeah so the current status of the work I've been doing is it seems to work, and the USB side of things seem reliable. However somehow enabling MSC is interfering with Marlin itself. With MSC enabled, doing actions like setting the heating on works, but it completely breaks any actions requiring stepper motors. You can sometimes hear the steppers start or power up, but then they stop moving and the printer retains a busy state. It seems that the busy state actually works, as it sends out periodic busy notifications and I think it still controls the temperature as intended. It just seems stuck in the planner loop, if I had to guess what is going on. I'm not sure if it is somehow a timeout or something, but this also happens when the 3d printer is not doing busy work. I'm also a bit uncertain I'll be able to actually figure out what is going on without debugging this. If anyone with more experience with Marlin itself could even give me a glimpse of what is going on then I can try to fix this. I'm guessing it might somehow be related to either stepper or timer interrupts, but I'm not even sure which part of what code causes the planner to advance, and I'm unsure how this could be affected by the USB stack. |
The usual suspects:
|
@AnHardt I'm not directly making any changes to interrupt settings. However as far as I can tell the USB framework runs within an interrupt, and expects the SD card operations to be performed within that long running interrupt. So it likely that interrupt priorities are an issue, and I'll need to look into this some more. |
So indeed this seeems to probably have been a priority issue. As mentioned stm32duino/Arduino_Core_STM32#1088 (comment), setting the flag |
Please post a copy of your platformio.ini. I wasn't able to get a working USB interface. It enumerates without errors as a composite CDC device (3 endpoints) and MSC device (two endpoints) and shows up in my serial port list. Repetier Host can't connect to it and the virtual drive never appears. The generic Microsoft driver and the generic 3DPrinter driver both give the same result. It's probably because I don't understand how to implement this portion of your compile instructions:
|
I just committed the version I am currently working with, though it should be mostly identical. The configuration I'm using is the following, but the most important changes are using the flags: If there are issues with it not working with either of the other drivers, it is probably just a matter of changing the USB interface descriptor. Depending on the driver it might also be worth changing PID/VID. Also if you downloaded an older version of my patched arduineststm32, do make sure to remove the cached version with
|
@Bob-the-Kuhn So I just had a more in-depth look and as guessed it was just a matter of changing the descriptors. In particular, setting the protocol to |
IT WORKS!! I've tested it on the SKR_PRO and on a Black STM32F407. ThanksCode changes: Marlin - file msc_sd.cpp - need to keep this file from being compiled when doing USB without MSC. I suggest:
Strange behavior Black - takes 1-2 minutes before the mapped drive appears. |
Is there a strong reason to enable SDIO access to the onboard SD card? Marlin isn't SD intensive so the speed advantage of SDIO isn't a big item. I'm liking the idea of keeping the default as SPI because some composite capable controllers only have SPI access to the SD card. I'm also thinking that we shouldn't restrict SD access to the onboard SD card. With SPI access this requirement goes away. |
No, the Marlin bit is only something like a proof of concept, and I do not know the intricate details of when what makes sense. However until the PR for STM32duino has been merged in and made its way into a release, it is probably not worth overinvesting time in it. It would probably be good to have both options available. |
I was able to modify msc_sd.cpp and Sd2Card_sdio_stm32duino.cpp to use SDIO for the onboard SD card. May I add your software to the Marlin code base? Is the standard Marlin license OK or would you like another added to it? How would you like to be credited? I'll definitely say in the PR something like "All new files courtesy of @rudihorn ." I can also add to the files something like "Based on work done by rudihorn". |
Yes happily, I was going to submit a PR as soon as the stm32duino thing was pulled in any case.
Yeah whatever is fine.
One of the two would be nice, whichever is more appropriate. |
You are right about waiting on doing the Marlin changes. Changing platformio.ini before Marlin switches to the new stm32duino would result in no USB ports until the switch happens. I'm sure that you'll know long before I do when the new platformio stm32duino package is available. I think its best if you initiate the Marlin PR. Here's the two modified files you'll need for the Marlin PR. |
The changes I've made are:
|
I tried to implement the CDC_MSC in the latest bugfix. I'm getting timer function definition errors. There has been a lot of STM32 platform work recently. I'm definitely not understanding how the new settings work. Looks like I need to wait for you to get back to this when the new stm32duino is released. |
I just want to report, that I got my SKR PRO v1.1 onboard SD card USB access working on Marlin 2.0.7.2 by using stm32duino/Arduino_Core_STM32#1088 and applying the few changes from @rudihorn 's usb-core rudihorn/Marlin/tree/usb-core branch. |
Hi I am building bugfix-2.0.x against a SKR Mini E3 v1.2 (STM32F103RC) I'm building against STM32F103RC_btt_USB
I have also been testing against maple. The build flags presented in the stm32f1.ini file are
I have tried a combination of your flags as well
|
Description
One feature that the STM32F1 library has is the ability to have direct access to the SD card as a mass storage device in addition to serial commands over USB. Currently the HAL does not support this, but there is a PR stm32duino/Arduino_Core_STM32#586. I would suggest those interested help to review the feature and get it ready to be merged in any way possible.
I'm creating this issue as this had been mentioned by @AnHardt in #18095.
Additional Information
The text was updated successfully, but these errors were encountered: