-
Notifications
You must be signed in to change notification settings - Fork 34
5) The SC64
This page describes how the UNFLoader tool and USB library handles the SC64 flashcart.
The SC64 (previously known as SummerCart64) is a free and open source N64 flashcart created by Polprzewodnikowy, fully available on his GitHub repo. It features a very fast 480Mb/s USB FTDI chip, and works similarly to the 64Drive. Besides the source code for the hardware, firmware, and the sc64deployer PC app, your only other source for the USB protocol is this very repository (UNFLoader, that is), as the cart's developer wrote support for it himself.
On the SC64, reads from cartridge space are mapped to SDRAM, meaning that you can use the usb_io_read and usb_io_write functions to address the different cartridge interface devices.
UNFLoader implemented SC64 communication using the D2XX FTDI library.
ℹ️ The SC64 has no byte alignment requirements.
After probing the connected devices, check if the device description matches "SC64" and the ID matches 0x04036014. If those two match, then the device is probably a SC64. To be sure, you need to open device and send IDENTIFIER_GET command to get response.
To detect flashcart presence you need to unlock register access first. Refer to the usb_findcart() function in usb.c for correct order and values for unlocking process. After successful unlocking you can read IDENTIFIER register located at address 0x1FFF000C that should return value 0x53437632 ("SCv2" in ASCII encoding).
Open the device and set its timeouts to a large enough value (by default, 5000 milliseconds is used). Set the cart's latency timer to 0 and reset the bitmode to 0xFF. Finally, it is recommended to purge the receive and transmission buffers before continuing.
The SummerCart64's USB protocol is documented in usb_pc.v, in the Command ids section. Commands are always 12 bytes big and start with C M and D, followed by a character that represents the command you want to send. The next 8 bytes are reserved for arguments. Some commands require you to write more than 8 bytes of arguments, so you should do so after sending the command header. Some commands send an 8 byte reply, which will contain the 3 bytes CMP, ERR, or PKT, and the fourth byte with the command you replied with. The last 4 bytes contain the size of the incoming reply, which you should read from USB and handle accordingly.
The USB upload process is done with the system turned on. The SummerCart64 has access to the IO pin that holds the switch on the voltage rail of the 4300, thus it can reset the console through USB. The upload process is quite intensive, so if you wish see how it's done, check out the device_sendrom_sc64 function in this repo's device_sc64.cpp.
In order to send data to the connected PC, check out UNFLoader USB Library's usb.c, specifically, the usb_sc64_write function. Make sure that you 4 byte align all data before sending it.
The SummerCart64 does not have a standard USB communication protocol, therefore, if you want your code to be compatible with UNFLoader, you must append the DMA@ header to the start of your data, and the CMPH signal to the end.
In order to write data to USB on the PC, check out the device_senddata_sc64 function in UNFLoader's device_sc64.cpp. The SummerCart64 does not have a standard USB communication protocol, therefore, if you want your code to be compatible with UNFLoader, you must append the DMA@ header to the start of your data, and the CMPH signal to the end.
In order to read the USB buffer on the N64, you can check out UNFLoader USB Library's usb.c usb_sc64_poll and usb_sc64_read function.