PJ – Installing Drivers on a Vanilla Linux Setup

Overview:

There are two linux drivers provided specifically for use with PJ. A main communication driver (j4b) and a linux joystick driver (pjjoy). Both must be installed for the JAMMA controls and board monitoring to function properly. The driver j4b is the parent module for pjjoy, so when loading the driver modules, j4b must be loaded first.

Compile drivers module if you are installing this on a vanilla retropie setup as they driver versioning is tied to the kernel and binary kernel driver files will not be provided for every kernel or retropie version.

Make sure you have this tar file already uploaded to your Pi and extracted as per the instructions here.

Communication module:

Compile the communication driver module.

cd /home/pi/linux-modules/j4b
make clean
make

Your output *should* look something like this (kernel version may be different):

make -C /lib/modules/4.14.98-v7+/build/ M=/home/pi/linux-modules/j4b modules
make[1]: Entering directory '/usr/src/linux-headers-4.14.98-v7+'
  CC [M]  /home/pi/linux-modules/j4b/j4b.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /home/pi/linux-modules/j4b/j4b.mod.o
  LD [M]  /home/pi/linux-modules/j4b/j4b.ko
make[1]: Leaving directory '/usr/src/linux-headers-4.14.98-v7+'

Install binary driver module (kernel_version can be obtained by running uname -r):

sudo cp j4b.ko /lib/modules/<kernel_version>/kernel/drivers/gpio/

Joystick module:

Compile the module:

cd /home/pi/linux-modules/pjjoy
make clean
make

Typical compiler output:

cp /home/pi/linux-modules/j4b/Module.symvers /home/pi/linux-modules/pjjoy
make -C /lib/modules/4.14.98-v7+/build M=/home/pi/linux-modules/pjjoy modules
make[1]: Entering directory '/usr/src/linux-headers-4.14.98-v7+'
  CC [M]  /home/pi/linux-modules/pjjoy/pjjoy.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /home/pi/linux-modules/pjjoy/pjjoy.mod.o
  LD [M]  /home/pi/linux-modules/pjjoy/pjjoy.ko
make[1]: Leaving directory '/usr/src/linux-headers-4.14.98-v7+'

Install driver module (kernel_version can be obtained by running uname -r):

sudo cp pjjoy.ko /lib/modules/<kernel_version>/kernel/drivers/input/

Backup your /etc/modules file:

cp /etc/modules /etc/modules.bak

Add these lines to /etc/modules:

j4b
pjjoy

Finally run:

depmod -a
reboot

Upon reboot, make sure your joystick driver modules are loaded… to confirm type:

lsmod

You should get a listing of modules which includes “j4b” and “pjjoy”:

Module                  Size  Used by
cfg80211              573440  0
rfkill                 28672  2 cfg80211
snd_bcm2835            32768  0
snd_pcm                98304  1 snd_bcm2835
snd_timer              32768  1 snd_pcm
snd                    69632  3 snd_timer,snd_bcm2835,snd_pcm
pwm_bcm2835            16384  0
uio_pdrv_genirq        16384  0
uio                    20480  1 uio_pdrv_genirq
fixed                  16384  0
evdev                  24576  4
joydev                 20480  0
pjjoy                  16384  0
j4b                    16384  1 pjjoy
uinput                 20480  0
ip_tables              24576  0
x_tables               32768  1 ip_tables
ipv6                  425984  28

If any issues occur loading the drivers this way, try doing in manually:

cd /home/pi/linux-modules/j4b
sudo insmod j4b.ko
cd /home/pi/linux-modules/pjjoy
sudo insmod pjjoy.ko

If any issues check /var/log/debug for more info, and verify that the module was loaded using lsmod.