GPIO Joystick raspberrypi-kernel-headers

Hi all,

I am trying to install a driver called mkarcadejoystick, a retrosmc driver to use a Arcade Controller over GPIO. But two packages were missing: dkms, raspberrypi-kernel-headers.
I installed dkms, but i couldnt find the linux headers for 4.4.27-9 osmc, i tried the deb package ‘rbp2-headers-4.4.27-9-osmc’ and the linux-headers-4.4.27-v7+_4.4.27-v7±2_armhf.deb but it doesnt solved the issue.

Someone could plz help me?

Try the source package.
It’s best not to use DKMS though and more ideal to get modules upstream

Sam what do you mean, with “try the source package”, because i am trying to compile, and i cant find these kernel headers?
I tried everything, like installing a older version of osmc, but i couldn’t solve this issue.

I downloaded the kernel source and made a link

sudo ln -s /usr/src/rbp2-source-4.4.27-9-osmc /lib/modules/4.4.27-9-osmc/build

So now i think i got one more step forward:
Running the following command to install from deb package:

osmc@osmc:~$ sudo dpkg -i mk-arcade-joystick-rpi-0.1.4.deb
(Reading database … 79813 files and directories currently insta> lled.)
Preparing to unpack mk-arcade-joystick-rpi-0.1.4.deb …

Deleting module version: 0.1.4
completely from the DKMS tree.

Unpacking mk-arcade-joystick-rpi-dkms (0.1.4) over (0.1.4) …
Setting up mk-arcade-joystick-rpi-dkms (0.1.4) …
Loading new mk_arcade_joystick_rpi-0.1.4 DKMS files…
First Installation: checking all kernels…
Building only for 4.4.27-9-osmc
Building for architecture armv7l
Building initial module for 4.4.27-9-osmc
Error! Bad return status for module build on kernel: 4.4.27-9-osmc (armv7l)
Consult /var/lib/dkms/mk_arcade_joystick_rpi/0.1.4/build/make.log for more information.

And the log report is:

osmc@osmc:~$ cat /var/lib/dkms/mk_arcade_joystick_rpi/0.1.4/build/make.log
DKMS make.log for mk_arcade_joystick_rpi-0.1.4 for kernel 4.4.27-9-osmc (armv7l)
Sun Mar 26 23:14:12 -03 2017
make -C /lib/modules/4.4.27-9-osmc/build M=/var/lib/dkms/mk_arcade_joystick_rpi/0.1.4/build modules
make[1]: Entering directory ‘/usr/src/rbp2-source-4.4.27-9-osmc’

ERROR: Kernel configuration is invalid.
include/generated/autoconf.h or include/config/auto.conf are missing.
Run ‘make oldconfig && make prepare’ on kernel src to fix it.

WARNING: Symbol version dump ./Module.symvers
is missing; modules will have no dependencies and modversions.

CC [M] /var/lib/dkms/mk_arcade_joystick_rpi/0.1.4/build/mk_arcade_joystick_rpi.o
In file included from :0:0:
././include/linux/kconfig.h:4:32: fatal error: generated/autoconf.h: No such file or directory
#include <generated/autoconf.h>
compilation terminated.
scripts/ recipe for target ‘/var/lib/dkms/mk_arcade_joystick_rpi/0.1.4/build/mk_arcade_joystick_rpi.o’ failed
make[2]: *** [/var/lib/dkms/mk_arcade_joystick_rpi/0.1.4/build/mk_arcade_joystick_rpi.o] Error 1
Makefile:1400: recipe for target ‘module/var/lib/dkms/mk_arcade_joystick_rpi/0.1.4/build’ failed
make[1]: *** [module/var/lib/dkms/mk_arcade_joystick_rpi/0.1.4/build] Error 2
make[1]: Leaving directory ‘/usr/src/rbp2-source-4.4.27-9-osmc’
Makefile:9: recipe for target ‘all’ failed
make: *** [all] Error 2

Any tips?
I i have to build the entire SO to have the correct /lib/module/‘uname -r’/build folder?

I (almost) solved this issue: (i can build now, but it doenst load )

install the kernel source:

sudo apt-get install rbp2-source-4.4.27-9-osmc

Link the src to the build folder

sudo ln -s /usr/src/rbp2-source-4.4.27-9-osmc /lib/modules/4.4.27-9-osmc/build

Go to the source folder and prepare for module build:

cd /usr/src/rbp2-source-4.4.27-9-osmc
sudo make modules_prepare

Download the deb package:


install package:

sudo dpkg -i mk-arcade-joystick-rpi-0.1.4.deb

But running:

sudo modprobe mk_arcade_joystick_rpi map=1,2
modprobe: ERROR: could not insert ‘mk_arcade_joystick_rpi’: Exec format error

someone could help me?

HI Sam, sorry but it doesn’t worked

I used the package source too:

git clone GitHub - recalbox/mk_arcade_joystick_rpi: Raspberry PI kernel module for arcade joystick on GPIO and MCP23017
make -C /usr/src/rbp2-source-4.4.27-9-osmc M=~/mk_arcade_joystick_rpi/
sudo insmod /home/osmc/mk_arcade_joystick_rpi/mk_arcade_joystick_rpi.ko


insmod: ERROR: could not insert module
/home/osmc/mk_arcade_joystick_rpi/mk_arcade_joystick_rpi.ko: Invalid module format

I used the source package, do you mean i must use another kernel source?

Use uname and get headers for the currently running kernel

I am using the one downloaded from apt-get:

uname -a
Linux osmc 4.4.27-9-osmc #1 SMP PREEMPT Tue Mar 14 20:54:19 UTC 2017 armv7l GNU/Linux

I am using the following source:

sudo apt-get install rbp2-source-4.4.27-9-osmc

I am lost here.

make clean
make install
ensure in /lib/modules and try modprobe it.

I did it and wont worked,

sudo modprobe mk_arcade_joystick_rpi map=1
modprobe: ERROR: could not insert 'mk_arcade_joystick_rpi': Device or resource busy

To make sure that the kernel version is right:

sudo apt-get instal rbp2-image-4.4.27-9-osmc

l the module compiled using:

> sudo make -C /usr/src/rbp2-source-4.4.27-9-osmc M=/lib/modules/mk_arcade_joystick_rpi/ modules
make: Entering directory '/usr/src/rbp2-source-4.4.27-9-osmc'
  CC [M]  /lib/modules/mk_arcade_joystick_rpi//mk_arcade_joystick_rpi.o
/lib/modules/mk_arcade_joystick_rpi//mk_arcade_joystick_rpi.c:152:1: warning: no semicolon at end of struct or union
/lib/modules/mk_arcade_joystick_rpi//mk_arcade_joystick_rpi.c: In function 'i2c_read':
/lib/modules/mk_arcade_joystick_rpi//mk_arcade_joystick_rpi.c:269:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     unsigned short bufidx;
/lib/modules/mk_arcade_joystick_rpi//mk_arcade_joystick_rpi.c: In function 'mk_setup_pad':
/lib/modules/mk_arcade_joystick_rpi//mk_arcade_joystick_rpi.c:412:14: warning: too many arguments for format [-Wformat-extra-args]
              pr_err("Invalid gpio argument\n", pad_type);
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /lib/modules/mk_arcade_joystick_rpi//mk_arcade_joystick_rpi.mod.o
  LD [M]  /lib/modules/mk_arcade_joystick_rpi//mk_arcade_joystick_rpi.ko
make: Leaving directory '/usr/src/rbp2-source-4.4.27-9-osmc'

dmesg msg:

[25074.291901] ------------[ cut here ]------------
[25074.291945] WARNING: CPU: 1 PID: 21967 at arch/arm/mm/ioremap.c:301 __arm_ioremap_caller+0x180/0x1a4()
[25074.291957] Modules linked in: mk_arcade_joystick_rpi(O+) binfmt_misc 8021q garp stp llc r8188eu(C) sg cfg80211 evdev joydev rfkill uas xpad snd_bcm2835 snd_pcm snd_timer bcm2835_thermal snd bcm2835_gpiomem bcm2835_wdt uio_pdrv_genirq uio fuse ipv6
[25074.292064] CPU: 1 PID: 21967 Comm: modprobe Tainted: G        WC O    4.4.27-9-osmc #1
[25074.292073] Hardware name: BCM2709
[25074.292110] [<8001fa6c>] (unwind_backtrace) from [<8001b28c>] (show_stack+0x20/0x24)
[25074.292135] [<8001b28c>] (show_stack) from [<8041522c>] (dump_stack+0xd4/0x118)
[25074.292159] [<8041522c>] (dump_stack) from [<8003105c>] (warn_slowpath_null+0x88/0xdc)
[25074.292180] [<8003105c>] (warn_slowpath_null) from [<800277fc>] (__arm_ioremap_caller+0x180/0x1a4)
[25074.292194] [<800277fc>] (__arm_ioremap_caller) from [<800273dc>] (ioremap+0x2c/0x30)
[25074.292218] [<800273dc>] (ioremap) from [<7f339020>] (mk_init+0x20/0x5e0 [mk_arcade_joystick_rpi])
[25074.292261] [<7f339020>] (mk_init [mk_arcade_joystick_rpi]) from [<80009820>] (do_one_initcall+0xa0/0x1ec)
[25074.292281] [<80009820>] (do_one_initcall) from [<8015ed84>] (do_init_module+0x74/0x218)
[25074.292304] [<8015ed84>] (do_init_module) from [<800dc6a8>] (load_module+0x268c/0x2a4c)
[25074.292321] [<800dc6a8>] (load_module) from [<800dcc3c>] (SyS_finit_module+0x8c/0xa4)
[25074.292339] [<800dcc3c>] (SyS_finit_module) from [<80016f40>] (ret_fast_syscall+0x0/0x1c)
[25074.292350] ---[ end trace 12742ca205262812 ]---
[25074.292357] mk_arcade_joystick_rpi: io remap failed

what i am doing wrong?

I don’t know what the cause of the error is. Address issues maybe?

I’d recommend contacting the author of the module about this. I am sure there are reasons the module is not found in the upstream Raspberry Pi kernel. Maybe it’s not ready or considered stable yet.


Thanks for your help Sam,

I am spending high amount of time to make this works, but i dont know how yet. I contacted the author already. I really want to use my home made arcade controller with rbp gpio’s.

Thanks for your time.

I understand.

If you are in contact with the module author, ask them what kernel version the driver worked on last, and on which devices they’ve tested with.


Sam, i have tested the other OS with a new kernel version: linux-headers-4.4.50 do you think that osmc could work with a new kernel version?

Yes – but we can only support the OSMC kernel officially.

We’ll release a 4.9 kernel soon, so you may have more luck then.

Good to hear.

I’ve found a workaround, using the RecalBoxOS together with OSMC, for this i am using this script (added a menu entry to enable this):

sudo su -c 'echo 8 > /sys/module/bcm2709/parameters/reboot_part'
sudo reboot

This way, i am using the full RecalBoxSO together with full OSMC, because the limitations of each distro does not affect the other distro. ( the game runs smother even with arcade controller / can watch videos )

Ps: The recalbox is installed in partition 8.