USBGecko/Linux

From WiiBrew
Jump to navigation Jump to search

Driver

The USBGecko is supported under Linux by the ftdi_sio driver

  1. Make sure to have support for USB 2.0 and USB Serial (usbserial) in your kernel, and have the USB 2.0 driver loaded (this will most likely be uhci-hcd)
  2. Connect the USBGecko
  3. If it loads successfully, a device (most likely /dev/ttyUSB0) will be created, and something like the following lines will appear in your kernel log (use dmesg to check it):
usb 2-1: new full speed USB device using uhci_hcd and address 2
usb 2-1: configuration #1 chosen from 1 choice
usbcore: registered new interface driver usbserial
/build/buildd/linux-source-2.6.22-2.6.22/drivers/usb/serial/usb-serial.c: USB Serial support registered for generic
usbcore: registered new interface driver usbserial_generic
/build/buildd/linux-source-2.6.22-2.6.22/drivers/usb/serial/usb-serial.c: USB Serial Driver core
/build/buildd/linux-source-2.6.22-2.6.22/drivers/usb/serial/usb-serial.c: USB Serial support registered for FTDI USB Serial Device
ftdi_sio 2-1:1.0: FTDI USB Serial Device converter detected
/build/buildd/linux-source-2.6.22-2.6.22/drivers/usb/serial/ftdi_sio.c: Detected FT232RL
usb 2-1: FTDI USB Serial Device converter now attached to ttyUSB0
usbcore: registered new interface driver ftdi_sio
/build/buildd/linux-source-2.6.22-2.6.22/drivers/usb/serial/ftdi_sio.c: v1.4.3:USB FTDI Serial Converters Driver

Remote Debugging

You can use the USBGecko in combination with gdb to do remote debugging. Currently you need libogc CVS for this to work.

  1. Include debug.h from libogc.
    #include <debug.h>
  2. Include a call to DEBUG_Init() in your code.
    This function takes 2 arguments. The first should be GDBSTUB_DEVICE_USB, and the second is the Gamecube Memory Card Port number (0 for A, 1 for B).
    Your code will most likely be:
    DEBUG_Init(GDBSTUB_DEVICE_USB, 1);
  3. Link libdb.
    Find the LIBS line in your Makefile. Add -ldb before -logc, as shown below:
    LIBS    :=      -ldb -logc -lm ...
  4. Start gdb from DevKitPro.
    Specify the elf file as the first argument.
    $ powerpc-gekko-gdb Tetris.elf
  5. Tell gdb to use the Gecko serial interface:
    (gdb) target remote /dev/ttyUSB0
    Alternatively, if you intend to use that PC for Wii debugging only, you can put the above command in ~/.gdbinit for automatic execution.

Quick gdb Reference

  • To display thread states:
    (gdb) info threads
  • To switch to thread X:
    (gdb) thread X
  • To show a stack backtrace of the current thread:
    (gdb) bt
  • To show a full stack backtrace of the current thread:
    (gdb) bt full
  • To show the disassembly at address 0xDEADBEEF:
    (gdb) disassemble 0xDEADBEEF

See the gdb documentation for more info.