Thursday, April 3, 2008

WRTSL54GS i-force joystick

I was able to get my WRTSL54GS to read my Saitek ST290 joystick as well as a mouse. I had problems at first getting it to read, and I think it was a conflict with USB 2.0

First download the newest bleeding edge version of OpenWRT. How to do this has been posted many times but for completion,

make a folder with


$mkdir Kamikaze
$cd Kamikaze
$svn co svn://svn.openwrt.org/openwrt/trunk/
$make menuconfig


Well, I can't upload the code for the moment so I'll just save it away and post it later.

4/18/09

Well, its been a damn long time, and this has taught me the valuable lesson of writing down the steps I take to make something happen, or else I might forget as I have this time and it has forced me to re-figure out how I got this to work in the first place. The main problem I had, and have, is that I don't think I'm entirely sure how the OpenWRT makefile system works.

Well, assuming you have directory named trunk where all of your openwrt stuff is type

make menuconfig


make sure the following settings are set

Target System (Broadcom BCM947xx/953xx [2.6])
Target Profile (Linksys WRTSL54GS)

Kernel modules --->
Other modules --->
kmod-hid
kmod-input-core
kmod-input-evdev
USB Support --->
kmod-usb-core
kmod-usb-ohci
kmod-usb-storage
kmod-usb2


Then press escape key twice
Now type

make kernel_menuconfig


Then make sure the following are selected


[*] Enable lodable module support --->
[*] Enable the block layer --->
[*] Networking support --->

Device Drivers--->
Input device support--->
Generic input layer (needed for keyboard, mouse, ...)
Polled input device skeleton
Mouse interface
Joystick interface
Event interface
<*>Joysticks/Gamepads--->
I-force devices
[*]HID devices
[*]USB support


If I didn't mention something then it may have been set by default, or if I did and it was already set, no harm done.

Then press esc esc. It will then start to do some basic writing of configurations through the makefile process. (I think) Then it will say
I-Force devices (JOYSTICK_IFORCE) [M/n/?] m
I-Force USB joysticks and wheels (JOYSTICK_IFORCE_USB) [N/y/?] (NEW)

type yes. I'm not sure why this comes up. As I do more research with this project, I'll try and figure more of how it actually works.

It will then finish.

then type

make V=99


The V=99 is very important as it will prompt you for different things during the make process.

such as the joystick thing mentioned above, type yes again. It will do this twice during the make process.

once its done, we're going to upload the new firmware to the WRTSL54GS. If you don't already have it make sure you have atftp. If you're running a system with apt-get use the following.


sudo apt-get install atftp


Then pull up two terminals. Connect the WRTSL54GS to the same router or switch or hub that your computer is connected to. You can do it directly but its more a pain in the butt as you have to set your computer to a static IP address. Also, change your router's ipaddress to something other than 192.168.1.1 as that is what the WRTSL54GS defaults to during loading and during a hard reset if its is necessary to do so.

so in one window

ping 192.168.1.1


And in the other window

$cd bin
$atftp
tftp> connect 192.168.1.1
tftp> mode octet
tftp> trace
Trace mode on.
tftp> put openwrt-wrtsl54gs-squashfs.bin


Now wait and don't press enter. Disconnect the WRT and you should see no response in the window that is pinging the device. Click on the terminal that is running atftp, so you are ready to press enter. Plug the device in and as soon as you get a response from 192.168.1.1 in 1 window, press enter and write the new firmware to the device. If for some reason you are having troubles, try pushing in a small pin in the hole next to the power supply hole on the WRT as you are pushing in the power, this will put the WRT into a type of safe mode that may help with the loading. Now assuming all went well you should get this

.
.
.
sent DATA
received ACK
.
.
.
sent DATA
received ACK
tftp>


I'm assuming it should end in about the same block size.

type quit in the atftp window to exit that program and go to the terminal that was pinging, press
ctrl-c to stop it and then try telnet 192.168.1.1

you should be greeted by the OpenWrt prompt.

type passwd to set your password as we have to move some files over using scp.

so


root@OpenWrt:/# passwd
Changing password for root
New password:
Bad password: too weak
Retype password:
Password for root changed by root
root@OpenWrt:/# exit



ssh root@192.168.1.1
$ ssh root@192.168.1.1
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
59:b6:61:9b:88:60:d0:af:c1:16:9a:02:f2:bb:76:82.
Please contact your system administrator.
Add correct host key in /home/santiago/.ssh/known_hosts to get rid of this message.
Offending key in /home/santiago/.ssh/known_hosts:1
RSA host key for 192.168.1.1 has changed and you have requested strict checking.
Host key verification failed.

If you get the above, just do

$rm /home/santiago/.ssh/known_hosts
$ssh root@192.168.1.1
The authenticity of host '192.168.1.1 (192.168.1.1)' can't be established.
RSA key fingerprint is 59:b6:61:9b:88:60:d0:af:c1:16:9a:02:f2:bb:76:82.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.1' (RSA) to the list of known hosts.
root@192.168.1.1's password:

After typing in your password you should be back to OpenWRT prompt.

Now go back to your directory where you just uploaded OpenWRT
should be
~/Kamikaze/trunk/bin$
now

$cd packages/target-mipsel_uClibc-0.9.29/
scp kmod-usb-core_2.6.28.9-brcm47xx-1_mipsel.ipk kmod-usb-hid_2.6.28.9-brcm47xx-1_mipsel.ipk kmod-input-core_2.6.28.9-brcm47xx-1_mipsel.ipk kmod-input-evdev_2.6.28.9-brcm47xx-1_mipsel.ipk kmod-usb-ohci_2.6.28.9-brcm47xx-1_mipsel.ipk kmod-hid_2.6.28.9-brcm47xx-1_mipsel.ipk root@192.168.1.1:/home

By the time you try this OpenWRT may have moved on to a different kernel version, so don't worry if the numbers don't match, just type in scp followed by the first part of the module and use tab completion to finish it. In other words use the same modules for your version of the kernel.

Now in the terminal that has OpenWRT open,

root@OpenWrt:/home# opkg install kmod-usb-core_2.6.28.9-brcm47xx-1_mipsel.ipk km
od-input-core_2.6.28.9-brcm47xx-1_mipsel.ipk kmod-input-evdev_2.6.28.9-brcm47xx-
1_mipsel.ipk kmod-hid_2.6.28.9-brcm47xx-1_mipsel.ipk kmod-usb-ohci_2.6.28.9-brcm
47xx-1_mipsel.ipk kmod-usb-hid_2.6.28.9-brcm47xx-1_mipsel.ipk

They have to be installed in that order as some depend on others.
Now in openWRT

root@OpenWrt:/home#cd /lib/modules/2.6.28.9

Then back on your own machine, on the

$cd ~/Kamikaze/trunk/build_dir/linux-brcm47xx/linux-2.6.28.9/drivers/input
$scp joydev.ko root@192.168.1.1:/lib/modules/2.6.28.9/
$cd joystick/iforce
$scp iforce.ko root@192.168.1.1:/lib/modules/2.6.28.9/

Now back in the terminal with openWRT

$cd /lib/modules/2.6.28.9/
$insmod joydev.ko
$insmod iforce.ko

Now plug in the joystick and type in dmesg

$dmesg
.
.
.
usbcore: registered new interface driver iforce
usb 1-1: new full speed USB device using ohci_hcd and address 2
usb 1-1: configuration #1 chosen from 1 choice
drivers/input/joystick/iforce/iforce-packets.c: info cmd = ff01, data = 43
drivers/input/joystick/iforce/iforce-packets.c: info cmd = ff03, data = 45 00 01
drivers/input/joystick/iforce/iforce-packets.c: info cmd = ff01, data = 4f
drivers/input/joystick/iforce/iforce-packets.c: info cmd = ff04, data = 56 02 05 00
input: AVB Top Shot Pegasus as /devices/pci0000:00/0000:00:02.0/usb1/1-1/input/input0

Now lets give it a quick test. Still in OpenWRT


$cd /dev
root@OpenWrt:/dev# ls
1-1 mtd3ro shm
console mtd4 tty
cpu_dma_latency mtd4ro ttyS0
event0 mtdblock0 ttyS1
full mtdblock1 urandom
input mtdblock2 usb1
js0 mtdblock3 usb2
kmsg mtdblock4 usbdev1.1_ep00
log network_latency usbdev1.1_ep81
mem network_throughput usbdev1.2_ep00
mtd0 null usbdev1.2_ep01
mtd0ro port usbdev1.2_ep82
mtd1 ppp usbdev2.1_ep00
mtd1ro ptmx usbdev2.1_ep81
mtd2 pts zero
mtd2ro random
mtd3 root
root@OpenWrt:/dev#cat js0
|��|��|��|��|��|��|��|��|�|��|����|��|��|��|��|��|�������������������
���$�,���D�L���T�\���|�����������������������������������
����L��T���d��l���t�|������������������������������
����$���L�T���d�l������������������������
���$��,���^C

The ^c at the end if me pressing ctrl-c to stop the output. Obviously this isn't the way you want it to use the device. but it shows that it is being recognized and is working. In order to get more than that you need to have a test program such as jscal installed. I'll put details for that later, as I already know how to do it and it won't take long to put that one up.

No comments: