theDavis
Posts: 5
Joined: Fri Aug 17, 2012 6:21 pm

Re: Multi-console gamepad driver for GPIO

Tue May 06, 2014 3:59 am

Hi Marqs!

Thanks for the driver, it works great! I'm in the process of setting up a nes/snes game system, and thanks to you I can use the original controllers!

I have the pins of the rpi connected to the original SNES controller pcb, and the SNES controller I have seems to take a few seconds to warm up. That is, i'll have everything hooked up to the pi, load the module, and run jstest. At first, jstest responds only to one button (input 1, 'B'), but after a few seconds/button presses they all start working. I haven't tinkered with it too much, but it seems fine after that initial sluggishness. Is this just an oddity of the third party controller I'm using, or could it be something wrong with how I've wired things?

Thanks for your thoughts!

marqs
Posts: 212
Joined: Sat Jun 09, 2012 11:34 am

Re: Multi-console gamepad driver for GPIO

Tue May 06, 2014 6:26 pm

theDavis wrote:Hi Marqs!

Thanks for the driver, it works great! I'm in the process of setting up a nes/snes game system, and thanks to you I can use the original controllers!

I have the pins of the rpi connected to the original SNES controller pcb, and the SNES controller I have seems to take a few seconds to warm up. That is, i'll have everything hooked up to the pi, load the module, and run jstest. At first, jstest responds only to one button (input 1, 'B'), but after a few seconds/button presses they all start working. I haven't tinkered with it too much, but it seems fine after that initial sluggishness. Is this just an oddity of the third party controller I'm using, or could it be something wrong with how I've wired things?

Thanks for your thoughts!
I guess it could be specific to that brand as I haven't heard of such issue before. Perhaps it'd require 5V for flawless operation, but if it works correctly after a while I'd leave it at that.

BTW, if you have a cannibalized SNES with a discreet SPC APU, it's quite easy to connect it to RPi and play SPCs through it. I ported this to RPi GPIO some time ago - PM me if you're interested and I can share schematics and code.

Marv007
Posts: 9
Joined: Sat May 03, 2014 7:24 pm

Re: Multi-console gamepad driver for GPIO

Thu May 08, 2014 10:46 pm

marqs wrote: Ok, thanks for elaborating. In that case, I bet RPi cannot properly drive high the clock inputs of those 3 controllers. If they don't work at all with 5V, then perhaps some of the ICs require more than 3.3V to the data pins for proper logic high. It seems that latching works correctly (as the first button, 'A', is reported ok) but clock generation causes oscillation which shifts the 4021 shift-register too many times, so that '0' appears in the output after first pulse (causing all other buttons read as 'off').

This should be fixed by adding a 3.3V->5V shifter (e.g. 74HCT244) to latch and clock outputs of Pi. Increasing the drive strength of GPIO pads could also be a sufficient fix. That can be done with the following:

Code: Select all

wget http://www.niksula.hut.fi/~mhiienka/Rpi/set_gpio_str.c
gcc set_gpio_str.c -o set_gpio_str
sudo ./set_gpio_str 7
Thanks! I'll try changing the drive strength first. If that doesn't work I need to collect some shifters and start prototyping again. I'll keep you updated

theDavis
Posts: 5
Joined: Fri Aug 17, 2012 6:21 pm

Re: Multi-console gamepad driver for GPIO

Sat May 10, 2014 2:30 am

marqs wrote:I guess it could be specific to that brand as I haven't heard of such issue before. Perhaps it'd require 5V for flawless operation, but if it works correctly after a while I'd leave it at that.

BTW, if you have a cannibalized SNES with a discreet SPC APU, it's quite easy to connect it to RPi and play SPCs through it. I ported this to RPi GPIO some time ago - PM me if you're interested and I can share schematics and code.
Ok, that makes sense. Maybe I'll see if I can find a 1st party controller to test out, see if it really is just a quirk of this particular controller.

I do have a cannibalized SNES with a discreet SPC APU...that looks interesting! Is it just for playback of SPCs, or could it be used with an emulator for more accurate reproduction during play?

marqs
Posts: 212
Joined: Sat Jun 09, 2012 11:34 am

Re: Multi-console gamepad driver for GPIO

Sat May 10, 2014 8:06 am

theDavis wrote:I do have a cannibalized SNES with a discreet SPC APU...that looks interesting! Is it just for playback of SPCs, or could it be used with an emulator for more accurate reproduction during play?
Currently it's just a command-line tool for SPC playback through the APU, but it'd be also possible to write a plugin for SNES emulator to utilize it. It'd mostly be for curiosity, even though there's a few real advantages (higher accuracy, less CPU cycles, cleaner sound than Pi's analog audio output).

Marv007
Posts: 9
Joined: Sat May 03, 2014 7:24 pm

Re: Multi-console gamepad driver for GPIO

Sat May 10, 2014 4:07 pm

Marv007 wrote:
marqs wrote: Ok, thanks for elaborating. In that case, I bet RPi cannot properly drive high the clock inputs of those 3 controllers. If they don't work at all with 5V, then perhaps some of the ICs require more than 3.3V to the data pins for proper logic high. It seems that latching works correctly (as the first button, 'A', is reported ok) but clock generation causes oscillation which shifts the 4021 shift-register too many times, so that '0' appears in the output after first pulse (causing all other buttons read as 'off').

This should be fixed by adding a 3.3V->5V shifter (e.g. 74HCT244) to latch and clock outputs of Pi. Increasing the drive strength of GPIO pads could also be a sufficient fix. That can be done with the following:

Code: Select all

wget http://www.niksula.hut.fi/~mhiienka/Rpi/set_gpio_str.c
gcc set_gpio_str.c -o set_gpio_str
sudo ./set_gpio_str 7
Thanks! I'll try changing the drive strength first. If that doesn't work I need to collect some shifters and start prototyping again. I'll keep you updated
Unfortunately changing the drive strength didn't work. Do you think a 74LVC245 would work as well? That one is easier to obtain for me. In that case I could use one for latch + clock and one for the 4 data out.

marqs
Posts: 212
Joined: Sat Jun 09, 2012 11:34 am

Re: Multi-console gamepad driver for GPIO

Sat May 10, 2014 8:41 pm

Marv007 wrote:Unfortunately changing the drive strength didn't work. Do you think a 74LVC245 would work as well? That one is easier to obtain for me. In that case I could use one for latch + clock and one for the 4 data out.
74LVC245 can only be used as a down level shifter to protect the GPIO pin(s) set as input (data in this case). Here you need an up level shifter for gpio output pins (latch and clock). It can be a buffer/bus transceiver which recognizes 3.3V input as logic high with 5V supply voltage - HCT series are guaranteed to be compatible, check e.g. this thread for more info.

Alternatively, you could replace the ancient 4021 shift registers from the nonfunctional controllers, although that's a bit more work. Any CMOS logic ICs made in the last 15 years should run fine with 3.3V supply.

Marv007
Posts: 9
Joined: Sat May 03, 2014 7:24 pm

Re: Multi-console gamepad driver for GPIO

Sun May 11, 2014 10:18 pm

marqs wrote:74LVC245 can only be used as a down level shifter to protect the GPIO pin(s) set as input (data in this case). Here you need an up level shifter for gpio output pins (latch and clock). It can be a buffer/bus transceiver which recognizes 3.3V input as logic high with 5V supply voltage - HCT series are guaranteed to be compatible, check e.g. this thread for more info.

Alternatively, you could replace the ancient 4021 shift registers from the nonfunctional controllers, although that's a bit more work. Any CMOS logic ICs made in the last 15 years should run fine with 3.3V supply.
So I would need both a 74LVC245 and a 74HCT244. That's okay, I found a shop that ships both. It's out of stock so it could take a while but I'll keep you updated. Thanks!

marqs
Posts: 212
Joined: Sat Jun 09, 2012 11:34 am

Re: Multi-console gamepad driver for GPIO

Mon May 12, 2014 6:11 am

Marv007 wrote:
marqs wrote:74LVC245 can only be used as a down level shifter to protect the GPIO pin(s) set as input (data in this case). Here you need an up level shifter for gpio output pins (latch and clock). It can be a buffer/bus transceiver which recognizes 3.3V input as logic high with 5V supply voltage - HCT series are guaranteed to be compatible, check e.g. this thread for more info.

Alternatively, you could replace the ancient 4021 shift registers from the nonfunctional controllers, although that's a bit more work. Any CMOS logic ICs made in the last 15 years should run fine with 3.3V supply.
So I would need both a 74LVC245 and a 74HCT244. That's okay, I found a shop that ships both. It's out of stock so it could take a while but I'll keep you updated. Thanks!
Yeah, you'll need both. Alternatively, you could use a single bi-directional level shifter (e.g. MAX3001E or TXB0108), but I've seen them only in TSSOP packages, so SMD soldering is required. Hopefully the level translation will fix your issues.

Marv007
Posts: 9
Joined: Sat May 03, 2014 7:24 pm

Re: Multi-console gamepad driver for GPIO

Tue May 13, 2014 9:48 pm

marqs wrote:
Marv007 wrote:
marqs wrote:74LVC245 can only be used as a down level shifter to protect the GPIO pin(s) set as input (data in this case). Here you need an up level shifter for gpio output pins (latch and clock). It can be a buffer/bus transceiver which recognizes 3.3V input as logic high with 5V supply voltage - HCT series are guaranteed to be compatible, check e.g. this thread for more info.

Alternatively, you could replace the ancient 4021 shift registers from the nonfunctional controllers, although that's a bit more work. Any CMOS logic ICs made in the last 15 years should run fine with 3.3V supply.
So I would need both a 74LVC245 and a 74HCT244. That's okay, I found a shop that ships both. It's out of stock so it could take a while but I'll keep you updated. Thanks!
Yeah, you'll need both. Alternatively, you could use a single bi-directional level shifter (e.g. MAX3001E or TXB0108), but I've seen them only in TSSOP packages, so SMD soldering is required. Hopefully the level translation will fix your issues.
That totally did the trick! It's working perfectly now! Thanks! I was able to get the chips very quickly at my local electronics store and tried them this evening. I connected 2 controllers and they work totally fine simultaneously. I'm going to get 4 snes connectors as well to see if that works. Thanks again!

FYI I used a 74LVC245 and a 74HCT244

theDavis
Posts: 5
Joined: Fri Aug 17, 2012 6:21 pm

Re: Multi-console gamepad driver for GPIO

Wed May 14, 2014 3:57 am

Marv007 wrote:
That totally did the trick! It's working perfectly now! Thanks! I was able to get the chips very quickly at my local electronics store and tried them this evening. I connected 2 controllers and they work totally fine simultaneously. I'm going to get 4 snes connectors as well to see if that works. Thanks again!

FYI I used a 74LVC245 and a 74HCT244
Hey Marv,

Could you post an explanation/simple diagram of how you connected those two chips? I'm wondering if the flakiness of some of my 3rd party controllers is due to using 3.3v logic rather than 5v. I'm fairly new to the hardware level (software guy), and think I get the general idea from the datasheets, but just want to make sure I'm getting it.

Thanks!

bcrawford
Posts: 20
Joined: Fri May 10, 2013 8:22 pm

Re: Multi-console gamepad driver for GPIO

Wed May 14, 2014 12:00 pm

Hello,
First of all, let me say thanks for all the hard work that has been put into this project. So here's the problem I have run into. I have a working setup that I put together last summer (pi inside an old snes housing with the original snes controllers wired up to the pi, no adapter). After blowing off the dust yesterday, I decided do some updates on the pi and on retropie. Once it was finished, I realized that my controllers were no longer working. I was getting these errors on boot and when running modprobe manually:

Code: Select all

pi@raspberrypi ~ $ sudo modprobe gamecon_gpio_rpi map=0,0,0,0,1,1
ERROR: could not insert 'gamecon_gpio_rpi': Exec format error
pi@raspberrypi ~ $ tail /var/log/kern.log
May 13 21:45:32 raspberrypi kernel: [   32.277362] Bluetooth: SCO socket layer initialized
May 13 21:45:32 raspberrypi kernel: [   32.349155] Bluetooth: RFCOMM TTY layer initialized
May 13 21:45:32 raspberrypi kernel: [   32.349227] Bluetooth: RFCOMM socket layer initialized
May 13 21:45:32 raspberrypi kernel: [   32.349241] Bluetooth: RFCOMM ver 1.11
May 13 21:45:32 raspberrypi kernel: [   32.362209] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
May 13 21:45:32 raspberrypi kernel: [   32.362237] Bluetooth: BNEP filters: protocol multicast
May 13 21:45:32 raspberrypi kernel: [   32.362277] Bluetooth: BNEP socket layer initialized
May 13 21:45:37 raspberrypi kernel: [   37.558523] input: python-uinput as /devices/virtual/input/input2
May 14 07:35:40 raspberrypi kernel: [  290.889788] input: python-uinput as /devices/virtual/input/input3
May 14 07:37:19 raspberrypi kernel: [  390.025342] gamecon_gpio_rpi: disagrees about version of symbol module_layout
After doing a little research on this thread, it seems that this problem stems from the kernel and the headers being out of sync/date. I was hoping I could simply roll back the kernel to the last working set of headers from your site (I had updated to 3.12.19, so I tried to go back to 3.10.38), so I tried the following:

Code: Select all

sudo rpi-update f6eef32dd6388c3b04dbf462bd324d93281bf397
But after letting it complete, running retropie setup and installing/updating gamecon I get the same error:

Code: Select all

ERROR: could not insert 'gamecon_gpio_rpi': Exec format error
Here's the output from running install/update drivers from retropie setup while on 3.10.38:

Code: Select all

pi@raspberrypi ~/RetroPie-Setup $ uname -r
3.10.38+
pi@raspberrypi ~/RetroPie-Setup $ sudo ./retropie_setup.sh 
Loaded module /home/pi/RetroPie-Setup/./scriptmodules/helpers.shinc
Loaded module /home/pi/RetroPie-Setup/./scriptmodules/raspbianconfig.shinc
Loaded module /home/pi/RetroPie-Setup/./scriptmodules/emulators.shinc
Loaded module /home/pi/RetroPie-Setup/./scriptmodules/libretrocores.shinc
Loaded module /home/pi/RetroPie-Setup/./scriptmodules/supplementary.shinc
Loaded module /home/pi/RetroPie-Setup/./scriptmodules/setup.shinc
Loaded module /home/pi/RetroPie-Setup/./scriptmodules/retropiesetup.shinc
Loaded configuration file /home/pi/RetroPie-Setup/./configs/retronetplay.cfg
Found needed packages 'git' and 'dialog'.
/usr/bin /home/pi/RetroPie-Setup
gcc-4.7 is now the default
cpp-4.7 is now the default
g++-4.7 is now the default
gcov-4.7 is now the default
gccbug-4.7 is not installed
/home/pi/RetroPie-Setup

Starting installation.
Hit http://archive.raspberrypi.org wheezy Release.gpg
Hit http://archive.raspberrypi.org wheezy Release
Hit http://archive.raspberrypi.org wheezy/main armhf Packages
Ign http://archive.raspberrypi.org wheezy/main Translation-en_US
Ign http://archive.raspberrypi.org wheezy/main Translation-en
Hit http://raspberrypi.collabora.com wheezy Release.gpg
Hit http://mirrordirector.raspbian.org wheezy Release.gpg
Hit http://raspberrypi.collabora.com wheezy Release
Hit http://mirrordirector.raspbian.org wheezy Release
Hit http://raspberrypi.collabora.com wheezy/rpi armhf Packages
Hit http://mirrordirector.raspbian.org wheezy/main armhf Packages
Hit http://mirrordirector.raspbian.org wheezy/contrib armhf Packages
Hit http://mirrordirector.raspbian.org wheezy/non-free armhf Packages
Hit http://mirrordirector.raspbian.org wheezy/rpi armhf Packages
Ign http://raspberrypi.collabora.com wheezy/rpi Translation-en_US
Ign http://raspberrypi.collabora.com wheezy/rpi Translation-en
Ign http://mirrordirector.raspbian.org wheezy/contrib Translation-en_US
Ign http://mirrordirector.raspbian.org wheezy/contrib Translation-en
Ign http://mirrordirector.raspbian.org wheezy/main Translation-en_US
Ign http://mirrordirector.raspbian.org wheezy/main Translation-en
Ign http://mirrordirector.raspbian.org wheezy/non-free Translation-en_US
Ign http://mirrordirector.raspbian.org wheezy/non-free Translation-en
Ign http://mirrordirector.raspbian.org wheezy/rpi Translation-en_US
Ign http://mirrordirector.raspbian.org wheezy/rpi Translation-en
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
dkms is already the newest version.
gcc-4.7 is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
make: Entering directory `/usr/src/linux-headers-3.10.38+'
  CLEAN   .
scripts/Makefile.clean:17: /usr/src/linux-headers-3.10.38+/drivers/infiniband/hw/amso1100/Makefile: No such file or directory
make[3]: *** No rule to make target `/usr/src/linux-headers-3.10.38+/drivers/infiniband/hw/amso1100/Makefile'.  Stop.
make[2]: [drivers/infiniband/hw/amso1100] Error 2 (ignored)
scripts/Makefile.clean:17: /usr/src/linux-headers-3.10.38+/drivers/infiniband/ulp/srp/Makefile: No such file or directory
make[3]: *** No rule to make target `/usr/src/linux-headers-3.10.38+/drivers/infiniband/ulp/srp/Makefile'.  Stop.
make[2]: [drivers/infiniband/ulp/srp] Error 2 (ignored)
scripts/Makefile.clean:17: /usr/src/linux-headers-3.10.38+/drivers/scsi/cxgbi/cxgb3i/Makefile: No such file or directory
make[4]: *** No rule to make target `/usr/src/linux-headers-3.10.38+/drivers/scsi/cxgbi/cxgb3i/Makefile'.  Stop.
make[3]: [drivers/scsi/cxgbi/cxgb3i] Error 2 (ignored)
scripts/Makefile.clean:17: /usr/src/linux-headers-3.10.38+/drivers/scsi/cxgbi/cxgb4i/Makefile: No such file or directory
make[4]: *** No rule to make target `/usr/src/linux-headers-3.10.38+/drivers/scsi/cxgbi/cxgb4i/Makefile'.  Stop.
make[3]: [drivers/scsi/cxgbi/cxgb4i] Error 2 (ignored)
scripts/Makefile.clean:17: /usr/src/linux-headers-3.10.38+/drivers/scsi/osd/Makefile: No such file or directory
make[3]: *** No rule to make target `/usr/src/linux-headers-3.10.38+/drivers/scsi/osd/Makefile'.  Stop.
make[2]: [drivers/scsi/osd] Error 2 (ignored)
scripts/Makefile.clean:17: /usr/src/linux-headers-3.10.38+/drivers/staging/ozwpan/Makefile: No such file or directory
make[3]: *** No rule to make target `/usr/src/linux-headers-3.10.38+/drivers/staging/ozwpan/Makefile'.  Stop.
make[2]: [drivers/staging/ozwpan] Error 2 (ignored)
scripts/Makefile.clean:17: /usr/src/linux-headers-3.10.38+/drivers/usb/host/whci/Makefile: No such file or directory
make[4]: *** No rule to make target `/usr/src/linux-headers-3.10.38+/drivers/usb/host/whci/Makefile'.  Stop.
make[3]: [drivers/usb/host/whci] Error 2 (ignored)
scripts/Makefile.clean:17: /usr/src/linux-headers-3.10.38+/fs/exofs/Makefile: No such file or directory
make[2]: *** No rule to make target `/usr/src/linux-headers-3.10.38+/fs/exofs/Makefile'.  Stop.
make[1]: [fs/exofs] Error 2 (ignored)
/usr/src/linux-headers-3.10.38+/fs/hostfs/Makefile:11: arch/um/scripts/Makefile.rules: No such file or directory
make[2]: *** No rule to make target `arch/um/scripts/Makefile.rules'.  Stop.
make[1]: [fs/hostfs] Error 2 (ignored)
scripts/Makefile.clean:17: /usr/src/linux-headers-3.10.38+/fs/nfs/objlayout/Makefile: No such file or directory
make[3]: *** No rule to make target `/usr/src/linux-headers-3.10.38+/fs/nfs/objlayout/Makefile'.  Stop.
make[2]: [fs/nfs/objlayout] Error 2 (ignored)
ls: cannot access /usr/src/linux-headers-3.10.38+/Documentation/DocBook/media/*.b64: No such file or directory
  CLEAN   .tmp_versions
ls: cannot access /usr/src/linux-headers-3.10.38+/Documentation/DocBook/media/*.b64: No such file or directory
  CLEAN   scripts/basic
  CLEAN   scripts/genksyms
  CLEAN   scripts/kconfig
  CLEAN   scripts/mod
  CLEAN   scripts
  CLEAN   include/config include/generated arch/arm/include/generated
  CLEAN   .config include/generated/uapi/linux/version.h Module.symvers
make: Leaving directory `/usr/src/linux-headers-3.10.38+'
--2014-05-14 07:48:59--  https://github.com/raspberrypi/firmware/raw/master/extra/Module.symvers
Resolving github.com (github.com)... 192.30.252.130
Connecting to github.com (github.com)|192.30.252.130|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://raw.githubusercontent.com/raspberrypi/firmware/master/extra/Module.symvers [following]
--2014-05-14 07:49:07--  https://raw.githubusercontent.com/raspberrypi/firmware/master/extra/Module.symvers
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 199.27.76.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|199.27.76.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 504485 (493K) [text/plain]
Saving to: `/usr/src/linux-headers-3.10.38+/Module.symvers'

     0K .......... .......... .......... .......... .......... 10%  459K 1s
    50K .......... .......... .......... .......... .......... 20%  451K 1s
   100K .......... .......... .......... .......... .......... 30%  423K 1s
   150K .......... .......... .......... .......... .......... 40%  614K 1s
   200K .......... .......... .......... .......... .......... 50%  563K 0s
   250K .......... .......... .......... .......... .......... 60%  645K 0s
   300K .......... .......... .......... .......... .......... 71%  628K 0s
   350K .......... .......... .......... .......... .......... 81%  607K 0s
   400K .......... .......... .......... .......... .......... 91%  622K 0s
   450K .......... .......... .......... .......... ..        100%  633K=0.9s

Last-modified header missing -- time-stamps turned off.
2014-05-14 07:49:14 (550 KB/s) - `/usr/src/linux-headers-3.10.38+/Module.symvers' saved [504485/504485]

make: Entering directory `/usr/src/linux-headers-3.10.38+'
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  SHIPPED scripts/kconfig/zconf.tab.c
  SHIPPED scripts/kconfig/zconf.lex.c
  SHIPPED scripts/kconfig/zconf.hash.c
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/conf
scripts/kconfig/conf --silentoldconfig Kconfig
make: Leaving directory `/usr/src/linux-headers-3.10.38+'
make: Entering directory `/usr/src/linux-headers-3.10.38+'
  WRAP    arch/arm/include/generated/asm/auxvec.h
  WRAP    arch/arm/include/generated/asm/bitsperlong.h
  WRAP    arch/arm/include/generated/asm/cputime.h
  WRAP    arch/arm/include/generated/asm/current.h
  WRAP    arch/arm/include/generated/asm/emergency-restart.h
  WRAP    arch/arm/include/generated/asm/errno.h
  WRAP    arch/arm/include/generated/asm/exec.h
  WRAP    arch/arm/include/generated/asm/ioctl.h
  WRAP    arch/arm/include/generated/asm/ipcbuf.h
  WRAP    arch/arm/include/generated/asm/irq_regs.h
  WRAP    arch/arm/include/generated/asm/kdebug.h
  WRAP    arch/arm/include/generated/asm/local.h
  WRAP    arch/arm/include/generated/asm/local64.h
  WRAP    arch/arm/include/generated/asm/msgbuf.h
  WRAP    arch/arm/include/generated/asm/param.h
  WRAP    arch/arm/include/generated/asm/parport.h
  WRAP    arch/arm/include/generated/asm/poll.h
  WRAP    arch/arm/include/generated/asm/resource.h
  WRAP    arch/arm/include/generated/asm/sections.h
  WRAP    arch/arm/include/generated/asm/segment.h
  WRAP    arch/arm/include/generated/asm/sembuf.h
  WRAP    arch/arm/include/generated/asm/serial.h
  WRAP    arch/arm/include/generated/asm/shmbuf.h
  WRAP    arch/arm/include/generated/asm/siginfo.h
  WRAP    arch/arm/include/generated/asm/sizes.h
  WRAP    arch/arm/include/generated/asm/socket.h
  WRAP    arch/arm/include/generated/asm/sockios.h
  WRAP    arch/arm/include/generated/asm/termbits.h
  WRAP    arch/arm/include/generated/asm/termios.h
  WRAP    arch/arm/include/generated/asm/timex.h
  WRAP    arch/arm/include/generated/asm/trace_clock.h
  WRAP    arch/arm/include/generated/asm/types.h
  WRAP    arch/arm/include/generated/asm/unaligned.h
  CHK     include/generated/uapi/linux/version.h
  UPD     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  UPD     include/generated/utsrelease.h
  Generating include/generated/mach-types.h
  CC      kernel/bounds.s
  GEN     include/generated/bounds.h
  CC      arch/arm/kernel/asm-offsets.s
  GEN     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
grep: scripts/../arch/x86/syscalls/syscall_32.tbl: No such file or directory
  HOSTCC  scripts/genksyms/genksyms.o
  SHIPPED scripts/genksyms/lex.lex.c
  SHIPPED scripts/genksyms/keywords.hash.c
  SHIPPED scripts/genksyms/parse.tab.h
  HOSTCC  scripts/genksyms/lex.lex.o
  SHIPPED scripts/genksyms/parse.tab.c
  HOSTCC  scripts/genksyms/parse.tab.o
  HOSTLD  scripts/genksyms/genksyms
  CC      scripts/mod/empty.o
  HOSTCC  scripts/mod/mk_elfconfig
  MKELF   scripts/mod/elfconfig.h
  CC      scripts/mod/devicetable-offsets.s
  GEN     scripts/mod/devicetable-offsets.h
  HOSTCC  scripts/mod/file2alias.o
  HOSTCC  scripts/mod/modpost.o
  HOSTCC  scripts/mod/sumversion.o
  HOSTLD  scripts/mod/modpost
  HOSTCC  scripts/kallsyms
  HOSTCC  scripts/pnmtologo
  HOSTCC  scripts/conmakehash
  HOSTCC  scripts/bin2c
  HOSTCC  scripts/sortextable
make: Leaving directory `/usr/src/linux-headers-3.10.38+'

-------- Uninstall Beginning --------
Module:  db9_gpio_rpi
Version: 0.7
Kernel:  3.10.38+ (armv6l)
-------------------------------------

Status: Before uninstall, this module version was ACTIVE on this kernel.

db9_gpio_rpi.ko:
 - Uninstallation
   - Deleting from: /lib/modules/3.10.38+/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

depmod......

DKMS: uninstall completed.

------------------------------
Deleting module version: 0.7
completely from the DKMS tree.
------------------------------
Done.
Loading new db9_gpio_rpi-0.7 DKMS files...
First Installation: checking all kernels...
It is likely that 3.10.38+ belongs to a chroot's host
Building for architecture armv6l
Building initial module for 3.10.38+
Done.

db9_gpio_rpi:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/3.10.38+/updates/dkms/

depmod.....

DKMS: install completed.

-------- Uninstall Beginning --------
Module:  gamecon_gpio_rpi
Version: 0.9
Kernel:  3.10.38+ (armv6l)
-------------------------------------

Status: Before uninstall, this module version was ACTIVE on this kernel.

gamecon_gpio_rpi.ko:
 - Uninstallation
   - Deleting from: /lib/modules/3.10.38+/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

depmod.....

DKMS: uninstall completed.

------------------------------
Deleting module version: 0.9
completely from the DKMS tree.
------------------------------
Done.
Loading new gamecon_gpio_rpi-0.9 DKMS files...
First Installation: checking all kernels...
It is likely that 3.10.38+ belongs to a chroot's host
Building for architecture armv6l
Building initial module for 3.10.38+
Done.

gamecon_gpio_rpi:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/3.10.38+/updates/dkms/

depmod.....

DKMS: install completed.
gamecon is the newest version
db9 is the newest version
I've been struggling with this for the last day and any help would be greatly appreciated. Please let me know if there is any more info you need from me. Thanks!

bcrawford
Posts: 20
Joined: Fri May 10, 2013 8:22 pm

Re: Multi-console gamepad driver for GPIO

Wed May 14, 2014 3:16 pm

MrHein wrote:I finally got it to work. I repacked linux-headers-3.6.11+_3.6.11+-2_armhf.deb and changed the postinst.
Instead of master branch I figured it out to use https://raw.github.com/raspberrypi/firm ... le.symvers.
I totally missed this post. After seeing it I realized that the modified headers were downloading Module.symvers from the 3.12.19 branch instead of grabbing from the 3.10.38 branch. This post was very helpful in understanding how to unpack, modify, and repack .deb packages, something which I learned today =).

Looks like I got it figured out, but hopefully someone will find these posts helpful in the future.

marqs
Posts: 212
Joined: Sat Jun 09, 2012 11:34 am

Re: Multi-console gamepad driver for GPIO

Wed May 14, 2014 7:21 pm

Seems like RPi kernel has switched to 3.12.y. I updated the header generation script to follow that branch, so headers will be now generated automatically till 3.14.

Marv007
Posts: 9
Joined: Sat May 03, 2014 7:24 pm

Re: Multi-console gamepad driver for GPIO

Wed May 14, 2014 7:43 pm

theDavis wrote:Hey Marv,

Could you post an explanation/simple diagram of how you connected those two chips? I'm wondering if the flakiness of some of my 3rd party controllers is due to using 3.3v logic rather than 5v. I'm fairly new to the hardware level (software guy), and think I get the general idea from the datasheets, but just want to make sure I'm getting it.

Thanks!
Hi theDavis. Of course I'll post the diagram. Does this make sense:

Code: Select all

          VCC - DIR  01     20 VCC - 3.3V P1
    CON1 DATA -  AO  02  7  19 OE  - GND P6
                     03  4  18 B0  - GPIO0 P3
                     04  L  17
                     05  V  16
                     06  C  15
                     07  2  14
                     08  4  13
                     09  5  12
       P6 GND - GND  10     11



       P6 GND - 1OE  01     20 VCC - 5V P2
   P19 GPIO10 - 1A0  02  7  19
                     03  4  18 1Y0 - CLK CON
   P23 GPIO11 - 1A1  04  H  17
                     05  C  16 1Y1 - LCH CON
                     06  T  15
                     07  2  14
                     08  4  13
                     09  4  12
       P6 GND - GND  10     11



       P6 GND - GND  .
                CLK  .  N  . 5V - 5V P2
                LCH  .  E  .
               DATA  .  S  .
With Pxx I mean a pin number on the Pi. It's based on Rev 1

theDavis
Posts: 5
Joined: Fri Aug 17, 2012 6:21 pm

Re: Multi-console gamepad driver for GPIO

Wed May 14, 2014 11:58 pm

Marv007 wrote:
Hi theDavis. Of course I'll post the diagram. Does this make sense:

Code: Select all

          VCC - DIR  01     20 VCC - 3.3V P1
    CON1 DATA -  AO  02  7  19 OE  - GND P6
                     03  4  18 B0  - GPIO0 P3
                     04  L  17
                     05  V  16
                     06  C  15
                     07  2  14
                     08  4  13
                     09  5  12
       P6 GND - GND  10     11



       P6 GND - 1OE  01     20 VCC - 5V P2
   P19 GPIO10 - 1A0  02  7  19
                     03  4  18 1Y0 - CLK CON
   P23 GPIO11 - 1A1  04  H  17
                     05  C  16 1Y1 - LCH CON
                     06  T  15
                     07  2  14
                     08  4  13
                     09  4  12
       P6 GND - GND  10     11



       P6 GND - GND  .
                CLK  .  N  . 5V - 5V P2
                LCH  .  E  .
               DATA  .  S  .
With Pxx I mean a pin number on the Pi. It's based on Rev 1
That's perfect, thanks!

User avatar
DigitalLumberjack
Posts: 336
Joined: Thu May 22, 2014 8:55 am
Location: France
Contact: Website

Re: Multi-console gamepad driver for GPIO

Thu May 22, 2014 9:35 am

Hello, i'm currently trying to connect my nes pad ton my raspberry pi REV 2.

I installed gamecon module and it loads without problem.

I first connected data wired on GPIO 2 (GPIO0 for rev1) and GPIO3 (GPIO1 for rev1). I could not receive any data from the controller with jstest.

Then i connected my data wire on GPIO4 and loaded the driver as follow :

Code: Select all

sudo modprobe gamecon_gpio_rpi map=0,0,2
and running the jstest program show something interesting :

No button pressed :
Axes: 0: 0 1: 0 Buttons: 0:off 1:off 2:off 3:off

A button pressed :
Axes: 0: 0 1: 0 Buttons: 0:on 1:on 2:on 3:on

I saw that when no button is pressed the controller send 8 bits set to 1


So the state when no button is pressed is 1,1,1,1,1,1,1,1

I tried to see in SNESDev sources the way to read data on pin and made a few printf to see what is happening when i press a button.

I can see that when i pull the A button on the controller, the 8 bits read on the controller change to 1,0,0,0,0,0,0,0.

I cant find a way to correct this by myself.

I tried to read values from the controller from wiringpi with this program :

Code: Select all

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <wiringPi.h>
#include <piNes.h>

int main(){
	int joystick, buttons;
	if (wiringPiSetupGpio () < 0)
	{
		fprintf (stderr, "Can't setup GPIO: %s\n", strerror (errno)) ;
		exit (1) ;
	}

	if ((joystick = setupNesJoystick (4, 11, 10)) == -1)
	{
		fprintf (stderr, "Unable to setup joystick\n") ;
		return 1 ;
	}
	
	while(1){
		printf("reading joystick\n");
		buttons = readNesJoystick (joystick) ;
		
		printf("result : %d\n", buttons);
		sleep(1);
	}
	if ((buttons & NES_UP) != 0){
		printf("up pressed");
	}
	printf("exiting\n");
	return 0;
}

And all works fine, i have a different value for each button pressed on the controller.

Someone have an idea ?

Thank you.

marqs
Posts: 212
Joined: Sat Jun 09, 2012 11:34 am

Re: Multi-console gamepad driver for GPIO

Thu May 22, 2014 3:50 pm

The difference between GPIO2/GPIO3 and other GPIOs is pullup strength, but it should not affect the operation.

If you look at the raw output from GPIO, '1' means a button is up and '0' down (=pressed).

So you did not get correct readings with either gamecon or Snesdev, but wiringPi was OK? With a quick look, the only relevant difference I noticed is the delay they use (e.g. PULSE_TIME in piNes.c). Gamecon uses 6us while wiringPi 25us. BTW, which supply (3.3V or 5V) did you use for the controller?
DigitalLumberjack wrote:Hello, i'm currently trying to connect my nes pad ton my raspberry pi REV 2.

I installed gamecon module and it loads without problem.

I first connected data wired on GPIO 2 (GPIO0 for rev1) and GPIO3 (GPIO1 for rev1). I could not receive any data from the controller with jstest.

Then i connected my data wire on GPIO4 and loaded the driver as follow :

Code: Select all

sudo modprobe gamecon_gpio_rpi map=0,0,2
and running the jstest program show something interesting :

No button pressed :
Axes: 0: 0 1: 0 Buttons: 0:off 1:off 2:off 3:off

A button pressed :
Axes: 0: 0 1: 0 Buttons: 0:on 1:on 2:on 3:on

I saw that when no button is pressed the controller send 8 bits set to 1


So the state when no button is pressed is 1,1,1,1,1,1,1,1

I tried to see in SNESDev sources the way to read data on pin and made a few printf to see what is happening when i press a button.

I can see that when i pull the A button on the controller, the 8 bits read on the controller change to 1,0,0,0,0,0,0,0.

I cant find a way to correct this by myself.

I tried to read values from the controller from wiringpi with this program :

Code: Select all

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <wiringPi.h>
#include <piNes.h>

int main(){
	int joystick, buttons;
	if (wiringPiSetupGpio () < 0)
	{
		fprintf (stderr, "Can't setup GPIO: %s\n", strerror (errno)) ;
		exit (1) ;
	}

	if ((joystick = setupNesJoystick (4, 11, 10)) == -1)
	{
		fprintf (stderr, "Unable to setup joystick\n") ;
		return 1 ;
	}
	
	while(1){
		printf("reading joystick\n");
		buttons = readNesJoystick (joystick) ;
		
		printf("result : %d\n", buttons);
		sleep(1);
	}
	if ((buttons & NES_UP) != 0){
		printf("up pressed");
	}
	printf("exiting\n");
	return 0;
}

And all works fine, i have a different value for each button pressed on the controller.

Someone have an idea ?

Thank you.

User avatar
DigitalLumberjack
Posts: 336
Joined: Thu May 22, 2014 8:55 am
Location: France
Contact: Website

Re: Multi-console gamepad driver for GPIO

Tue May 27, 2014 6:18 pm

Hello marqs thank you for your answer.
I use the 3.3V as power wire.

I made it work since my last post ! With all test i made i exchanged clock and latch on my solderings. I soldered again all wire and it works now !

Thank you !

What a good feeling to play all my childhood games, on a nes, with nes controllers :D

Marv007
Posts: 9
Joined: Sat May 03, 2014 7:24 pm

Re: Multi-console gamepad driver for GPIO

Thu May 29, 2014 8:04 pm

Marv007 wrote:That totally did the trick! It's working perfectly now! Thanks! I was able to get the chips very quickly at my local electronics store and tried them this evening. I connected 2 controllers and they work totally fine simultaneously. I'm going to get 4 snes connectors as well to see if that works. Thanks again!

FYI I used a 74LVC245 and a 74HCT244
I have not yet connected 4 snes controllers at the same time but I did connect 2 nes + 2 snes controllers and they work fine according to jstest. I tried some games and I got mixed results. Chip 'n Dale for nes works fine. Mario Kart for snes works fine. Bomberman 2 for snes can only recognise the first two controllers. But that is of course due to the limited functionality of the emulator I used, is doesn't support multitap. Micro Machines (1 and 2) for snes do not recognise the 2nd, 3rd or 4th controller at all, which is kinda weird.

I've been googling the last few days to see if someone else fixed this problem but I couldn't find a fix. I tried some settings myself but couldn't get 4p to work. Pocket SNES probably has no support for multitap whatsoever. Snes9x-rpi does not support it either. Both of them seem to be abandoned.

So your driver works perfectly fine but the emulators are a bit lacking. Oh well, 2p is working at least.

LifeAsASuffix
Posts: 11
Joined: Mon Jan 07, 2013 1:10 am

Re: Multi-console gamepad driver for GPIO

Fri Jun 27, 2014 1:52 am

im having an odd issue with the GPIO driver on boot. I've tried everything i can think of to track down and remedy the issue.. So far I've reinstalled the RetroPie script, installed the whole system from scratch, installed the gamecon driver from the retropie script, and manually. When i reboot the system the driver does not seem to load. I'm booting to emulationstation, where the controllers are not recognized. I can exit emulation and type "sudo modprobe gamecon_gpio_rpi map=0,0,0,0,7,7" and everything works until i reboot again.
anyone have any ideas? I'm stumped.
Thanks
-Ed

marqs
Posts: 212
Joined: Sat Jun 09, 2012 11:34 am

Re: Multi-console gamepad driver for GPIO

Fri Jun 27, 2014 5:51 am

LifeAsASuffix wrote:im having an odd issue with the GPIO driver on boot. I've tried everything i can think of to track down and remedy the issue.. So far I've reinstalled the RetroPie script, installed the whole system from scratch, installed the gamecon driver from the retropie script, and manually. When i reboot the system the driver does not seem to load. I'm booting to emulationstation, where the controllers are not recognized. I can exit emulation and type "sudo modprobe gamecon_gpio_rpi map=0,0,0,0,7,7" and everything works until i reboot again.
anyone have any ideas? I'm stumped.
Thanks
-Ed
Did you add the corresponding line (gamecon_gpio_rpi map=0,0,0,0,7,7) to /etc/modules? Modprobe-command only loads the driver for the running kernel. This info seems to be missing on wikipage, I'll add it there shortly.

LifeAsASuffix
Posts: 11
Joined: Mon Jan 07, 2013 1:10 am

Re: Multi-console gamepad driver for GPIO

Fri Jun 27, 2014 11:31 pm

marqs wrote: Did you add the corresponding line (gamecon_gpio_rpi map=0,0,0,0,7,7) to /etc/modules? Modprobe-command only loads the driver for the running kernel. This info seems to be missing on wikipage, I'll add it there shortly.
You are amazing! I knew it was something simple I was missing. Thanks that fixed my issue!

joostvanpoppel
Posts: 24
Joined: Mon Jan 27, 2014 2:26 pm

Re: Multi-console gamepad driver for GPIO

Tue Jul 01, 2014 2:24 pm

Download link in first post seems to be broken, what is the link to use?

thanks,
Joost

marqs
Posts: 212
Joined: Sat Jun 09, 2012 11:34 am

Re: Multi-console gamepad driver for GPIO

Tue Jul 01, 2014 5:51 pm

joostvanpoppel wrote:Download link in first post seems to be broken, what is the link to use?

thanks,
Joost
The driver is nowadays part of RetroPie-project, and you can install it by selecting the corresponding option in RetroPie-Setup
-script.

Return to “Gaming”