Atari to USB Driver


68 posts   Page 2 of 3   1, 2, 3
by Croccy22 » Wed Jan 15, 2014 11:49 pm
Hey guys,

My brother bought one of these adapters for the Spectrum + I fitted out with a Raspberry pi (http://www.flickr.com/photos/113610905@ ... 510524445/)

Anyway, we then discovered that it didn't work on the PI so he set me the challenge to get it working. AND I DID!!! :-)

The basic solution is as follows. Download the latest source code for raspbian from git hub and get everything ready to compile. But before doing so edit the hid-input.c file which is located in /drivers/hid/hid-input.c (Within the source code directory).

Now search in the file for "out-of-range". You will see the following:

Code: Select all
if ((field->flags & HID_MAIN_ITEM_VARIABLE) &&
(value < field->logical_minimum ||
value > field->logical_maximum)) {
dbg_hid("Ignoring out-of-range value %x\n", value);
return;
}


Change this to read:

Code: Select all
if ((field->flags & HID_MAIN_ITEM_VARIABLE) &&
(value < field->logical_minimum ||
value > field->logical_maximum)) {
if(value < logical_minimum)
value=field->logical_minimum;
else
value= field->logical_maximum;
}


Credit for this discovery goes to the website -> http://blognamn.wordpress.com/

You can now compile the kernel and the modules etc and transfer them over to the pi. This will make the Up and Left function as they should but still leaves one problem. It is only detected as a single input device but with 4 axis.

So now edit the /boot/cmdline.txt file on the pi and at the end of the line of text, add the following:

Code: Select all
usbhid.quirks=0x1292:0x4154:0x040


This will enable the multi input quirk for the Atari Adpater. If you are using the NES or SNES adapter then the middle value is the USB Device ID so just change it to match.

And there you go!! When plugged in the device now adds two fully functioning Joysticks :-). You don't need the hid-atari-retrobit driver at all to get this working.

Hope this has helped someone and thanks for all the work that people have already done as this really helped get this thing working.

Happy Emulating!

Matt.
Posts: 12
Joined: Sun Jan 05, 2014 9:19 pm
by teeth_03 » Fri Jan 17, 2014 11:56 am
Not guessing you would upload the files that were compiled from this fix for those not comfortable with recompiling?
Posts: 284
Joined: Sat Sep 08, 2012 12:02 am
by Croccy22 » Fri Jan 17, 2014 12:03 pm
Yeah I don't see why not, it's all open source. I'm not at home at the moment but when I get back later I'll zip it all up and upload it somewhere.

Will then just be a case of copying the kernel image into the /boot folder. copy the 3.10.26+ folder into the /lib/modules folder. And then editing the cmdline.txt file as above.

Have now had some chance to do some testing and it all seems fine. Works perfect with the Fuse Emulator. Unfortunately the UnrealSpeccy emulator only support one joystick at the moment so it very much depends on the emualtor you wish to use. But at least in Linux you will have js0 and js1 input devices.

Matt.
Posts: 12
Joined: Sun Jan 05, 2014 9:19 pm
by Croccy22 » Fri Jan 17, 2014 6:16 pm
Hi,

Have uploaded the files you need now. https://www.dropbox.com/s/51qwrvz85mful ... .26%2B.tar

Download and un compress. Copy the kernel.img file into your /boot folder and overwrite the existing file. Then copy the 3.10.26+ folder to the /lib/modules directory on the pi.

Edit the /boot/cmdline.txt file and add usbhid.quirks=0x1292:0x4154:0x040 to the end of the line of text. Save the file and reboot your pi.

Let me know if it all works for you.

Matt.
Posts: 12
Joined: Sun Jan 05, 2014 9:19 pm
by JTCook » Sun Jan 19, 2014 3:57 am
Great work! I just tried it an confirm it works with the USB to dual Atari/Genesis dual adapters. Thank you for you work on this and thank you for including compiled binaries and instructions. Now we just need to get this included in the official distro! :D
Posts: 16
Joined: Tue Nov 12, 2013 1:53 am
by sviudes » Sat Mar 08, 2014 12:35 pm
Croccy22 it worker for me! Thaaaaannnkkksss!! :D :D :D
Posts: 4
Joined: Tue Dec 24, 2013 4:16 pm
by cdtpepette » Sat Mar 15, 2014 1:09 pm
Thanks for your help left and up control now works with THT Arcade console 2P USB Player.
However I'm not able to configure the 2nd player on final burn alpha pi.
THT Arcade console 2P USB Player is detected as only one joystick "js0" with 4 axes and 22 buttons.

jstest /dev/input/js0
Axes: 0: 0 1: 0 2: 0 3: 0 Buttons: 0:off 1:off 2:off 3:off 4:off 5:off 6:off 7:off 8:off 9:off 10:off 11:off 12:off 13:off 14:off 15:off 16:off 17:off 18:off 19:off 20:off 21:off

Every axes and buttons works in the test but when I try to use axes 2 and 3 and buttons 10 to 17 for the 2nd player in configuration it doesn't work.
Thanks for your help.
Posts: 2
Joined: Sat Mar 15, 2014 12:57 pm
by roquen » Fri Aug 08, 2014 12:15 am
can we get a new version of this compiled, or even better, added to the debian distro entirely?
Posts: 2
Joined: Tue Jan 14, 2014 4:59 am
by allroy1975 » Wed Sep 10, 2014 3:25 am
hmmm....any chance we could get a re-post? I just got my adapter after accidentally ordering the original controllers....then go to plug them in....dang! Running the latest retropie....and I'm stuck. :( I don't know enough about compiling linux, but I can certainly FTP some files over the old ones. :)

Please?
Posts: 1
Joined: Wed Sep 10, 2014 3:22 am
by goochbuntu » Fri Oct 10, 2014 6:40 am
it would be nice if you can fix that download lilnk to that kernel.img

dang thing tried to recompile mine and i couldnt get it to work right
Posts: 1
Joined: Fri Oct 10, 2014 6:33 am
by siemprepe » Thu Oct 16, 2014 7:02 am
I have a compiled kernel and modules containing the fix. It was built on 10-16-2014 and works.
If you still need it, let me know.
Posts: 1
Joined: Thu Oct 16, 2014 7:00 am
by bertdotself » Sun Oct 19, 2014 3:07 am
@siemprepe, if you could please post a link to this archive.

I am having the same problem with a Retrobit NES USB Adapter

Thanks much!
Posts: 1
Joined: Sun Oct 19, 2014 3:05 am
by Croccy22 » Tue Nov 04, 2014 3:59 pm
Hi guys,

Not been around the forums for a while so didn't see the messages. Sorry I deleted the file :P. I had a tidy up of my dropbox account and removed loads of stuff that I couldn't remember what it was! This was obviously one of those things, ooops!

I am currently working on fitting a pi to an old C64 and will almost certainly be using one of these adapters again so I will need to go through this process within the next couple of weeks. Once I have done so I will try and remember to post the latest kernel image.

Matt.
Posts: 12
Joined: Sun Jan 05, 2014 9:19 pm
by Gombly » Tue Nov 11, 2014 4:18 am
Hey Croccy22 or whom ever ;)

I'm compiling to 3.17.y and I'm getting errors when I change the code specified in Croccy22's reference under hid-input.c:
Code: Select all
if ((field->flags & HID_MAIN_ITEM_VARIABLE) &&
(value < field->logical_minimum ||
value > field->logical_maximum)) {
if(value < logical_minimum)
value=field->logical_minimum;
else
value= field->logical_maximum;
}


What I'm actually getting is that the system thinks that field->logical_minimum is undefined. I assume this would be the same with logical_maximum as well if it could get that far.

Any idea why this is happening? I'm not familiar enough with hardware to know where the logicals would be set.
Posts: 2
Joined: Tue Nov 11, 2014 4:12 am
by Gombly » Tue Nov 11, 2014 4:27 am
OMG just figured out the problem. There was a typo in the code listing. Just added 'field->' before a logical_minimum call and it compiles...

Thanks and sorry.

Maybe we should commit this back over to git.
Posts: 2
Joined: Tue Nov 11, 2014 4:12 am
by Croccy22 » Tue Dec 02, 2014 5:51 pm
Just recompiled this with the latest kernel version ( 3.12.33+)

Download kernel from here: https://dl.dropboxusercontent.com/u/79402220/kernel.img

and then the modules from here: https://dl.dropboxusercontent.com/u/794 ... odules.tgz

Copy both files over the /tmp folder on your raspberry pi.

SSH onto your raspberry pi and type the following:
cd /
sudo mv /tmp/kernel.img /boot/
sudo tar xzf /tmp/modules.tgz
rm /tmp/modules.tgz

now edit the /boot/cmdline.txt and add the [b]usbhid.quirks=0x1292:0x4154:0x040[/b] to the end of the line of text within that file.

Reboot the pi and all should work :)

Matt.
Posts: 12
Joined: Sun Jan 05, 2014 9:19 pm
by Solid One » Mon Dec 22, 2014 12:54 am
Thanks for your solution. I have a Retrolink cable for Genesis controller, and your compiled kernel w/ these settings worked nicely. Now I can play Genesis games on Retropie! Awesome!
Posts: 3
Joined: Mon Dec 22, 2014 12:17 am
by sviudes » Tue Dec 23, 2014 7:05 pm
Croccy22 thanks for upload the updated version :!:
Posts: 4
Joined: Tue Dec 24, 2013 4:16 pm
by toxibunny » Tue Dec 23, 2014 10:54 pm
Yeah, thanks! *bookmarked*
note: I may or may not know what I'm talking about...
Posts: 1383
Joined: Thu Aug 18, 2011 9:21 pm
by Solid One » Sat Dec 27, 2014 3:21 pm
I'm getting a bug on this pre-made kernel: There's no sound.

Explaining with more details: I'm using Retropie, previously with kernel 3.12.22+. Since my genesis controllers weren't working, I downloaded your kernel 3.12.33+ with all modules included. Unpacked everything on the folders, and then my controller worked.

However, using your compiled kernel 3.12.33++ with specified modules, sound isn't working anymore. I've made a few tests with a few commands, and everything seems to say that the problem happened on your kernel:
'alsamixer' command returns that:
Code: Select all
pi@raspberrypi ~ $ alsamixer
Cannot open mixer: File or directory not found

Modprobbing 'snd_bcm2835' module gives me that:
Code: Select all
pi@raspberrypi ~ $ sudo modprobe snd_bcm2835
libkmod: ERROR ../libkmod/libkmod-module.c:174 kmod_module_parse_depline: ctx=0xb7f78008 path=/lib/modules/3.12.33+/kernel/sound/core/snd-pcm.ko error=No such file or directory
libkmod: ERROR ../libkmod/libkmod-module.c:174 kmod_module_parse_depline: ctx=0xb7f78008 path=/lib/modules/3.12.33+/kernel/sound/core/snd-pcm.ko error=No such file or directory
ERROR: could not insert 'snd_bcm2835': Unknown symbol in module, or unknown parameter (see dmesg)

Tried copying module files from older kernel and then re-modprobbing 'snd_bcm2835' module, and then it gives me that:
Code: Select all
pi@raspberrypi ~ $ cp -r /lib/modules/3.12.22+/kernel/sound /lib/modules/3.12.33+/kernel/
pi@raspberrypi ~ $ sudo modprobe snd_bcm2835
ERROR: could not insert 'snd': Exec format error
libkmod: ERROR ../libkmod/libkmod-module.c:925 command_do: Error running install command for snd
ERROR: could not insert 'snd_bcm2835': Operation not permitted

For now, I can go back to previous kernel, and sound will work. But anyone know a way to make sound work on this kernel?

EDIT: Nevermind. Compiled the kernel myself with changes above. But it's interesting to say that compiling kernel from RPI itself takes more than 5 hours, and doing cross-compile from a Ubuntu desktop installation takes less than 10 minutes. WOW.
Posts: 3
Joined: Mon Dec 22, 2014 12:17 am
by feederchain » Sun Feb 15, 2015 6:20 pm
Anyone successfully compile for 3.18.7? I tried to compile on my own and no change, tried cross compiling... No change. I've never bothered updating my pi once I got this all running, but I wanted to upgrade to a pi2 to see if it made some emulators run faster.

I went through the entire kernel compile process, changing the code before hand of course, once I reboot it states that my new kernel is running, but it's as if I did nothing.

The weird thing is that it appears that my left and down buttons are acting odd as well. They seem to be pulsing between 32767 and 0 when held. Whereas the rest of the buttons just stay on.

I'm feeling very much the idiot, because this should have been a relatively easy process.

Thanks
Posts: 14
Joined: Sun Feb 15, 2015 6:08 pm
by feederchain » Mon Feb 16, 2015 1:52 am
OK got the compile to work properly. I don't think the code matches up with what was there previously. So here's a snippet from the patch file.

Code: Select all
-      dbg_hid("Ignoring out-of-range value %x\n", value);
-      return;
+      if(value < field->logical_minimum)
+                  value = field->logical_minimum;
+           else
+                  value = field->logical_maximum;


This at least gets all the axis buttons recognised. I still have the pulsing issue. Looking into that next.
Posts: 14
Joined: Sun Feb 15, 2015 6:08 pm
by feederchain » Mon Feb 16, 2015 4:05 pm
I think I fixed the pulsing issue. It involves another change to hid-input.c.

Remove the code that was put in with the following commit.

https://github.com/raspberrypi/linux/co ... b7f9a46888
Posts: 14
Joined: Sun Feb 15, 2015 6:08 pm
by david8704 » Sat Mar 07, 2015 6:36 pm
Did you got it to work with retro-link? I wan't to buy one, but only if it works... :D
Posts: 1
Joined: Sat Mar 07, 2015 6:34 pm
by feederchain » Sat Mar 07, 2015 10:50 pm
Yep, successfully got everything working with this

http://www.amazon.com/Retro-Bit-Genesis-PC-USB-Cable-Sega/dp/B0080RAT42/ref=pd_sxp_f_pt

I've also posted the custom kernel that I compiled with the changes if you want to save yourself some time.

http://blog.petrockblock.com/forums/topic/autofire-on-the-axis/#post-90318
Posts: 14
Joined: Sun Feb 15, 2015 6:08 pm