-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Multiple luns #6555
Multiple luns #6555
Conversation
@hathach I tried this on Linux, macOS 12.4 (the latest), and Windows 10. I wrote a code.py that mounted the SD card file system, and then just looped to stay in code.py. On Linux and macOS it worked OK. On macOS the SD card drive appeared quickly; on Linux it took a few seconds longer. Occasionally it would get hung up, but a reset fixed things. On Windows, I had more trouble. Windows took a long time to show drives D, E, F, G, as long as 15 or 30 seconds. Drive D was CIRCUITPY. Trying to edit a file on the SD card drive caused a spinning mouse cursor, and did not work. Sometimes after a reset the drives would not appear, and I had to resort to unplug/replug. In general it was not a satisfactory experience. Did you notice similar behavior on Windows, or did it work better for you? Since we can't tell what the host system is, we could do something more restrictive, but simpler: we could restrict this to allowing only as many LUNs as mounted filesystems. The SD card or other secondary filesystem would need to be mounted in |
Thanks Dan for detail testing, hmm, I actually test this more on Linux (main pc) and macOS
I guess there maybe some scsi command that does not meet windows expectation. I will pull out my analyzer to test with. |
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.
supervisor/shared/usb/usb_msc_flash.c
@dhalbert confirmed the slow enumerating on windows 10, is troubleshooting, have no idea I miss this in the first place. Will post more update when I have one. |
@dhalbert I have updated the msc to fix issue with null vfs. These should fix current issue with windows. Would you mind testing it again.
PS: Issues are caused by windows skipping Test Unit Ready for certain commands (probably for speed) and try to read & access LUN. Previously, we didn't check the SD existence for read capacity and/or read/write --> caused misbehavior due to incorrect response. Linux/macos doing better job by always test to check if unit is ready first before doing any access command. |
FYI, Dan is out on vacation this week and should get back to you next week on this. |
thanks @tannewt for the info |
I had a user test this, and they said they were unable to create new files on CIRCUITPY after the latest commit, using Windows I tried the artifacts from the the latest commit on PyPortal on Linux with an SD card inserted, and confirmed that. I did this test on the artifact from before and after the latest commit.
Note that I did not On the previous artifact (a512f83), |
thanks @dhalbert for testing, just want to re-confirm
|
I am testing e780461 with a PyPortal with the simpler test code below. I initially only tested on Linux, but here are results for all. Linux Ubuntu 22.04: as above. Both drives appear, but when attempting to create a new file on either drive, it never shows up. Sometimes it appears as if the drives are remounting (disappear and appear in the file manager). Windows 10 (latest version): Both drives appear, and show the files I expect. But if I right-click and try to create a "New Text Document", I get an error window like the below. I also tried saving a file in Notepad, and got a different error about the drive not existing. macOS 12.4 on an M1 Mac Mini: The drives never show up. The PyPortal screen shows auto-reload happening over and over every few seconds. This is quite new behavior. macOS used to be the best-behaved. Test program, which just mounts the SD card and waits. I am using an 512MB (not a typo - it's small) SD card. import board
import sdcardio
import storage
import time
sdcard = sdcardio.SDCard(board.SPI(), board.SD_CS)
vfs = storage.VfsFat(sdcard)
storage.mount(vfs, "/sd")
while True:
time.sleep(1) |
@dhalbert thanks, yeah, I confirmed the issue with creating new file. I probably don't test this enough. Will definitely running some disk benchmark this time to make sure everything is OK. Will push the fix if as soon I could |
@hathach Did you ever get back to this? |
@tannewt unfortunately not yet, I have switched to other esp32/rp2040 works. Will back to this later when possible. |
Perhaps using a single LUN that presents additional devices as partitions in a fake MBR would work around host OS problems. |
Could it be dynamic in that case? Would the partitions for unmounted filesystems be visible? |
It could be dynamic in the same sense as adding/changing/deleting partitions with
No. We'd elide all but existing filesystems from the fake MBR. This approach would work best where the additional SD card devices are inserted into the CP system before attaching USB to the host and are then left undisturbed until unmounted from the host OS. |
Just an FYI... Espressif ESP_IDF has the esp-iot-solution with examples. An one of those examples is the usb_msc_wireless_disk. |
Closing this because it hasn't been worked on ages and we're not sure when we'll get back to it. #3477 is still open to track the desire and links to this PR. |
This PR exposes up to 4 LUNs for MSC, for additional fatfs such as SDCard. Mostly based on @dhalbert https://github.com/dhalbert/circuitpython/tree/multiple-luns branch combined with following changes
NOTE: I originally planned to make PR to Danh's fork as of dhalbert#1 . However, the tinyusb lib version there requires update to work with macOS, therefore I merge from latest
main
since it already got later version of tinyusb. Now the changes compared to Danh's fork is too large. So it is better to just make PR to main directly.Tested with PyPortal using built-in card reader with the following
code.py
on windows/linux/macos. Note: SD is slow, if your card has lots of files, it may take several minutes to show up on the file explorer.