Polprzewodnikowy / SummerCart64

SummerCart64 - a fully open source N64 flashcart
https://summercart64.dev
GNU General Public License v3.0
463 stars 25 forks source link

Support to interface with SD Card contents entirely over USB. #87

Open YourWishes opened 1 week ago

YourWishes commented 1 week ago

Is your feature request related to a problem? Please describe. I would love to be able to read and write contents of the SD card while it is still inserted into the N64, allowing me to perform save file synchronization.

Describe the solution you'd like Add either; A tiny SMB, FTP or WebDav server that can be spun from the command line interface that exposes the full contents of the SD card, with compatibility to Read, Write, Delete, Create Directories and if possible rimdir but it's less important.

Describe alternatives you've considered Previously I achieved this on the ED64P using a BTT-SD-Card Wi-Fi Adapter, which is a device that exposes the contents of the SD over Wi-Fi, however it uses some non standard FAT interface that I believe the FatFs lib SummerCart64 uses is not compatible with.

Alternatively support the non standard FAT interface, I don't know much about it but I believe it's a simplified FAT16 based interface.

Additional context See screenshot when attempting to use BTT Wi-Fi SD Card Adapter. Not expecting it to be supported but if it's a quick fix I'm happy to guinea pig a solution. 20240906_221705

Polprzewodnikowy commented 1 week ago

Regarding the BTT-SD-Card Wi-Fi Adapter - this thing will never work with the SummerCart64. It only supports SPI communication mode while the SC64 talks with the SD card via SDIO interface. Below is the screenshot of the adapter's instruction that warns about this issue:

Screenshot 2024-09-07 at 10 05 27

Accessing SD card via USB interface is possible with some firmware modifications, but there are couple of engineering challenges that aren't easy to overcome. This feature might get added at some point but it would take some time to implement.

YourWishes commented 1 week ago

Thanks for the quick reply, I'll take look and see if I can help add something. In the mean time is it possible to get a ls command to list contents of a folder on the SD? Rest I think I can achieve with the existing save commands.

Polprzewodnikowy commented 1 week ago

No, no, no. You have a deep misunderstanding of how the SC64 works. The flashcart itself doesn't know about files on the SD card - it merely exposes it to the N64 as a block device. It's the code running on the N64 that interprets these blocks as a filesystem.

To implement a file browser on the PC you would need:

  1. Add USB commands to start transfer to/from the SD card, in the flashcart firmware
  2. Add support for these commands in the sc64deployer
  3. Add filesystem driver (probably FatFs) to the sc64deployer
  4. Expose filesystem to the user, there are couple of ways: a. Use a FUSE/WinFSP to proxy filesystem to the underlying OS b. Make a GUI application that acts as a file browser c. Add some CLI commands to the existing sc64deployer app for listing directories and copying single files

There are more issues with this implementation, such as possibility of filesystem corruption due to two separate implementations trying to access the same resource - if both PC and N64 write to the SD card at the same time, it will most likely corrupt the FAT structure.

In conclusion - it's not that simple even if it looks like at a first glance.

YourWishes commented 1 week ago

Ah OK thanks for clarifying that.