Author Topic: Usb Connection Howto  (Read 122319 times)

Headrush

  • Newbie
  • *
  • Posts: 4
    • View Profile
Usb Connection Howto
« Reply #15 on: December 04, 2005, 03:41:48 pm »
I had this usbd connection working perfectly and then something has changed and I can't figure it out.

I am on Gentoo and set up bridging like NickNak suggested. The PC has address 192.168.13.100 and the Zaurus gets 192.168.13.113.
My PC goes to a router @ 192.168.13.1

This is the dmesg on PC when Zaurus inserted into cradle

Code: [Select]
usb 4-1: new full speed USB device using uhci_hcd and address 15
usb0: register 'zaurus' at usb-0000:00:10.3-1, Sharp Zaurus SL-5x00, 36:78:db:4c:f0:41
device usb0 entered promiscuous mode
br0: port 2(usb0) entering learning state
br0: topology change detected, propagating
br0: port 2(usb0) entering forwarding state
I can ping the PC, and router without issue. I can also ping any web address by name or IP address.

If I do a traceroute to any web address I can see the packets routed properly.

If I try any network program on the Zaurus, they do nothing. Includes, ipkg, wget, konq-embedded. All the sites are working

Any ideas or suggestions?
« Last Edit: January 13, 2006, 02:36:22 am by Headrush »

lardman

  • Hero Member
  • *****
  • Posts: 4512
    • View Profile
    • http://people.bath.ac.uk/enpsgp/Zaurus/
Usb Connection Howto
« Reply #16 on: December 05, 2005, 06:32:48 am »
No, no, no, no, no - this is a thread giving details about how to get connections working, not to ask about how to get them working; start a new thread.
C750 OZ3.5.4 (GPE, 2.6.x kernel)
SL5500 OZ3.5.4 (Opie)
Nokia 770
Serial GPS, WCF-12, Socket Ethernet & BT, Ratoc USB
WinXP, Mandriva

7_feet_up

  • Newbie
  • *
  • Posts: 27
    • View Profile
    • http://
Usb Connection Howto
« Reply #17 on: December 17, 2005, 12:08:09 pm »
[span style=\'font-size:14pt;line-height:100%\']Debian unstable Zaurus USB-network how-to:[/span]
Install the latest stock kernel for your machine class e.g.:
Code: [Select]
user@desktop:~# sudo apt-get install linux-image-2.6.14-2-686Reboot.
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: [Select]
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: [Select]
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: [Select]
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: [Select]
sudo ifconfig usb0 192.168.129.200 netmask 255.255.255.0 upThis 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: [Select]
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: [Select]
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: [Select]
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: [Select]
$ cd /etc/udev/rules.d
user@desktop:~# sudo ln -s ../zaurus.rules 10_zaurus.rules

Now restart the udev daemon:
Code: [Select]
user@desktop:~# sudo /etc/init.d/udev restartThis 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: [Select]
root@zaurus:~# ifconfig usb0 mtu 1000To 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.

[span style=\'font-size:8pt;line-height:100%\']
*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.
[/span]
« Last Edit: March 21, 2006, 01:50:52 pm by 7_feet_up »
Zaurus SL-5600
OpenZaurus 3.5.4.2-rc2
Wireless LAN CF Card NL-2511CF MERCURY
Destinator CF GPS receiver
PEAK Compact Flash Card 512MB
SanDisk Standard SD Card 64 MB
Brandless SD Card 1 GB
Sharp Zaurus SL5500 3E-Piel Frama Luxury Black Tan leather PDA case
PSP Battery Pack PW-2992p

microsoft/linux

  • Full Member
  • ***
  • Posts: 237
    • View Profile
    • http://
Usb Connection Howto
« Reply #18 on: January 23, 2006, 12:49:50 am »
what happens if the usbnet driver is built into my kernel. I custom build my kernel, the scripts should still work right?
C3200(exiguitas) Angstrom Beta(version not designated)/GPE
SL-5500(immotus) OpenZaurus 3.5.4/GPE, OpenZaurus 3.5.4/Opie(loopmount)
1GB SD Card
128MB CF Card/8MB CF Card
Gentoo/Windows XP Home SP2

Numbers rule the Universe.
        --The Pythagoreans

Microsoft/Linux

7_feet_up

  • Newbie
  • *
  • Posts: 27
    • View Profile
    • http://
Usb Connection Howto
« Reply #19 on: January 24, 2006, 06:00:13 am »
Quote
what happens if the usbnet driver is built into my kernel. I custom build my kernel, the scripts should still work right?
[div align=\"right\"][a href=\"index.php?act=findpost&pid=112017\"][{POST_SNAPBACK}][/a][/div]
It shouldn't make a difference.
Zaurus SL-5600
OpenZaurus 3.5.4.2-rc2
Wireless LAN CF Card NL-2511CF MERCURY
Destinator CF GPS receiver
PEAK Compact Flash Card 512MB
SanDisk Standard SD Card 64 MB
Brandless SD Card 1 GB
Sharp Zaurus SL5500 3E-Piel Frama Luxury Black Tan leather PDA case
PSP Battery Pack PW-2992p

Storm

  • Full Member
  • ***
  • Posts: 156
    • View Profile
    • http://
Usb Connection Howto
« Reply #20 on: January 30, 2006, 05:24:42 pm »
Quote
[span style=\'font-size:14pt;line-height:100%\']Debian unstable Zaurus USB-network how-to:[/span]
Install the latest stock kernel for your machine class e.g.:
Code: [Select]
$ 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: [Select]
[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: [Select]
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: [Select]
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: [Select]
#!/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
Zaurus SL-5500/Hentges OZ 3.5.4.1
Ambicom WL1100-CF wireless card
Desktop: Debian/GNU Linux (unstable)

jan

  • Jr. Member
  • **
  • Posts: 87
    • View Profile
    • http://www.spacezone.de/zaurus/articles/
Usb Connection Howto
« Reply #21 on: February 19, 2006, 03:51:18 pm »
Quote
Using an ethernet bridge to plug your Zaurus into your network seems to me preferable to routing a two-node subnet between your PC and the Z and then using NAT to give the Z access to your network/the internet.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=95837\"][{POST_SNAPBACK}][/a][/div]
Hmm, looks good, but I do need NAT, IP MASQ on the PC because I my internet is via PPP. Can I do netfilter IP MASQ together with bridging?

SL-C860 (Boxer), OZ 3.5.4.1 GPE 2.7
my blog

7_feet_up

  • Newbie
  • *
  • Posts: 27
    • View Profile
    • http://
Usb Connection Howto
« Reply #22 on: March 20, 2006, 04:24:27 pm »
Quote
<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
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: [Select]
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.
« Last Edit: March 20, 2006, 04:25:31 pm by 7_feet_up »
Zaurus SL-5600
OpenZaurus 3.5.4.2-rc2
Wireless LAN CF Card NL-2511CF MERCURY
Destinator CF GPS receiver
PEAK Compact Flash Card 512MB
SanDisk Standard SD Card 64 MB
Brandless SD Card 1 GB
Sharp Zaurus SL5500 3E-Piel Frama Luxury Black Tan leather PDA case
PSP Battery Pack PW-2992p

microsoft/linux

  • Full Member
  • ***
  • Posts: 237
    • View Profile
    • http://
Usb Connection Howto
« Reply #23 on: March 21, 2006, 12:11:13 am »
ok, I changed GUIs, after I updated to 3.5.4. Now I can't connect from my PC. I made the settings of usb0 on the Z the same as they were, to no avail. Suggestions?
C3200(exiguitas) Angstrom Beta(version not designated)/GPE
SL-5500(immotus) OpenZaurus 3.5.4/GPE, OpenZaurus 3.5.4/Opie(loopmount)
1GB SD Card
128MB CF Card/8MB CF Card
Gentoo/Windows XP Home SP2

Numbers rule the Universe.
        --The Pythagoreans

Microsoft/Linux

pgas

  • Hero Member
  • *****
  • Posts: 1097
    • View Profile
    • http://
Usb Connection Howto
« Reply #24 on: March 21, 2006, 02:42:21 am »
PC: windows XP
Zaurus: 860 oz/gpe 3.5.4 2.6 kernel

Connect the zaurus to the pc via usb.

On the zaurus:
Menu -> settings -> usb settings  :
  Ethernet Networking ok

Menu -> settings -> Network setup
  usb0 (NOT usbd0) I change the ip here to 192.168.128.202, in order not to have problems with my other subnets

Menu -> utilities -> Root shell
 type in the console:
Code: [Select]
modprobe g_ether
ifup usb0
ignore the messages, now when typing `ifconfig' you should see usb0 with the ip set before and hopefully windows should have found a new device, time to set windows.

On the pc:
- save the attached file and rename it linux.inf
- follow the steps here:
http://www.gumstix.org/tikiwiki/tiki-index...ndows_XP_usbnet
( in fact I have included the location of linux.inf and windows did it all by itself)
- at the end right click on the local connection and choose properties
- click on tcpip and properties
- click on Use the following ip address and put 192.168.128.200 (or whatever you have set as a gateway on the zaurus, by default it should be 192.168.0.200)

Voila
« Last Edit: March 21, 2006, 02:46:30 am by pgas »
SLC-860 cacko / senao wifi

GenericAnimeBoy

  • Newbie
  • *
  • Posts: 36
    • View Profile
    • http://
Usb Connection Howto
« Reply #25 on: March 22, 2006, 01:34:07 am »
For those of us poor fools who have to internet connect the Z using the USB b/c we don't have a wifi CF card...

Zaurus:
SL-5500 - OZ 3.5.4 (I'm assuming Opie Image)

PC / Network:
- Windows XP
- Router (Optional?)

Drivers
- Load the original drivers either from the CD or by downloading them from...somewhere.  I used the CD.    (When the windows add hardware wizard asks for the drivers, just put the CD in and have the wiz look there.)

PC Side Changes
- In order for your Z to be able to see the rest of your network, you need to create a windows network bridge.  Open up Network Connnections (with the Z in the cradle and turned on, and drivers installed).  Select both the Z's connection and your PC's network connection (by control clicking).  Right click, and choose "Create Network Bridge".  IIRC, that's it.

Z Side Changes
- To bring up the network interface on the z, you may have to suspend/resume it in the cradle, or restart usbd0, or otherwise baby the device.  If you have DHCP (read: your network has a router, as mine does) IP address should configure itself.
- If your only available internet connection for the Z is via USB cradle (not useful for all that much, other than installing packages) it may be in your best interests to install fbvncserver ASAP (as the cradle blocks keyboard).  Hunt and peck into console using onscreen keyboard 'ipkg update' then 'ipkg -d <dest> install fbvncserver' then 'ipkg-link mount <dest/packages>'.  Reboot (yes, reboot--groan), and launch fbvnc from the console.  Connect to your Z's VNC server using a normal VNC client on your PC.
« Last Edit: March 22, 2006, 01:41:13 am by GenericAnimeBoy »
Sharp Zaurus SL-5500
OZ 3.5.4 / Opie Image - Flashed March 2006
256mb SimpleTech SD Card
Internet over USB Dock / WinXP
Can't afford a WiFi card yet  =(

jerrybme

  • Hero Member
  • *****
  • Posts: 639
    • View Profile
    • http://
Usb Connection Howto
« Reply #26 on: March 24, 2006, 10:05:11 am »
Quote
PC: windows XP
Zaurus: 860 oz/gpe 3.5.4 2.6 kernel

Connect the zaurus to the pc via usb.

On the zaurus:
Menu -> settings -> usb settings  :
  Ethernet Networking ok

Menu -> settings -> Network setup
  usb0 (NOT usbd0) I change the ip here to 192.168.128.202, in order not to have problems with my other subnets

Menu -> utilities -> Root shell
 type in the console:
Code: [Select]
modprobe g_ether
ifup usb0
ignore the messages, now when typing `ifconfig' you should see usb0 with the ip set before and hopefully windows should have found a new device, time to set windows.

On the pc:
- save the attached file and rename it linux.inf
- follow the steps here:
http://www.gumstix.org/tikiwiki/tiki-index...ndows_XP_usbnet
( in fact I have included the location of linux.inf and windows did it all by itself)
- at the end right click on the local connection and choose properties
- click on tcpip and properties
- click on Use the following ip address and put 192.168.128.200 (or whatever you have set as a gateway on the zaurus, by default it should be 192.168.0.200)

Voila
[div align=\"right\"][a href=\"index.php?act=findpost&pid=119530\"][{POST_SNAPBACK}][/a][/div]
God I hate windoze, thanks pgas for the above info, it almost works for me except as the XP drivers are being installed the new device dialog locks and I lose my USB mouse. As soon as I disconnect my Z the mouse comes back, but the drivers never completely install. This may be related to the docking station I use at work.
SL-C3100
Angstrom-GPE
Lexar SD 1 GB
PQI 2GB CF
Ambicom WL1100 CF

papercrane

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
    • http://reversefold.com
Usb Connection Howto
« Reply #27 on: March 29, 2006, 03:32:03 pm »
The Cxx00 doesn't talk to Windows correctly yet. Richard Purdie "has some hints" which should make it work but he hasn't had time to implement them yet. :-/

Tron

  • Newbie
  • *
  • Posts: 47
    • View Profile
Usb Connection Howto
« Reply #28 on: April 04, 2006, 04:25:39 am »
Quote
The Cxx00 doesn't talk to Windows correctly yet. Richard Purdie "has some hints" which should make it work but he hasn't had time to implement them yet. :-/
No wonder Windows does not like my borzoi. Ah well, linux works fine, though.

--
YT,
Tron
YT,
Tron

nick88

  • Newbie
  • *
  • Posts: 9
    • View Profile
Usb Connection Howto
« Reply #29 on: April 06, 2006, 09:20:28 pm »
Hi,  

I followed the shell scripts and can ping and ssh out of the Zaurus, but can't do a wget that ipkg needs using the Opie 3.5.4 images.  Any suggestions?
Zaurus 5500 w/ Ambicom WL1100C 802.11b, Sandisk 128MB SD card