[HowTo] Scripts for using Xbox Controller in RetrOSMC

Your real problem is:

open("/dev/bus/usb/001/004", O_RDWR)    = -1 EACCES (Permission denied)

You shouldn’t have this problem with sudo though. What does ls -l /dev/bus/usb/001 show. You can also try chown -R osmc:osmc this path. If that works, then we need to set up a udev rule.

futex() is just a fast (userspace mutex) implementation. It locks until it gets access to a resource.

Edit: also check xpad stuff definitely isn’t loading with lsmod

The USB device belonged to root:

osmc@RASPI2:~$ ls -l /dev/bus/usb/001
total 0
crw-rw-r-- 1 root root 189, 0 Aug 18 13:51 001
crw-rw-r-- 1 root root 189, 1 Aug 18 13:51 002
crw-rw-r-- 1 root root 189, 2 Aug 18 13:51 003
crw-rw-r-- 1 root root 189, 3 Aug 18 13:52 004

so I changed its ownership by sudo chown -R osmc:osmc /dev/bus/usb/001 as you suggested. xpad is definitely not loaded, it never shows up in lsmod, neither when working nor when not-working:

Output of lsmod
osmc@RASPI2:~$ lsmod
Module                  Size  Used by
8021q                  22147  0
garp                    7622  1 8021q
stp                     2430  1 garp
llc                     6031  2 stp,garp
joydev                  9585  0
evdev                  13192  2
uinput                  9818  2
snd_bcm2835            24938  0
snd_pcm               115812  1 snd_bcm2835
snd_timer              25966  1 snd_pcm
snd                    78512  3 snd_bcm2835,snd_timer,snd_pcm
bcm2835_gpiomem         4026  0
bcm2835_thermal         2541  0
bcm2835_wdt             4081  0
lirc_rpi                9315  3
lirc_dev               11576  1 lirc_rpi
rc_core                25745  1 lirc_dev
uio_pdrv_genirq         3885  0
uio                    10428  1 uio_pdrv_genirq
fuse                  107913  1
ipv6                  447942  42

Here’s a log after the ownership change and when working. A little different, now the old

write(1, " Error couldn’t claim the USB in"…, 59 Error couldn’t claim the USB interface: LIBUSB_ERROR_BUSY
) = 59
write(1, “Try to run ‘rmmod xpad’ and then”…, 104Try to run ‘rmmod xpad’ and then xboxdrv again or start xboxdrv with the option --detach-kernel-driver.
) = 104

turns up again in the last lines. xpad isn’t loaded then, either, I checked again via lsmod.

ioctl(12, USBDEVFS_CLAIMINTERFACE, 0x7e95e08c) = -1 EBUSY (Device or resource busy)

Something is holding the device. You don’t have xboxdrv running as a daemon (systemd or init.d service) do you?

Nope, no -D or --deamon option, neither in /home/osmc/start.sh, /home/osmc/xbmc.ini or /etc/rc.local. Just as in step 2 of Yggdrasil’s initial post. Also deleted the /home/osmc/buttonswap.ini because it has [xboxdrv-daemon] in it, although I had no call to it at this point, just to make sure. No change in behaviour.

Without the hardware, I am not sure, sorry. I would try building a kernel without xpad module

I’m actually playing around with the idea of sending you a 360 wireless controller via [amazon.co.uk] (https://www.amazon.co.uk/Official-Xbox-Wireless-Controller-Windows/dp/B004JU0JSA/). :smiley: If you’d like to, I’d be happy to contribute to the project in this way. Please PM me the address to which to ship (the address given here also turns up on an internet fraud site, so I’d like to play it safe).

As for kernel building: Does this post by DBMandrake contain everything needed, or is there anything else I need to prepare, know, read besides the development entries in the wiki?

I have a Wired Xbox 360 Controller. If you have a wired one and can replicate the problem with that I can try and look at this.

Hehe. I formed the company using a website that does it all for you and they set up a mail forwarding address for anonymity. I need to update that as we have an actual office now.

Hold off for now on spending money, because even if I get one, I may not necessarily be able to fix the problem.

That’s it. But you want to disable the xpad modules from being built, so you need to check for CONFIG_XPAD (may not be exact option name) in patches/rbp2-000-add-kernel-config.patch and remove it. Ideally you want to set to IS NOT SET or use make menuconfig to properly generate the kernel configuration.

Then sudo dpkg -i rbp2-image… after.

Unfortunately it’s the wireless version and I don’t own the cable to turn it into a wired one.

Ah, that’s why! And congratulations on the office! :slight_smile:
Anyway, donating via Paypal/Bitcoin/Flattr is always open and I’ll just use this instead.

Okay, will do so! This will be interesting.

Again, thanks for your help! And keep OSMC as awesome as it its :slight_smile:

Thanks :slight_smile:

Let me know how you get on. You should find the build process relatively hands-off. Make sure you have a few GB free on the SD card (as the kernel is a large package)

Sam

osmc@RASPI2:~$ uname -a
Linux RASPI2 4.4.16-1-osmc #1 SMP PREEMPT Thu Aug 18 16:30:00 UTC 2016 armv7l GNU/Linux

It took nearly five hours to build, but at least I built my first (custom) kernel, yay. :smiley: Btw, it worked with an 8 GB µSD card that contained nothing but OSMC.
Before I started building, I edited the /home/osmc/osmc/package/kernel-osmc/patches/rbp2-000-add-kernel-config.patch to contain

+CONFIG_JOYSTICK_XPAD is not set
+CONFIG_JOYSTICK_XPAD_FF is not set

During building some y/n/m questions came up for including stuff into the kernel, I answered n to CONFIG_JOYSTICK_XPAD and CONFIG_JOYSTICK_XPAD_FF. Also about six questions about sound broadcom thingie (unfortunately didn’t take screenhots) to which I replied n as well.
sudo dpkg -i rbp2-image-4.4.16-1-osmc.deb, edited /etc/osmc/prefs.d/update_preferences, removed the sudo rmmod xpad line from /home/osmc/start.sh, rebooted, tested controller.

Unfortunately it still doesn’t work reliably. All tests/methods from the last ten posts above showed the same behaviour and error messages.
Now it might be imagination, but with the new kernel it worked in 4/5 cases. What also changed was the LED behaviour; now flashing always means working, and staying lit in position 1 always means not working. This is strange, as this is exactly what the --led=2 in /home/osmc/start.sh tells it to do.

Therefore I still think it can’t be a problem in principle but has to do with the order or way the USB device is initialised. If this can be determined by syslogs or anything, I’m happy to provide them.

I’m also interested in a solution, please fix it :slight_smile:

Retropie 4.0 just released :

NOTE: Some people have been having trouble with the XBox/XBox 360 controller driver xboxdrv on the current Raspbian Kernel. To work around this we now include the latest xpad kernel driver with the image (it is available from the Packages -> Drivers menu for those upgrading). The included xpad has been patched to map the Xbox 360 triggers to buttons, so they work out of the box with Emulation Station, without the need for xboxdrv.

I’ve tried to install xpad but it ended up with could not install package : dkms raspberrypi-kernel-headers

We don’t use DKMS modules. If someone gets in touch with them and finds out where they sourced the updated kernel module from I will update our kernel.

Seems like the RetroPie guys are suggesting the kernel module is problematic. If this is the case I’m not sure why excluding it from the build as @RJ45 did doesn’t fix the problem.

I’ve asked for help on the retropie forum OSMC Xpad Support - RetroPie Forum.
Wait & see

From a retropie admin :

You may not want our xpad, as it may cause problems with Kodi on OSMC or other issues. We have some support for OSMC but I don’t think I can help get xpad working if they are managing their own kernels that won’t work with dkms.

The code is here

It’s this driver we are building - which contains newer xpad code than is in the currentl Raspbian 4.4 kernel - https://github.com/paroj/xpad.git

However due to problems with ES and the triggers, I have patched it so the triggers are forced to act as buttons (can be switched off via module param).

I need to know if this causes regressions, as this may have an impact on RetroPlayer in v18. I can backport the driver if someone is willing to give it a go.

It looks like there is a small downstream (RetroPie) patch, which is applied to the xpad.git tree which is based on the latest upstream kernel.

Sam

I’m willing to try but I’m not at home until wednesday. @RJ45 or @cibban can you try sooner ?

I have compile tested this only, so no guarantee if it will work:

I will now schedule builds on Jenkins and let you know when they are available.

Sam

I’m willing to test anything, although I managed to get the standard xpad driver to work reasonably good by simply removing all custom configs. It works ok with the autoconfig. I’m just not sure how to test it. All that git magic is fairly new to me so I’m still trying to wrap my head around it.

Hi

We are working our new build system, and it’s being given a small workout tonight which is delaying these builds.

No need to do anything with Git. When the new kernels for Pi 1 and Pi 2 are ready, I will give you clear instructions for how to try them.

Thanks

Sam