In memory of Ben “bushing” Byer, who passed away on Monday, February 8th, 2016.

Difference between revisions of "USB Gecko"

From WiiBrew
Jump to navigation Jump to search
m (UsbGecko moved to USB Gecko: proper name)
m
Line 1: Line 1:
The USB Gecko is a Wii/Gamecube development and hacking tool which connects to the USB port of the computer, and to the gamecube memory slot of the Wii.  It can be used to upload homebrew, to use your computer as a remote terminal under [[Homebrew_apps/Wii_Linux|Wii Linux]] and as a [[Debugging|remote debugging]] tool.  For more information see the [http://www.usbgecko.com USB Gecko homepage].
+
The '''USB Gecko''' is a Wii/Gamecube development and hacking tool which connects to the USB port of the computer, and to the GameCube memory slot of the Wii.  It can be used to upload homebrew, to use your computer as a remote terminal under [[Homebrew_apps/Wii_Linux|Wii Linux]] and as a [[Debugging|remote debugging]] tool.  For more information see the [http://www.usbgecko.com USB Gecko homepage].
  
 
To code computer side usbgecko application you need :  
 
To code computer side usbgecko application you need :  
Line 8: Line 8:
  
  
I have started a linux application, all seems ok, except the ftdi_read_data that always return 0 :/
+
I have started a Linux application, all seems ok, except the ftdi_read_data that always return 0 :/
For those who interrested this page can be a base to make a usable application.
+
For those who interested this page can be a base to make a usable application.
  
 
<source lang="c">
 
<source lang="c">

Revision as of 05:42, 25 September 2008

The USB Gecko is a Wii/Gamecube development and hacking tool which connects to the USB port of the computer, and to the GameCube memory slot of the Wii. It can be used to upload homebrew, to use your computer as a remote terminal under Wii Linux and as a remote debugging tool. For more information see the USB Gecko homepage.

To code computer side usbgecko application you need :


I have started a Linux application, all seems ok, except the ftdi_read_data that always return 0 :/ For those who interested this page can be a base to make a usable application.

#include <stdio.h>
#include <sys/types.h>
#include <ftdi.h> 
 
 //--------------------------  Globals ----------------------------------
 int32_t status;
 int ret;
 int32_t TxSent;
 int32_t RxSent;
 
 struct ftdi_context ftdic;
 
 int cmd_readmem = 0x04;
 //--------------------------  Function Prototypes ----------------------------------
 void gecko_opendevice(); 
 
 
 
 
 int main(int argc, char **argv)
 {
 	void* plop; 
 	unsigned char responseback = 0;
 
 	ftdi_init(&ftdic);
 
 
 	printf("-----------------------------------\n");
 	printf("- NoNameNo's UsbGecko Linux Tools -\n");
 	printf("-----------------------------------\n\n");
 
 	gecko_opendevice();
 	printf("Connecting to Wii.\n");
 	printf("%x\n",gecko_writebyte(&cmd_readmem,1));
 	printf("%x\n",gecko_readbyte(&responseback, 1));
 	ftdi_usb_close(&ftdic);
 	ftdi_deinit(&ftdic);
 
 	return EXIT_SUCCESS;
 }
 //----------------------------------------------------------------------------------------------------
 //----------------------------------------------------------------------------------------------------
 //----------------------------------------------------------------------------------------------------
 int gecko_readbyte(unsigned char* lpBuffer, int dwBytesToRead)
 {
 	status = ftdi_read_data(&ftdic, lpBuffer, dwBytesToRead);
 	
 	if (status > 0){
 		if(status != dwBytesToRead){
 			return 2;
 		}
 	}
 	else{
 		printf("[Error] UsbGecko Reading Device\n");
 		//ftdi_usb_close(&ftdic);
 		//ftdi_deinit(&ftdic);
 		return status;
 	}
 		
 	return 1;
 }
 
 //----------------------------------------------------------------------------------------------------
 //----------------------------------------------------------------------------------------------------
 //----------------------------------------------------------------------------------------------------
 int gecko_writebyte(unsigned char* lpBuffer, int dwBytesToWrite)
 {
 	status = ftdi_write_data(&ftdic, lpBuffer, dwBytesToWrite);
 	
 	if (status > 0){
 		if(status != dwBytesToWrite){
 			return 2;
 		}
 	}
 	else{
 		printf("[Error] UsbGecko Writing Device\n");
 		ftdi_usb_close(&ftdic);
 		ftdi_deinit(&ftdic);
 		return 0;
 	}
 		
 	return 1;
 } 
  
 
 
 //----------------------------------------------------------------------------------------------------
 //----------------------------------------------------------------------------------------------------
 //----------------------------------------------------------------------------------------------------
 void gecko_opendevice()
 {
 //---------------------------open device --------------------------------------
 	if((ret = ftdi_usb_open(&ftdic, 0x0403, 0x6001)) < 0) {
 		printf("[Error] UsbGecko NOT Detected\n");
 		exit(0);
 	}
 	else{   
 		printf("[OK] UsbGecko Detected\n");
 	}
 
 
 //---------------------------Reset device --------------------------------------
 	if((ret = ftdi_usb_reset(&ftdic)) < 0) {
 		printf("[Error] UsbGecko Reseting Device \n");
 		ftdi_usb_close(&ftdic);
 		ftdi_deinit(&ftdic);
 		exit(0);
 	}
 	else{   
 		printf("[OK] UsbGecko Reseted\n");
 	}
 
 
 //---------------------------SetTimeOut to 2000 --------------------------------------
 	ftdic.usb_read_timeout=2000;
 	ftdic.usb_write_timeout=2000;
 	printf("[OK] UsbGecko Setted 2 sec timout\n");
 
 //---------------------------Purging RX/TX buffers --------------------------------------
 	if((ret = ftdi_usb_purge_buffers(&ftdic)) < 0) {
 		printf("[Error] UsbGecko Purging Buffer \n");
 		ftdi_usb_close(&ftdic);
 		ftdi_deinit(&ftdic);
 		exit(0);
 	}
 	else{   
 		printf("[OK] UsbGecko Purged RX/TX buffers\n");
 	}
 
 
 
 //--------------------------- Set RX/TX size buffer --------------------------------------
 	if((ret = ftdi_read_data_set_chunksize(&ftdic,65536)) < 0) {
 		printf("[Error] UsbGecko Setting RX buffer size\n");
 		ftdi_usb_close(&ftdic);
 		ftdi_deinit(&ftdic);
 		exit(0);
 	}
 	else{   
 		printf("[OK] UsbGecko Setted RX Buffer Size\n");
 	}
 	if((ret = ftdi_write_data_set_chunksize(&ftdic,65536)) < 0) {
 		printf("[Error] UsbGecko Setting TX Buffer size\n");
 		ftdi_usb_close(&ftdic);
 		ftdi_deinit(&ftdic);
 		exit(0);
 	}
 	else{   
 		printf("[OK] UsbGecko Setted TX Buffer Size\n");
 	}
 
 
 //---------------------------Required ???  --------------------------------------
 	sleep(1);
 
 }