OESF | ELSI | pdaXrom | OpenZaurus | Zaurus Themes | Community Links | Ibiblio

IPB

Welcome Guest ( Log In | Register )

> Usb Connection Howto, Windows & Linux - OE specific
lardman
post Apr 7 2005, 06:03 AM
Post #1





Group: Members
Posts: 4,515
Joined: 25-October 03
From: Bath, UK
Member No.: 464



Another pinned topic :-)

Let's nail setting up USB connections between a Z and a PC (running WinXP or Linux), which is a basic thing which ought to be documented (and which comes up from time to time).

What we need is:
* Your Z (hardware, OZ version, kernel version)
* Your PC OS (including kernel version/service pack/etc.)
* Where you got the drivers from (if needed)
* What changes you made on the PC (if any, mainly for Linux)
* What changes you made on your Z (if any)

Cheers,


Si

P.S. I know there are already HowTos in the ZUG HowTos area, however these generally apply to Sharp ROMs (and although there may not be many differences, there are enough).

By all means, lift the info from there if it works, it'll go back in there once this is all sorted.
Go to the top of the page
 
+Quote Post
 
Start new topic
Replies
7_feet_up
post Dec 17 2005, 09:08 AM
Post #2





Group: Members
Posts: 27
Joined: 19-April 05
From: Netherlands
Member No.: 6,917



Debian unstable Zaurus USB-network how-to:
Install the latest stock kernel for your machine class e.g.:
CODE
user@desktop:~# sudo apt-get install linux-image-2.6.14-2-686

Reboot.
Plug in the zaurus and see if it was recognized by your computer. By issueing the command 'tail /var/log/messages' you will see the last few lines of your system log. You should see that an usb device was connected, the 'zaurus' module was loaded and that your zaurus was recognized:
CODE
user@desktop:~# tail /var/log/messages
Dec 17 17:35:58 localhost kernel: usb 2-2: new full speed USB device using uhci_hcd and address 10
Dec 17 17:35:58 localhost kernel: usb0: register 'zaurus' at usb-0000:00:10.0-2, pseudo-MDLM (BLAN) device, 52:8c:8b:4f:e4:90

Find that the module was loaded:
CODE
user@desktop:~# lsmod | grep zaurus
usbnet                 17064  2 zaurus,cdc_ether

You'll probably have one or two more lines containing the word 'zaurus', but you definitely should have this line here. If not, something went wrong with loading the module.
An 'ifconfig -a' should give you a usb0 network interface, which isn't configured yet. There may be more network interfaces depending on your system, but usb0 should definitely be there.
CODE
user@desktop:~# ifconfig -a
usb0      Link encap:Ethernet  HWaddr 52:8C:8B:4F:E4:90
         BROADCAST MULTICAST  MTU:1500  Metric:1
         RX packets:0 errors:0 dropped:0 overruns:0 frame:0
         TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:1000
         RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

Now we'll configure the network interface of the zaurus and your linux computer. We'll give your computer and your zaurus a static IP.
First your zaurus:

Start 'Network' in your Settings dir. Click on the interface 'usbd0' and click configure.

Fill in the Following:

(X) Automatically bring up
( ) DHCP

Static Ip Configuration
IP Address 192.168.129.201
Subnet Mask 255.255.255.0

Leave the rest empty for now.

On your linux computer type the following:
CODE
sudo ifconfig usb0 192.168.129.200 netmask 255.255.255.0 up

This should configure your USB network interface and bring it up. Now we'll try if we can reach the zaurus. We'll do this by pinging it's IP address (the command should be stopped by typing Ctrl-c or it will go on forever):
CODE
user@desktop:~# ping 192.168.129.201
PING 192.168.129.201 (192.168.129.201) 56(84) bytes of data.
64 bytes from 192.168.129.201: icmp_seq=1 ttl=64 time=0.108 ms
64 bytes from 192.168.129.201: icmp_seq=2 ttl=64 time=0.094 ms
64 bytes from 192.168.129.201: icmp_seq=3 ttl=64 time=0.090 ms
64 bytes from 192.168.129.201: icmp_seq=4 ttl=64 time=0.089 ms
64 bytes from 192.168.129.201: icmp_seq=5 ttl=64 time=0.093 ms

--- 192.168.129.201 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 3998ms
rtt min/avg/max/mdev = 0.089/0.094/0.108/0.014 ms

Now we will make your configuration permanent. You don't want to type 'ifconfig usb0 192.168.129.200 netmask 255.255.255.0 up' to use your zaurus all the time, and you'll probably just want to stick it in to be able to use it. There are (at least) two ways to accomplish this task:
1. by adding an entry for the usb interface in the file /etc/network/interfaces, or
2. by writing a new udev rule that configures the usb interface

1. The first option is the easiest and, in my opinion, the cleanest. As root, add the following lines to the file /etc/network/interfaces:
CODE
allow-hotplug usb0
mapping hotplug
       script grep
       map usb0

iface usb0 inet static
address 192.168.129.200
netmask 255.255.255.0
pointopoint 192.168.129.201


2. The second option also works, but should be considered a hack. So you'd better skip this one. I will leave it in this post for historical purposes though, since untill I found out about the option printed above this was the only way I could bring up the usb interface automatically. It requires writing a new udev rule that configures the usb interface based on 2 keys: the kernel device name (e.g. usb0) and the driver used, that is 'zaurus'. You actually could omit this key, but then this rule would interfere with other devices with a usb* device name (probably usb networking devices), if you owned such a device. (It appeared that the hardware address used in a previous version of this post changes every other time you reboot your machine. Since the address isn't permanent, it isn't suitable as a key.)

So, as root, create the file /etc/udev/zaurus.rules and add the following line:
CODE
KERNEL=="usb[0-9]*", DRIVER="zaurus", NAME="%k", SYMLINK="zaurus", RUN+="/sbin/ifconfig %k 192.168.129.200 netmask 255.255.255.0 up"


and symlink it to the directory /etc/udev/rules.d:
CODE
$ cd /etc/udev/rules.d
user@desktop:~# sudo ln -s ../zaurus.rules 10_zaurus.rules


Now restart the udev daemon:
CODE
user@desktop:~# sudo /etc/init.d/udev restart

This will ensure that every time your zaurus hits the cradle the network connection will be started.

If your connection to the zaurus often hangs for no apparent reason, consider shrinking the MTU on the zaurus:
CODE
root@zaurus:~# ifconfig usb0 mtu 1000

To make the change permanent, even after rebooting, add the line "mtu 1000" to the section of the usbd0 network interface in the /etc/network/interfaces file.

Folkert van der Beek.


*edit: modified the udev rule, so it won't interfere with other usb networking devices.
*edit2: modified the udev rule to identify the zaurus based on the driver in stead of the hardware address, since the latter apparently changes after every reboot.
*edit3: added the option to modify /etc/network/interfaces, instead of writing an udev rule.
*edit4: added the option to shrink the MTU to prevent freezing connections.
Go to the top of the page
 
+Quote Post
Storm
post Jan 30 2006, 02:24 PM
Post #3





Group: Members
Posts: 156
Joined: 29-March 05
From: Virginia
Member No.: 6,736



QUOTE(7_feet_up @ Dec 17 2005, 01:08 PM)
Debian unstable Zaurus USB-network how-to:
Install the latest stock kernel for your machine class e.g.:
CODE
$ sudo apt-get install linux-image-2.6.14-2-686



Excellent howto, 7_feet_up. I have questions, since it does not seem to work for me. I'm running Debian stable on an HP laptop, with kernel 2.6.15 (I just upgraded from 2.6.12, where the problem existed as well). Everything works manually, but although I followed all of the steps to get it to come up automagically, it doesn't.

lsmod shows:

CODE
[riogrande ~]# lsmod | grep zaurus
zaurus                  4096  0
cdc_ether               4352  1 zaurus
usbnet                 11528  2 zaurus,cdc_ether


I also created /etc/udev/zaurus.rules and symlinked it to /etc/udev/rules.d/, and added usb0 to /etc/network/interfaces:

CODE
auto usb0
iface usb0 inet static
       address 192.168.129.1
       pointopoint 192.168.129.1
       netmask 255.255.255.255
       pre-up modprobe zaurus
       post-down rmmod zaurus


When I put the Zaurus in the dock, I get:

CODE
Jan 30 12:59:35 localhost kernel: usb 4-5.4: new full speed USB device using ehci_hcd and address 10
Jan 30 12:59:35 localhost kernel: usb0: register 'zaurus' at usb-0000:00:1d.7-5.4, Sharp Zaurus SL-5x00, 0a:95:46:a6:00:af


At this point, I can bring up usb0 and assign it an address, but it is by no means automatic.

One thing I noticed. The beginning of your /etc/udev/zaurus starts with KERNEL=="usb[0-9]*". Does this look for /dev/usb[0-9]? Because on my system, these devices do not appear. Is this a normal occurrence?

Once I get this up and working, I would like to append something like the following to bring up out-to-the-internet connectivity for the zaurus:

CODE
#!/bin/sh
# Determine external interface.
EXTIF="`/bin/netstat -rn | grep ^0.0.0.0 | awk '{ print $8}'`"
  echo 1 > /proc/sys/net/ipv4/ip_forward
  iptables -t filter -F FORWARD
  iptables -t filter -P FORWARD DROP
  iptables -t filter -A FORWARD -s 192.168.129.0/24 -j ACCEPT
  iptables -t filter -A FORWARD -d 192.168.129.0/24 -j ACCEPT
  iptables -t nat -F PREROUTING
  iptables -t nat -P PREROUTING ACCEPT
  iptables -t nat -F POSTROUTING
  iptables -t nat -P POSTROUTING ACCEPT
  iptables -t nat -F OUTPUT
  iptables -t nat -P OUTPUT ACCEPT
  iptables -t nat -A POSTROUTING -s 192.168.129.0/24 -o $EXTIF -j MASQUERADE


But one step at a time...

--Storm
Go to the top of the page
 
+Quote Post
7_feet_up
post Mar 20 2006, 01:24 PM
Post #4





Group: Members
Posts: 27
Joined: 19-April 05
From: Netherlands
Member No.: 6,917



QUOTE(Storm @ Jan 30 2006, 11:24 PM)
<snip>
I have questions, since it does not seem to work for me.
<snip>

Sorry about the late reply. I don't regularly check this thread, so you could as well have solved the issue by now. Anyway, I updated the howto. Just delete the udev rule and add the lines to /etc/network/interfaces as described in the howto.
QUOTE(Storm @ Jan 30 2006, 11:24 PM)
Once I get this up and working, I would like to append something like the following to bring up out-to-the-internet connectivity for the zaurus:
<snip>
But one step at a time...

--Storm

To run commands after the interface has been brought up, use the 'up' command in /etc/network/interfaces, and the 'post-down' command after taking the interface down:
CODE
allow-hotplug usb0
mapping hotplug
      script grep
      map usb0

iface usb0 inet static
address 192.168.129.200
netmask 255.255.255.0
pointopoint 192.168.129.201

pre-up modprobe iptable_filter
pre-up modprobe iptable_nat
pre-up modprobe ip_nat_ftp
pre-up modprobe ip_conntrack_ftp
pre-up modprobe ip_conntrack_irc
pre-up modprobe ip_nat_irc
up echo "1" > /proc/sys/net/ipv4/ip_forward
up iptables -t filter -F FORWARD
up iptables -t filter -P FORWARD DROP
up iptables -t filter -A FORWARD -s 192.168.129.0/24 -j ACCEPT
up iptables -t filter -A FORWARD -d 192.168.129.0/24 -j ACCEPT
up iptables -t nat -F PREROUTING
up iptables -t nat -P PREROUTING ACCEPT
up iptables -t nat -F POSTROUTING
up iptables -t nat -P POSTROUTING ACCEPT
up iptables -t nat -F OUTPUT
up iptables -t nat -P OUTPUT ACCEPT
up iptables -t nat -A POSTROUTING -s 192.168.129.0/24 -o usb0 -j MASQUERADE
post-down echo "0" > /proc/sys/net/ipv4/ip_forward
post-down iptables -t nat -F

Folkert.
Go to the top of the page
 
+Quote Post

Posts in this topic
lardman   Usb Connection Howto   Apr 7 2005, 06:03 AM
lardman   Zaurus - C750, 2.6.11 kernel, OZ 3.5.3pre (probabl...   Apr 7 2005, 06:07 AM
darac   Zaurus: SL-5500 (Collie) Hentges.net ROM T7 (based...   Apr 13 2005, 12:45 PM
obergix   QUOTE(darac @ Apr 13 2005, 10:45 PM)Add the f...   May 18 2005, 12:15 AM
gfdsa   Zaurus: SL-600L, OZ 3.5.2, Dock Station PC: WinXP ...   Apr 14 2005, 08:58 AM
jancici   hi, for me this is not working, I can remember tha...   Apr 17 2005, 01:30 PM
lardman   Start a seperate thread please, this thread is jus...   Apr 18 2005, 12:10 AM
lardman   Zaurus: OZ 3.5.3 C7x0 with 2.4.18 kernel (GPE onl...   Apr 18 2005, 01:13 AM
dansawyer   The howto is very helpful as it is. I would sugge...   May 26 2005, 05:56 AM
niv   Windowz: you may want to use NT/2000/XP routing to...   Jun 19 2005, 05:48 PM
charcler   HELLO sysops... gurus... wanna.. new... all ;) M...   Aug 4 2005, 07:50 PM
ajaygautam   Z: SL5500, OZ 3.5.3,2.4.18-rmk7-pxa3-embedix PC: G...   Aug 11 2005, 10:47 AM
NickNak   Using an ethernet bridge to plug your Zaurus into ...   Sep 14 2005, 08:56 AM
Headrush   QUOTE(NickNak @ Sep 14 2005, 11:56 AM)Using a...   Sep 19 2005, 02:11 PM
jan   QUOTE(NickNak @ Sep 14 2005, 06:56 PM)Using a...   Feb 19 2006, 12:51 PM
NickNak   Using this method, usb0 and eth0 do not need IP ad...   Sep 19 2005, 02:31 PM
Headrush   I had this usbd connection working perfectly and t...   Dec 4 2005, 12:41 PM
lardman   No, no, no, no, no - this is a thread giving detai...   Dec 5 2005, 03:32 AM
7_feet_up   Debian unstable Zaurus USB-network how-to: Install...   Dec 17 2005, 09:08 AM
Storm   QUOTE(7_feet_up @ Dec 17 2005, 01:08 PM)Debia...   Jan 30 2006, 02:24 PM
7_feet_up   QUOTE(Storm @ Jan 30 2006, 11:24 PM)<snip...   Mar 20 2006, 01:24 PM
microsoft/linux   what happens if the usbnet driver is built into my...   Jan 22 2006, 09:49 PM
7_feet_up   QUOTE(microsoft/linux @ Jan 23 2006, 06:49 AM...   Jan 24 2006, 03:00 AM
microsoft/linux   ok, I changed GUIs, after I updated to 3.5.4. Now ...   Mar 20 2006, 09:11 PM
pgas   PC: windows XP Zaurus: 860 oz/gpe 3.5.4 2.6 kernel...   Mar 20 2006, 11:42 PM
jerrybme   QUOTE(pgas @ Mar 21 2006, 01:42 AM)PC: window...   Mar 24 2006, 07:05 AM
GenericAnimeBoy   For those of us poor fools who have to internet co...   Mar 21 2006, 10:34 PM
papercrane   The Cxx00 doesn't talk to Windows correctly ye...   Mar 29 2006, 12:32 PM
Tron   QUOTE(papercrane @ Mar 29 2006, 10:32 PM)The ...   Apr 4 2006, 12:25 AM
nick88   Hi, I followed the shell scripts and can ping a...   Apr 6 2006, 05:20 PM
telemetric_au   followed 7_feet_up's guide (thanks) and it wou...   Apr 17 2006, 06:33 AM
telemetric_au   well after mucking aroun some i cant get my z to p...   Apr 17 2006, 07:11 AM
telemetric_au   I GOT IT WORKING !!! --finally after ...   Apr 18 2006, 04:17 AM
telemetric_au   Just to make life even more sweet, i just set the ...   Apr 18 2006, 04:44 AM
telemetric_au   i just added an updated bridging guide to the wik...   Apr 28 2006, 03:25 PM
lardman   Please add stuff to the official OZ wiki: http://o...   Apr 29 2006, 02:03 PM
telemetric_au   trying to do it now, but the server is soooo slow....   Apr 29 2006, 02:25 PM
NickNak   I have run into problems with my bridging setup: ...   May 1 2006, 12:17 PM
7_feet_up   QUOTE(NickNak @ May 1 2006, 09:17 PM)I have r...   May 3 2006, 02:32 AM
telemetric_au   sorry, but i have no experience with that problem ...   May 2 2006, 03:09 PM
NickNak   The "USB Networking" howto submitted by ...   May 4 2006, 01:54 PM
telemetric_au   QUOTE(NickNak @ May 5 2006, 08:54 AM)The ...   May 4 2006, 03:04 PM
telemetric_au   NickNak: fixed up my title to debian rather than ...   May 4 2006, 03:20 PM
benplaut   waiting for an arch tutorial, all you arch users h...   Jul 18 2006, 06:51 PM
lardman   If someone fancies tidying up the info in this thr...   Jul 19 2006, 02:32 AM
speculatrix   I added some stuff which is somewhat 6000 specific...   Oct 10 2006, 05:38 AM
lardman   I'll have a look through, thanks Si   Oct 10 2006, 06:54 AM


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 23rd October 2014 - 05:06 AM