The EverDrive-64 X7 is a flash cart made by Krikzz.


Serial Communication

The EverDrive-64 X7 supports serial over USB communication to a host PC. This can be used to load ROMs and allows running ROMs to send an receive data from the host PC. Krikzz provides a reference implementation here.

Serial Registers

The EverDrive-64 X7 provides various registers starting at the address 0x1F800000 in the cartridge address space. The following registers are used for USB communcation.

List of Registers
Name Description Address relative to 0x1F800000 Size (bytes)
REG_USB_CFG Reads USB status and sends read and write commands 0x0004 4
REG_USB_DATA The temporary data buffer used to read and write to USB 0x0400 512
REG_KEY Set to 0xAA55 on initialization 0x8004 4
REG_SYS_CFG Set to 0 on initialization 0x8000 4

The REG_USB_CFG register contains various bits as described below

REG_USB_CFG bits
Name Description Bits (15-0) Hex Mask
USB_LE_CFG Set to a 1 when reading and writing data 15 0x8000
USB_LE_CTR Set to a 1 when reading and writing data 14 0x4000
USB_STA_BSY Behavior not known 13 0x2000
USB_STA_PWR Set to when 1 when data can be read or written 12 0x1000
USB_STA_TXE Set to 0 when data can be written 11 0x0800
USB_CFG_RD/USB_STA_RXF Writing a 1 switches the controller to read mode. Writing a 0 switches the controller to write mode.

Reads as a 0 when data is available to be read.

10 0x0400
USB_CFG_ACT/USB_STA_ACT Writing a 1 starts reading or writing to REG_USB_DATA. The direction of data is specified by the value of USB_CFG_RD. The amount of data written is specified by baddr.

When reading this bit, a 1 indicates the USB port is busy reading or writing data.

9 0x0200
baddr These 5 bits give the address into REG_USB_DAT where USB data is read from and written to. Data is read starting at baddr offset until the end of the REG_USB_DAT buffer. This means the amount of data read is 512 - baddr. Because of this, when copying data to and from REG_USB_DAT, you don't always start copying at the beginning of the buffer. 8..0 0x01FF

Initializing Serial Data

Below is the code used to initialize USB IO from krikzz's reference code with comments

void bi_init() {
    // sets the PI handler latency
    IO_WRITE(PI_BSD_DOM1_LAT_REG, 0x04);
    // sets the pulse for the PI manager
    IO_WRITE(PI_BSD_DOM1_PWD_REG, 0x0C);
    
    // the specific value of 0xAA55 needs to be written here to enable USB IO
    bi_reg_wr(REG_KEY, 0xAA55);
    bi_reg_wr(REG_SYS_CFG, 0);
    // this flushes serial buffer of any pending data
    bi_usb_init();

    // sets the save type. Not needed for USB IO
    bi_set_save_type(SAVE_OFF);
}