cIOS usb2/es

From WiiBrew

Jump to: navigation, search

cIOS usb2
File:USB2.png
General
Author(s)Kwiirk
TypeSystem tool
Versionbeta3
Links
Download
Peripherals
1 Wiimote


cIOS usb2 beta3 por kwiirk

Contents

Descripción

Este programa es una modificación del modulo custom ios de neimod, la aplicación de un usb2 (ehci) driver en el sitio de legalidad OH0 y OH1 módulos.

Básicamente, este habilita los dispositivos USB 2.0 para cargar a velocidad completa USB 2.0 . Antes, sólo permitían velocidades de USB 1.1 .

El "sources" contienen también varias herramientas para ayudar al ioshacker. Usar con cuidado. Una copia modificada de libfat muestra a los desarrolladores un camino simple para usar la velocidad completa de un USB con sus aplicaciones, manteniendo el usb1 trabajando si el cios_usb2 no está instalado.

Responsabilidad

Este software está en fase beta y no está mayoritariamente testado, pero está preparado para funcionar en el sistema wii del autor. Los daños físicos en tu disco duro son posibles debido a el estado de "inmadurez" del código. Los daños en los datos de tu disco duro son muy posibles. Ver la parte "NO WARANTY" (NO GARANTÍA) de la licencia GPL.

Por favor, no utilizar este software para propositos ilegales.

Cambios beta3

  • Mejora de la fiabilidad del driver usbstorage. Este ahora reiniciara el driver si empieza a provocar errores.

Cambios beta2

  • Añadido un módulo ehc custom que implementa la standard ios usb API bajo /dev/usb/ehc, plus custom

usbstorage direct api.

  • Restaurado el módulo de legalidad oh0 de nintendo. Los dispositivos externos USB1.1 serán cargados por este módulo.
  • Cambiado el orden del módulo cargando in order para asegurarnos de que el código de inicio EHCI cargue antes del OH1, ahora el bluetooth seguramente trabajará "reliabily".
  • Añadido libfat w/ read_ahead y USBspeedTest, cortesía de rodries, del equipo mplayer-ce.

Cambios beta1

  • Añadido libcios, a fin de evitar la duplicación del código (source) entre los módulos y iostester.
  • Corregidos diversos errores en el código original (stack address pointed to the begginning of actual memory allocation, but needed to be at the end.)
  • Añadido tinyehci, un mínimo driver génerico ehci basado en linux driver ehci-hcd.
  • Añadido el módulo oh0, el cual implementa los mensajes oh0 ios con tinyehci, y nuevos mensajes usbstorage para una mejor velocidad.
  • Añadido patchmii installer.

Explicación

usb-hcd knowledge La CPU de la Wii usa un alto nivel de interfaz para acceder a los dispositivos USB. Esta API no sabe sobre el USB2.0 o el USB1.1, estaba diseñada para enviar mensajes de control y mensajes "bulk".

El IOS original de la Wii implementa esta interfaz con un driver OHCI en el módulo OH0. Este es el por qué un Wii sin modificar está limitada al USB1.1.

Lo extraño sobre la IOS es que tienen 2 OHCI drivers, para hacer frente a cada uno de los 2 módulos OHCI HW. El OH0 está conectado a los puertos externos, y OH1 está conectado con el puerto inerno uno (que luego se conecta a la controladora Bluetooth).

Estos dos módulos OH parecen tener duplicado la mallor parte del código. la diferencia está seguramente en su nivel de optimización. OH1 no puede soportar los centros "hotplug".

La idea el que nosotros podemos añadir otro módulo que estará en el espacio libre del IOS y en el que implementar nuestro driver ehci. Este módulo se iniciaba antes en OH0, y OH1, por eso este puede actualizar/liberar los puertos USB, que no es USB2, o que queremos ser gestionados por código (bluetooth dongle).

La beta1 hack original, lleva aplicado un módulo ehci en el sirio del módulo oh0, que conoce el usb1 externo que estaba desactivado, pero el viejo código libogc correrá "fuera de la caja", el código homebrew podía comunicarse con el it talk usb1 bign driver pero actualmente se comunica con el código del usb2 homebrew.

Ahora, con beta2 y en adelante, me figuré el cómo añadir módulos en la TMD, y cómo puedo encontrar un espacio libre de memoria RAM para ellos (ver fuentes). El oh0 original está retrasado, de modo que el código homebrew tiene que saber que hay una nueva interfaz /dev/usb/ehc que puede como si fuera usual con el API.

Limitaciónes del Driver

  • The lack of a real usb stack means the driver lacks usb2 hub support. The USB2 hubs "TT" mechanism is a bit complicated, and would need a lot more work.
  • The driver doesn't implement the scheduled pipes, ie interrupt and isochronous pipes, which would be

needed for highend webcams (I cannot think of other usb2 devices type that uses such pipes.)

  • The driver does not implement hotplug detection. Plug your usb2 devices before launching an

application using ios 202, and it will be recognised as usb2, else, it will be recognised by usb1 driver.

Instrucciones de Uso

  • install the cios_usb2 with cios_usb2_install.dol
 note: unplug any device you may have inserted in the gamecube memory card slots prior to running the installer.
  • Plug your usb key into wii external port (for HW modders, this should actually also work with the unused internal port if the pins are present on the PCB..)
    • test it with raw_speed_test.elf or fat_speed_test.dol
    • or launch a usb2 aware application
  • If your usb2 device is connected before application launch, then it will be recognised as

usb2. Else, it will be recognised as usb1.

  • if you connect a usb1 device at anytime, it will be recognised as usb1 by OH0 module.

Instrucciones de Uso para los Programadores

the cios_usb2 is compatible with libogc, you just have to do:

IOS_ReloadIOS(202);

at the very begginning of a program to use this ios.

usbstorage_starlet.c

is present in a modified libfat, which allows libfat to directly use cios_usb2 mass storage API for better performance (3 times less ios ioctls). This modified libfat adds in disc.c a usb2:/ devices which allows to access usb2 discs, and keeps usb:/ for legacy usb access, in case cios_usb2 is not installed.


License

This program is free software. You are allowed and encouraged to use/change it for your homebrew hacks, even if you only release it when done, as soon as you repect the GPL. ;-)

Linux

to use it on linux, you must recompile the kernel after modifying the file

starlet_es.c:
#define STARLET_ES_IOS_MAX 202

The linux driver is a nice hack that uses the IOS OH0 API to implement a hcd driver. This breaks the software layers rules but this works. As cios_usb2 implements the exact same API (except for possible implementation bugs) linux driver should work just by telling him there is a new usb device tree available:

diff --git a/rvl-sthcd.c b/rvl-sthcd.c
index 4c117e8..cc4e821 100644
--- a/rvl-sthcd.c
+++ b/rvl-sthcd.c
@@ -160,7 +160,7 @@ struct sthcd_oh {
 struct sthcd_hcd {
        spinlock_t lock;
 
-       struct sthcd_oh oh[2];
+       struct sthcd_oh oh[3];
 
        struct sthcd_port *ports;       /* array of ports */
        unsigned int nr_ports;
@@ -1257,8 +1257,11 @@ static int sthcd_udev_open(struct sthcd_udev *udev)
                sthcd_udev_close(udev);
        }
 
-       snprintf(pathname, sizeof(pathname), "/dev/usb/oh%u/%04x/%04x",
-                oh->index, udev->idVendor, udev->idProduct);
+       if(oh->index==2)
+               snprintf(pathname, sizeof(pathname), "/dev/usb/ehc/%04x/%04x", , udev->idVendor, udev->idProduct);
+       else
+               snprintf(pathname, sizeof(pathname), "/dev/usb/oh%u/%04x/%04x",
+                       oh->index, udev->idVendor, udev->idProduct);
        error = starlet_open(pathname, 0);
        if (error < 0) {
                drv_printk(KERN_ERR, "open %s failed\n", pathname);
@@ -1980,10 +1983,12 @@ static int sthcd_oh_init(struct sthcd_oh *oh, unsigned int index,
        char pathname[16];
        int error;
 
-       if (index != 0 && index != 1)
+       if (index != 0 && index != 1 && index != 2)
                return -EINVAL;
-
-       snprintf(pathname, sizeof(pathname), "/dev/usb/oh%u", index);
+       if(index==2)
+               snprintf(pathname, sizeof(pathname), "/dev/usb/ehc");
+       else
+               snprintf(pathname, sizeof(pathname), "/dev/usb/oh%u", index);
        error = starlet_open(pathname, 0);
        if (error < 0)
                return error;
@@ -2025,8 +2030,9 @@ static int sthcd_rescan_thread(void *arg)
         * We may need to rescan oh1 if bluetooth dongle disconnects.
         */
 
-       /* oh1 has non-removable devices only, so just scan it once */
+       /* oh1 and ehc has non-removable devices only, so just scan it once */
        sthcd_oh_rescan(&sthcd->oh[1]);
+       sthcd_oh_rescan(&sthcd->oh[2]);
 
        oh = &sthcd->oh[0];
 
@@ -2064,6 +2070,12 @@ static int sthcd_start(struct usb_hcd *hcd)
 
        hcd->uses_new_polling = 1;
 
+       /* ehc is the external usb2 bus */
+       error = sthcd_oh_init(&sthcd->oh[2], 2, sthcd, STHCD_MAX_DEVIDS);
+       if (error < 0) {
+               DBG("%s: error=%d (%x)\n", __func__, error, error);
+               return error;
+       }
        /* oh0 is the external bus */
        error = sthcd_oh_init(&sthcd->oh[0], 0, sthcd, STHCD_MAX_DEVIDS);
        if (error < 0) {
@@ -2101,6 +2113,7 @@ static void sthcd_stop(struct usb_hcd *hcd)
 
        sthcd_oh_exit(&sthcd->oh[0]);
        sthcd_oh_exit(&sthcd->oh[1]);
+       sthcd_oh_exit(&sthcd->oh[2]);
 
        hcd->state &= ~HC_STATE_RUNNING;
 }

This is not tested for now, please report bugs..


todo

  • Performances are still limited to 4MB/s on a HD which can do up can do up to 30MB/s with dd on linux/x86.
  • compatibility: I got one lowend USB key, which doesn't work (stalled at the first bulk message)
  • more testing is needed, but for now it seems more stable than nintendo's oh0 driver (which crashed when doing a performance test..)

Thanks

Thanks to the helpful wii homebrew and open-source community, especially those who write code cios_usb2 is based on. (see source code)

Personal tools
Resources
Community
In other languages