adafruit / circuitpython

CircuitPython - a Python implementation for teaching coding with microcontrollers
https://circuitpython.org
Other
4.12k stars 1.22k forks source link

SD card emulator library/module #6763

Open arekm opened 2 years ago

arekm commented 2 years ago

There is a library to read sd cards but there is no library to "become" sd card to other hardware (via small pcb adapter inserted into sd card slot of other hardware and connected to circuitpython device).

The goal would be to for, example, expose fs of hardware running circuitpython as sd card in a way so both, circuitpython and other hardware could access it.

Some other projects for reference: https://github.com/ZipCPU/sdspi/blob/master/bench/cpp/sdspisim.cpp https://github.com/ZipCPU/zbasic/blob/master/sw/board/sdtest.c https://github.com/raspberrypi/pico-examples/tree/master/spi/spi_master_slave https://wiki.tizen.org/SDWire (but this only does switching between real sd card and sd card--usb storage chip) https://github.com/FYSETC/FYSETC-SD-WIFI , https://github.com/FYSETC/ESPWebDAV (another switching device, this time between real sd card and esp8266) https://www.eevblog.com/forum/microcontrollers/sd-card-emulator/ old discussion on eevblog

dhalbert commented 2 years ago

For this we need SPI secondary (device) support, which is not implemented on any port right now.

tannewt commented 2 years ago

circuitpython and other hardware could access it.

Note that SD cards operate at the block level and you'll have the same issue that we do with CP and a host computer. What device are you trying to share the FS with?

arekm commented 2 years ago

3d printer. It's a bit easier with 3d printer since most of them support remote command to release sd card (usually to remove it and also command to init it for usage). Parallel usage would be of much better but no idea if that can be done.

How CP is doing it?

tannewt commented 2 years ago

Can your 3D printer do USB host? It might be simpler to plug the circuitpython device into it.

arekm commented 2 years ago

Printer only exposes serial console over USB and the only storage medium is sd card. Currently using sdwire hardware (mentioned in first post) but that is just dumb switch without any programming capability.