https://github.com/prdktntwcklr/bootlin-nunchuk
Nunchuk Linux kernel module from Bootlin course.
https://github.com/prdktntwcklr/bootlin-nunchuk
bootlin i2c kernel-module linux nintendo nunchuk
Last synced: about 1 month ago
JSON representation
Nunchuk Linux kernel module from Bootlin course.
- Host: GitHub
- URL: https://github.com/prdktntwcklr/bootlin-nunchuk
- Owner: prdktntwcklr
- Created: 2023-06-23T11:06:38.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-02-14T09:28:06.000Z (over 2 years ago)
- Last Synced: 2025-01-14T02:12:58.448Z (over 1 year ago)
- Topics: bootlin, i2c, kernel-module, linux, nintendo, nunchuk
- Language: C
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Nunchuk Driver
A sample Linux I2C driver for the [Nintendo Wii Nunchuk](https://www.nintendo.co.jp/support/manual/wiiu/accessories/pdf/MAA-RVL-A-F-JPN.pdf) (RVL-004). The driver supports the following inputs using the input subsystem:
- Z Button
- C Button
- Joystick (X and Y)
This project is based on Bootlin's embedded Linux trainings (see `References` section below).
Tested on [BeagleBone Black](https://beagleboard.org/black) hardware running mainline Linux version 5.10.179.
## Hardware
- BeagleBone Black
- Nintendo Wii Nunchuk
- [UEXT connector for Wii Nunchuck](https://www.olimex.com/Products/Modules/Sensors/MOD-WII/MOD-WII-UEXT/open-source-hardware)
## Building the kernel module
To cross-compile, run the following command (using a cross-compiling toolchain provided by Ubuntu as an example):
```bash
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-
```
## Device Tree
To enable Nunchuk functionality on your board, add the following entry to the device tree:
```dts
&i2c1 {
pinctrl-names = "default";
pinctrl-0 = <&i2c1_pins>;
status = "okay";
clock-frequency = <100000>;
joystick@52 {
compatible = "nintendo,nunchuk";
reg = <0x52>;
};
};
```
## Nunchuk
Connect the Nunchuk to the I2C1 bus of the BeagleBone Black board (pins 17 and 18 of P9, see [pinout](https://docs.beagleboard.org/latest/boards/beaglebone/black/ch07.html#connector-p9)). The Nunchuk should show up at address 0x52:
```text
$ sudo i2cdetect -r 1
i2cdetect: WARNING! This program can confuse your I2C bus
Continue? [y/N] y
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- 52 -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
```
Load the kernel module to verify the driver finds the device:
```bash
$ sudo modprobe nunchuk
```
Finally, run the `evtest` application to test the inputs:
```bash
$ sudo evtest
```
## References
- Bootlin: [Embedded Linux kernel and driver development training](https://bootlin.com/training/kernel/).