Skip to content


RedOctane X-plorer on Ubuntu 7.10 (Gutsy)

In my current state of addiction I’ve been rocking out with my plastic guitar with the 5 brightly colored buttons. Guitar Hero 3 has been causing me to procrastinate a lot more over the last month than usual. It wasn’t until about a week ago that I found out about Frets on Fire. It is a guitar hero like game that you play using your keyboard (created in Python). You can create your own songs to play and even import the songs from the first three Guitar Hero games. After playing it for a while I wanted to use my GH3 guitar but I wasn’t sure if I could even do that. It turns out that yes, you can use the guitar under Linux and even Windows.

I decided to use my laptop which has Ubuntu 7.10 (Gutsy) on it and compile the module. You are going to need a to create a Makefile inside the xpad360 directory.

obj-m := xpad.o
KDIR := /lib/modules/$(shell uname -r)/build
EXTRA_CFLAGS=-I$(shell pwd)

all:
        $(MAKE) modules -C $(KDIR) SUBDIRS=$(shell pwd)
install:
        mv -f xpad.ko /lib/modules/$(shell uname -r)/kernel/drivers/input/joystick

You can use the following instructions to get the latest CVS version installed.

sudo apt-get install build-essential linux-headers-generic
mkdir xpad360
cd xpad360
wget 'http://xbox-linux.cvs.sourceforge.net/*checkout*/xbox-linux/kernel-2.6/drivers/usb/input/xpad.c'
wget 'http://xbox-linux.cvs.sourceforge.net/*checkout*/xbox-linux/kernel-2.6/drivers/usb/input/xpad.h'
make
sudo make install
sudo depmod
sudo modprobe xpad

You might have seen posts on Ubuntu’s forums telling you to run “update-modules”, this command is obsolete and does nothing. After that then you can insert the guitar into any USB port. Then run “dmesg” to see if everything went well. At this point you should have a device “/dev/input/js0″. You might also notice that the module has caused an “oops”. Now the module won’t unload until you reboot your PC. Lets look at the output from dmesg.

Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000] BUG: unable to handle kernel NULL pointer dereference at virtual address 00000006
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000]  printing eip:
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000] f8c73a26
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000] *pde = 00000000
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000] Oops: 0000 [#1]
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000] SMP
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000] Modules linked in: xpad usbhid hid af_packet rfcomm l2cap bluetooth ppdev ipv6 snd_atiixp_modem snd_via82xx_modem snd_intel8x0m acpi_cpufreq cpufreq_powersave cpufreq_ondemand cpufreq_conservative cpufreq_stats freq_table cpufreq_userspace dock button ac video battery container sbs sbp2 parport_pc lp parport snd_intel8x0 snd_ac97_codec ac97_bus snd_pcm_oss snd_mixer_oss snd_pcm snd_seq_dummy snd_seq_oss pcmcia snd_seq_midi snd_rawmidi joydev snd_seq_midi_event sdhci snd_seq snd_timer snd_seq_device ipw2200 mmc_core yenta_socket rsrc_nonstatic pcspkr ieee80211 ieee80211_crypt iTCO_wdt iTCO_vendor_support snd soundcore snd_page_alloc serio_raw psmouse pcmcia_core nvidia(P) i2c_core intel_agp agpgart shpchp pci_hotplug evdev ext3 jbd mbcache sg sr_mod cdrom sd_mod ata_generic ata_piix ahci libata scsi_mod ohci1394 ieee1394 tg3 ehci_hcd uhci_hcd usbcore thermal processor fan fuse apparmor commoncap
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000] CPU:    0
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000] EIP:    0060:[f8c73a26]    Tainted: P       VLI
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000] EFLAGS: 00010286   (2.6.22-14-generic #1)
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000] EIP is at xpad_probe+0x216/0x4b0 [xpad]
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000] eax: f2a66680   ebx: 00800000   ecx: f25cd000   edx: 00000000
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000] esi: 0000000e   edi: e73f7800   ebp: e042c800   esp: dfb81ce8
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000] ds: 007b   es: 007b   fs: 00d8  gs: 0000  ss: 0068
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000] Process khubd (pid: 1977, ti=dfb80000 task=df88e000 task.ti=dfb80000)
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000] Stack: f2a66694 00000041 f8c742f8 c1957d00 e73f7804 f25cd000 02c75584 f2a66680
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000]        f8c75584 f25cd000 00000000 f25cd000 f8c75584 f8c75440 f8882f66 e73f7800
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000]        f25cd018 00000000 f8c75470 f25cd0d0 c02611ae dfb81d60 c02f1793 00000000
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000] Call Trace:
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000]  [f8882f66] usb_probe_interface+0x96/0xe0 [usbcore]
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000]  [driver_probe_device+142/400] driver_probe_device+0x8e/0x190
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000]  [klist_next+83/160] klist_next+0x53/0xa0
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000]  [bus_for_each_drv+68/112] bus_for_each_drv+0x44/0x70
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000]  [device_attach+134/144] device_attach+0x86/0x90
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000]  [__device_attach+0/16] __device_attach+0x0/0x10
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000]  [bus_attach_device+77/160] bus_attach_device+0x4d/0xa0
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000]  [bus_add_device+297/352] bus_add_device+0x129/0x160
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000]  [device_add+1183/1392] device_add+0x49f/0x570
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000]  [f8880f22] usb_set_configuration+0x2a2/0x4f0 [usbcore]
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000]  [f8888e1d] generic_probe+0x16d/0x250 [usbcore]
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000]  [f8882c33] usb_probe_device+0x33/0x40 [usbcore]
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000]  [driver_probe_device+142/400] driver_probe_device+0x8e/0x190
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000]  [klist_next+83/160] klist_next+0x53/0xa0
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000]  [bus_for_each_drv+68/112] bus_for_each_drv+0x44/0x70
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000]  [device_attach+134/144] device_attach+0x86/0x90
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000]  [__device_attach+0/16] __device_attach+0x0/0x10
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000]  [bus_attach_device+77/160] bus_attach_device+0x4d/0xa0
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000]  [bus_add_device+297/352] bus_add_device+0x129/0x160
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000]  [device_add+1183/1392] device_add+0x49f/0x570
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000]  [f887c28d] usb_new_device+0x8d/0x110 [usbcore]
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000]  [f887cf6e] hub_thread+0x78e/0xc30 [usbcore]
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000]  [schedule+714/2192] schedule+0x2ca/0x890
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000]  [autoremove_wake_function+0/80] autoremove_wake_function+0x0/0x50
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000]  [f887c7e0] hub_thread+0x0/0xc30 [usbcore]
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000]  [kthread+66/112] kthread+0x42/0x70
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000]  [kthread+0/112] kthread+0x0/0x70
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000]  [kernel_thread_helper+7/16] kernel_thread_helper+0x7/0x10
Mar  1 00:34:25 laptop-ubuntu kernel: [  398.372000]  =======================

Looks like the offending function is xpad_probe which at some point accesses a null pointer. Further debugging reveals this offending code.

ep_irq_in = &intf->cur_altsetting->endpoint[0].desc;
usb_fill_int_urb(xpad->irq_in, udev,
                         usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress),
                         xpad->idata, XPAD_PKT_LEN, xpad_irq_in,
                         xpad, ep_irq_in->bInterval);

For some reason on the fourth probe “ep_irc_in” is null because it doesn’t have an endpoint (not a kernel guy, so that might be an incorrect assumption/terminology). If I add a check to see if the pointer is null before accessing it the module will load sorta correctly. When it fails I have it goto some cleanup code which tells me that the module didn’t load for that device. So I did some more poking around and figured this might be a good time to learn more about the kernel and modules. After hours of searching I didn’t find out anything new about why it would be null. If anyone is in the know in regards to the USB subsystem, kernel or the modules and can provide more information I would like to know. I ended up fixing the module by making a new controller type. When the controller type is being used during the probe it only creates a single device. There are 3 others including the one that caused the oops. I’m not sure what the other two are but they aren’t needed to be used as a joystick. The module correctly loads and unloads now. You can find the source code with the makefile here.

Posted in Kernel, Linux.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.