-
Notifications
You must be signed in to change notification settings - Fork 17
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
Simulate an SD card drive. #183
Comments
Some points for discussion if/when we implement this: Right now, projects consist of just text files (code + JSON + sometimes README). Supporting arbitrary binary files comes with some challenges:
Most of these issues may be mitigated if we only store files locally, on the user computers, and not share them as part of the project. But then we lose the benefit of "share and click to play". Anyway, it'd be useful to have some input on the use cases. How many files do you usually have in the SD card in your projects? How big? Which file types? |
How about.. We take care of "hosting" the files ourselves and just give Wokwi (What is a Wokwi anyway?) a URL to the folder we want. I'd vote for just a file on a web server. That way we can easily share them when needed. And the user deals with how simple of complicated the file structure is. Worried about virus? Deal with trusted users. |
Hosting the files elsewhere will solve the storage concerns. There is still the project load time concern, and also, what do we do in case the files aren't found? Do we start the simulation with an empty SD card? Do we want the user? Also, I just remembered there's another use case for the SD card, which is for data logger projects. In that case, there's no file storage needed (at least not always), but we do need to let the user download the files saved to the SD card. Now the issue is at the top of the list (thank you!), so I'm starting to work on the implementation on the SD protocol as we figure out the storage and user experience details. |
References for the SD card SPI protocol: |
Think of the SD card as just a different interface for a wifi board. The
user gives you an initial URL (SD Card root) and you read from it or write
to it using the File commands. Including directory listings etc. The
simulator doesn't read it all in, It just does what the Arduino already
does and read in a buffer. This way you don't have to know anything about
what kind of file they are accessing, changing or creating. In my case its
a lot of .bmp files. In many cases it would be text files. If there is no
initial folder found? Do what the Arduino does with an unformatted SD
card. It just fails.
Allowing the user to host their own files makes it really nice because its
just a drag and drop for most computers to put an SC card image onto a
server. And its just another drag and drop to copy it back off once its
been changed.
A url alone gives read access. A URL with login give Read/Write access.
…-jim lee
On Sat, September 18, 2021 2:13 am, Uri Shaked wrote:
Hosting the files elsewhere will solve the storage concerns. There is
still the project load time concern, and also, what do we do in case the
files aren't found? Do we start the simulation with an empty SD card? Do
we want the user?
Also, I just remembered there's another use case for the SD card, which
is for data logger projects. In that case, there's no file storage needed
(at least not always), but we do need to let the user download the files
saved to the SD card.
Now the issue is at [the top of the list](https://wokwi.com/features)
(thanks you), so I'm starting to work on the implementation on the SD
protocol as we figure out the storage and user experience details.
--
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#183 (comment)
|
Thanks for sharing your thoughts! Some thoughts about the bring-your-own URL approach:
|
Thinking off the top of my head.. When you do the File.open(); thing, you copy the file, if found, to the user's computer. Then do all your stuff to it. When you .close() the file, you copy back teh resulting file from the user's PC/Mac. My thought would be to use good old fashioned ftp for the file transfers. As for the SD formatting, this shouldn't be an issue. The PC deals with all that. All the simulator "sees" is a URL pointing to a folder that it thinks of as the SD card's root. Maybe I'm simplifying this too much? I'm thinking in c++. I don't know what concerns you may have from the point of view of your toolset. -jim lee |
Yes, there are a few challenging constraints when running in a browser environment:
|
Quick update: I got an initial working prototype of the protocol implementation, tested against Arduino's SD library. Now working on the graphics for the element. Will post a link to a demo project in a day or two... |
Graphics ready: https://elements.wokwi.com/?path=/story/microsd-card--default |
We have a prototype implementation! https://wokwi.com/arduino/projects/310542489623724609 Some limitations:
Thoughts about the next steps:
|
If you are going to do uploads, can you make sure you can accept folders containing folders? I have a entire system folder hierarchy I use to run most of my stuff. |
That's a good point. What is the average size of the filesystem and number of files in it? |
Progress updates:
|
Here's the SD card from my current project. Goto : http://leftcoast.biz/justStuff/ then the SD card IS the folder named... "NO NAME". Now how would I get something like that into my projects? |
What are the TRK files that you have there? |
I developed a way to incorporate and select different "apps" for my
Arduino handhelds. One of the apps is a, ported to Arduino, 1970s text
based Star Trek game. It was THE THING back in the day. I played it
(earlier version) on HP 2000 as a kid and it was almost like begin there!
(Chuckle)
Anyway, those are saved games from doing testing with the Star Trek app.
I"ll post a picture for you on Discord. Adafruit did a writeup on it about
a year ago.
…-jim
On Sun, September 26, 2021 1:03 pm, Uri Shaked wrote:
What are the TRK files that you have there?
--
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#183 (comment)
|
I've implemented a temporary solution so you can start testing the implementation without having to wait for the file upload functionality:
Note: the files will be gone once you refresh the page. So you have to repeat this process whenever you open a simulation link. |
As soon as I get the bloody TFT working, I'll attach an SD card reader to it and see if I can pull up some pictures. -jim lee |
Here's an idea for sharing projects with SD cards. Set it up so the creator of the simulation can put a URL on the simulator UI that the user can click to download the files somewhere. Then link that to the SD card. This way you are not doing the down load they are. Will that work? |
That could work, but I'm afraid most of the simulation creator will be too lazy to go ahead and upload their files. The spirit of Wokwi is to have everything just "work out of the box", so I think it makes sense that we take care of storage and download for the users, even if it means more work for us... |
Help! I completely forgot how to do the file thing with the SD card. How do I get it to use my folder of files? |
Here are the instructions, Chrome only for the time being:
|
How about SD cards? Right now the SD drive is the card. But could we access something or create something on our list of items that is an SD card? Preloaded with files that we could possibly share or at least use when someone tried our simulation? As it sits now, there's only a tiny handful of people that can use the SD drive. |
So here's my thought: If we add binary files and folder support to projects, you could create a subfolder in the project which will hold the content of the SD card. Some form of folder support would probably be needed for #186, as we'd need some way to specify a different set of source code files for each MCU. |
Yes! I was thinking that the two would probably merge at some point. |
Lets get this finished up and useable (And sharable). IE Users can click on it and it just works. |
A'ight cap'n, putting it back in the oven |
Some progress: if you open a project with an SD Card, you'll see a new "SD Card" tab which lets you manage the files in the SD card. It doesn't actually upload the files yet, just stores them locally in your browser, that's coming up next. |
Good progress! While we're at it, can you default to having libraries.txt as one of the defaults? I really hate typing it in each time. |
Thanks! I'll note this in #229, which is related to libraries |
Just a quick note that a Discord user expressed the desire to be able to see/download files from the SD-card after the sketch has modified them. |
So.. Is this getting close? I have my icon editor just about ready to try out on it. This includes an entire document editing framework complete with file alerts and everything. |
Thanks for checking in! There's still some infrastructure work that I need to finish. The user interface side of things is pretty much ready (but not very polished), you can preview it here: https://sd-card-upload.preview.wokwi.com/arduino/projects/310542489623724609 Right now all the uploads will fail (due to the missing infrastructure - the data is sent to the server, but still not stored). Once that part is ready, this should be usable already. We're probably a couple of days away from that point... |
Excellent! |
Good news - the storage part is done, and the feature has been merged into production! Here's the first working example - SD Card with a custom BMP file: |
Keeping this issue open as I still have to update the documentation :) |
And now we have some documentation as well: https://docs.wokwi.com/parts/wokwi-microsd-card#filesystem |
Need SD card for doing all sorts of stuff! I use one all the time for icons etc. My thought we'd need to be able to se up a folder online for the disk image. (Just a bunch of files and folders) and the SD "card" can point at that.
The text was updated successfully, but these errors were encountered: