From gc-linux

Jump to: navigation, search



The Nintendo Wii console includes a number of General Purpose IO pins. Some of them are used, for example, to control the sensor bar IR leds, the front blue led and the eject mechanism of the disc unit.

The starlet-gpio kernel driver

Our kernel includes a Linux GPIOLIB based driver called starlet-gpio that allows the use of the Nintendo Wii GPIOs both from userspace and kernelspace.

Each configured GPIO has a unique ID assigned by the kernel.

The default supplied device-tree for the Nintendo Wii gives access to the 32 GPIOs available at 0x0D8000C0, as follows:

224 31
225 30
226 29
... ..
253 2
254 1
255 0

Some of the relevant GPIOs are:

  • 246, eject (0x00000200)
  • 247, sendor bar (0x00000100)
  • 250, front blue led (0x00000020)

How to use GPIOs from userspace

GPIOs are managed from userspace via the /sys filesystem.

1. First, you need to export the GPIO to userspace.

For example, this command exports GPIO 250 to userspace:

 $ echo 250 | sudo tee /sys/class/gpio/export > /dev/null

2. Second, you need to setup the GPIO direction {in, out}.

For example, this command setups GPIO 250 for output:

 $ echo out | sudo tee /sys/class/gpio/gpio250/direction > /dev/null

3. Now, you can use the GPIO as previously configured.

For example, this command turns on GPIO 250, which in fact turns on the front blue led:

 $ echo 1 | sudo tee /sys/class/gpio/gpio250/value > /dev/null

And this one will turn it off:

 $ echo 0 | sudo tee /sys/class/gpio/gpio250/value > /dev/null

4. If you don't need the GPIO anymore, you can return it to the kernel by unexporting it.

For example, this command unexports GPIO 250, making it unavailable to userspace:

 $ echo 250 | sudo tee /sys/class/gpio/unexport > /dev/null

Aditional Information

Please, have a look at the kernel documentation


Personal tools