USB Gecko Serial Protocol

Discussion in 'Wii - Hardware, Devices and Utilities' started by gudenau, Sep 27, 2015.

  1. gudenau
    OP

    gudenau Largely ignored

    Member
    GBAtemp Patron
    gudenau is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    3,301
    1,253
    Jul 7, 2010
    United States
    /dev/random
    I have been having a hard time figuring out the protocol, I can get one bhte commands working but that is about it. The gecko.net source is a little confusing, as well as the code handler's; then the wiki has what I was able to figure out myself.

    Any help?
     
  2. FAST6191

    FAST6191 Techromancer

    pip Reporter
    23,865
    9,780
    Nov 21, 2005
    United Kingdom
    When you say wiki do you mean http://wiibrew.org/wiki/USB_Gecko ?
    The PDF link on that does not work but still seems available on http://www.furmans.com.ua/drivers/D2XXPG34.pdf

    Afraid I never went far with the USB gecko so I am not sure what I can do from memory. I also have to go do something so sitting here and puzzling things out is not what I am going to be able to sit here and do

    http://geckowii.googlecode.com/svn/trunk/GeckoDotNET/Gecko dNet/USBGecko.cs
    Code seems to be GPL v2
    Code:
        public class USBGecko
        {
            #if DIRECT
                #if MONO
                    private LFTDI PFTDI;
                #else  
                    private D2XXWrapper PFTDI;
                #endif
            #else   
                private FTDI PFTDI;
            #endif
    
            #region base constants
            private const UInt32    packetsize = 0xF800;
            private const UInt32 uplpacketsize = 0xF80;
    
            private const Byte      cmd_poke08 = 0x01;
            private const Byte      cmd_poke16 = 0x02;
            private const Byte     cmd_pokemem = 0x03;
            private const Byte     cmd_readmem = 0x04;
            private const Byte       cmd_pause = 0x06;
            private const Byte    cmd_unfreeze = 0x07;
            private const Byte  cmd_breakpoint = 0x09;
            private const Byte cmd_breakpointx = 0x10;
            private const Byte    cmd_sendregs = 0x2F;
            private const Byte     cmd_getregs = 0x30;
            private const Byte    cmd_cancelbp = 0x38;
            private const Byte  cmd_sendcheats = 0x40;
            private const Byte      cmd_upload = 0x41;
            private const Byte        cmd_hook = 0x42;
            private const Byte   cmd_hookpause = 0x43;
            private const Byte        cmd_step = 0x44;
            private const Byte      cmd_status = 0x50;
            private const Byte   cmd_cheatexec = 0x60;
            private const Byte cmd_nbreakpoint = 0x89;
            private const Byte     cmd_version = 0x99;
    
            private const Byte         GCBPHit = 0x11;
            private const Byte           GCACK = 0xAA;
            private const Byte         GCRETRY = 0xBB;
            private const Byte          GCFAIL = 0xCC;
            private const Byte          GCDONE = 0xFF;
    
            private const Byte        GCNewVer = 0x80;
    
            private static readonly Byte[] GCAllowedVersions = new Byte[] { GCNewVer };
    
            private const Byte       BPExecute = 0x03;
            private const Byte          BPRead = 0x05;
            private const Byte         BPWrite = 0x06;
            private const Byte     BPReadWrite = 0x07;
            #endregion
    
            private event GeckoProgress PChunkUpdate;
    
            public event GeckoProgress chunkUpdate
            {
                add
                {
                    PChunkUpdate += value;
                }
                remove
                {
                    PChunkUpdate -= value;
                }
            }
    
            private bool PConnected;
    
            public bool connected
            {
                get
                {
                    return PConnected;
                }
            }
    
            private bool PCancelDump;
    
            public bool CancelDump
            {
                get
                {
                    return PCancelDump;
                }
                set
                {
                    PCancelDump = value;
                }
            }
    
            public USBGecko()
            {
                #if DIRECT
                    #if MONO
                        PFTDI = new LFTDI();
                    #else
                        PFTDI = new D2XXWrapper();
                    #endif
                #else   
                    PFTDI = new FTDI();
                #endif
                PConnected = false;
                PChunkUpdate = null;
            }
    
            ~ USBGecko()
            {
                if (PConnected)
                    Disconnect();
            }
    
            protected bool InitGecko()
            {
              UInt32 FT_PURGE_RX = 1;
                UInt32 FT_PURGE_TX = 2;
    
                FT_STATUS ftStatus = FT_STATUS.FT_OK;
                //Reset device
                ftStatus = PFTDI.ResetDevice();
             if (ftStatus != FT_STATUS.FT_OK)
                {
                    Disconnect();
                    throw new EUSBGeckoException(EUSBErrorCode.FTDIResetError);
                }
                //Purge RX buffers
                ftStatus = PFTDI.Purge(FT_PURGE_RX);
            if (ftStatus != FT_STATUS.FT_OK)
                {
                    Disconnect();
                    throw new EUSBGeckoException(EUSBErrorCode.FTDIPurgeRxError);
                }
                //Purge TX buffers
                ftStatus = PFTDI.Purge(FT_PURGE_TX);
           if (ftStatus != FT_STATUS.FT_OK)
                {
                    Disconnect();
                    throw new EUSBGeckoException(EUSBErrorCode.FTDIPurgeTxError);
                }
    
                return true;
            }
    
    From the wiibrew link above, not a full breakdown but a decent start
     
  3. gudenau
    OP

    gudenau Largely ignored

    Member
    GBAtemp Patron
    gudenau is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    3,301
    1,253
    Jul 7, 2010
    United States
    /dev/random
    I got that stuff, I am trying to use read block command, but all I get back is ACKs.