Author Topic: Usb Connection Howto  (Read 122320 times)

lardman

  • Hero Member
  • *****
  • Posts: 4512
    • View Profile
    • http://people.bath.ac.uk/enpsgp/Zaurus/
Usb Connection Howto
« on: April 07, 2005, 10:03:30 am »
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.
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

lardman

  • Hero Member
  • *****
  • Posts: 4512
    • View Profile
    • http://people.bath.ac.uk/enpsgp/Zaurus/
Usb Connection Howto
« Reply #1 on: April 07, 2005, 10:07:26 am »
Zaurus - C750, 2.6.11 kernel, OZ 3.5.3pre (probably other C7/8x0 machines, possibly all machines with the 2.6.x kernel).

Windows XP.

Quite simple, no real drivers are required, just an .inf file you should point the hardware wizard to when it says it can't recognise your Z).

The linux.inf file comes from Documentation/usb/linux.inf in the kernel 2.6.x source (it will need to be converted to Windows format first if you take it directly from thje kernel source - use unix2dos, or open it with WordPad and re-save it).

The file is attached to this post for the time being, but we'll find a more permanent location when 3.5.3 is released.

https://www.oesf.org/forums/index.php?showt...indpost&p=73169


Si
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

darac

  • Newbie
  • *
  • Posts: 11
    • View Profile
    • http://www.darac.org.uk
Usb Connection Howto
« Reply #2 on: April 13, 2005, 04:45:56 pm »
Zaurus:
SL-5500 (Collie)
Hentges.net ROM T7 (based on OpenZaurus 3.5.2)

PC:
Debian 3.1 "Sarge", Vanilla Kernel 2.6.11.6 (Should work with earlier 2.6 kernels, but note that the driver location has moved.)

Drivers:
Device Drivers -> USB Support -> USB Network Adapters
Set "Multi-purpose USB Networking Framework" as a Module and turn on "Embedded ARM Linux links (iPaq, ...)" and "Sharp Zaurus (stock ROMs)"
Rebuild your kernel or just "make; make modules_install" if you're feeling brave.
(In other words, CONFIG_USB_USBNET=m, CONFIG_USB_ARMLINUX=y and CONFIG_USB_ZAURUS=y)

This will make the "usbnet.ko" module.

PC-Side changes
Install the "hotplug" package.

Add the following line into /etc/hotplug/usb.distmap:
Code: [Select]
usbnet    0x003    0x04dd    0x8004    0x0000    0x0000    0x00    0x00    0x00    0x00    0x00    0x00    0x00000000(That's one single line with Thirteen (13) white-space-delimited fields)

Now create the following file /etc/hotplug/usb/usbnet:
Code: [Select]
#! /bin/bash
typeset -i num
num=`ifconfig | grep usb0 | wc -l`
if [ $num -eq 0 ]; then
    ifup usb0
else
    ifdown usb0
    sleep 1
    ifup usb0
fi
and make it executable with "chmod +x /etc/hotplug/usb/usbnet"

Add the following to /etc/network/interfaces:
Code: [Select]
# USBd Interface to the Zaurus
# Statically configure the interface (i.e. no DHCP)
iface usb0 inet static
    address 192.168.129.200     # Address of PC's end of link
    pointopoint 192.168.129.201   # Address of Zaurus' end of link
    netmask 255.255.255.255
    # Now call some commands when the link comes up
    up iptables -t nat -F      # Flush the NAT table
    up iptables -t nat -A POSTROUTING -j SNAT -o eth0 --to $addr
         # Set up Source Network Address Translation (SNAT)
         # Note:
         # eth0 - Interface towards the internet.
         #   This can probably be ppp0 if the PC is dialled up.
         # $addr - Set this to the address of the above interface.
    up echo "1" > /proc/sys/net/ipv4/ip_forward
                    # Turn on IP Forwarding
    # Now call some commands AFTER the link has gone down
    post-down echo "0" > /proc/sys/net/ipv4/ip_forward
                    # Turn off IP Forwarding
    post-down iptables -t nat -F  # Flush the NAT table

# Optional IPv6 on interface
iface usb0 inet6 static
    address 2001:618:429:cafe::5501 # Choose an address in your own block
         # I have ...::5501 at this end and the
         # Zaurus configured as ...::5500
    netmask 128
    mtu 1500

Zaurus-side changes
In Network Settings, for usbd0:
Turn ON "Automatically bring up"
Turn OFF "DHCP"
IP Address: 192.168.129.201 (To match pointopoint address above)
Subnet Mask: 255.255.255.0
Gateway: 192.168.129.200 (To match address on PC)
First DNS: Whatever you like
Second DNS: Whatever you like

Now, you should be able to just plug the Zaurus in. Hotplug will detect the SL-5500, load usbnet.ko, configure the interface and iptables will allow the Zaurus to connect to the internet.

NOTE: We've only used Source NAT so, while the Zaurus can access the internet (pull down ipks etc), it is not accessible to internet computers connecting to it. (That is, you won't be able to ping the Zaurus or connnect to any servers on the Zaurus from any computer other than the one at the end of the USB cable). Also note that you WILL want to tweak the lines in /etc/network/interfaces if you perform other NAT functions on the PC. Suggestions are welcome for more specific (and better) iptables commands.
« Last Edit: April 14, 2005, 06:01:29 pm by darac »
--
SL-5500 (Collie)
OpenZaurus 3.3.5 (64/0)
Kingston 128Mb SD
TwinMOS/DabsValue 256Mb CF
Mavin MFC-M2.1 Bluetooth CF
ExtremeLimit Leather BodySuit
zThinUSB cable

gfdsa

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Usb Connection Howto
« Reply #3 on: April 14, 2005, 12:58:02 pm »
Zaurus:
SL-600L, OZ 3.5.2, Dock Station
PC:
WinXP SP2
Drivers:
Shipped on CD with Z, or download:
http://ezaurus.com/bzsolution/download/SL6...SL6000Setup.exe
http://www.gfdsa.org/~gfdsa/SL6000Setup.exe

After Windows recognizes SL-6000, point it to UsbDrivers Dir, follow the wizards.

PC-Side Changes
When it finally settles down, go to network connections, enable connection sharing for your internet connection.
Z-Side Changes
Change usbd0 ip to 192.168.0.x or enable dhcp
ifdown usbd0
ifup usbd0

NOTE: Disconnects on large files transffers with SCP, requires device disconnecting and ifdown/ifup

jancici

  • Newbie
  • *
  • Posts: 11
    • View Profile
Usb Connection Howto
« Reply #4 on: April 17, 2005, 05:30:35 pm »
hi, for me this is not working, I can remember that with original sharp ROM it was working very well. I did flash OZ 3.5.2 and it was not working, yeasterday I did flash OZ 3.5.3. and still I have problem.

so on Z I have OpenZaurus 3.5.3, uname -a saying 2.4.18-mk7-pxa3-embedix
I have done :
1. settings -> network -> usbd0 : to bring it UP automaticaly, and set up static IP
2. restart Z
after that usbd0 net interface is up

on my desktop I am running gentoo with 2.6.11-gentoo-r5 kernel
I did use same configuration as for SharpROM, so I think it's should work (if necesary I can post my config

when I plug Z to cardle and then I plug usb cable to desktop I can see Zaurus on desktop using "lsusb" command. but hotplug on desktop is not starting usbnet and I don't know why.

when I am typing modprobe -l on Z I am getting empty list :-(

I am totaly tired with this, I did try follow several hot-to by did not help.

thanks

lardman

  • Hero Member
  • *****
  • Posts: 4512
    • View Profile
    • http://people.bath.ac.uk/enpsgp/Zaurus/
Usb Connection Howto
« Reply #5 on: April 18, 2005, 04:10:33 am »
Start a seperate thread please, this thread is just for reference purposes.

Si

P.S.

Say which machine you have - it'll help people.
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

lardman

  • Hero Member
  • *****
  • Posts: 4512
    • View Profile
    • http://people.bath.ac.uk/enpsgp/Zaurus/
Usb Connection Howto
« Reply #6 on: April 18, 2005, 05:13:08 am »
Zaurus:

OZ 3.5.3 C7x0 with 2.4.18 kernel (GPE only atm)

PC:

Windows XP (should work for other versions of Windows too)

Drivers:

On the CD with your Z, or download the standard Windows USB drivers for the C7x0 machines from ZUG:

http://www.zaurususergroup.org/UpDownload+...t-lid-199.phtml

When the add hardware wizard asks where to look for the drivers, choose the custom location and point it to the net sub-directory in the above zip file.

PC-Side Changes
Go to network connections, select a static IP address (unless your PC or your Z is running a DHCP server - chances are neither is).

Z-Side Changes
Change usb connection IP address to a static address or enable dhcp if either your Z or PC is running a DHCP server.
« Last Edit: April 18, 2005, 05:14:39 am by lardman »
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

obergix

  • Full Member
  • ***
  • Posts: 128
    • View Profile
    • http://www.olivierberger.com/weblog/
Usb Connection Howto
« Reply #7 on: May 18, 2005, 04:15:00 am »
Quote
Add the following to /etc/network/interfaces:
Code: [Select]
# USBd Interface to the Zaurus
# Statically configure the interface (i.e. no DHCP)
iface usb0 inet static

[SNIP]

    up iptables -t nat -A POSTROUTING -j SNAT -o eth0 --to $addr


NOTE: We've only used Source NAT so, while the Zaurus can access the internet (pull down ipks etc), it is not accessible to internet computers connecting to it. (That is, you won't be able to ping the Zaurus or connnect to any servers on the Zaurus from any computer other than the one at the end of the USB cable). Also note that you WILL want to tweak the lines in /etc/network/interfaces if you perform other NAT functions on the PC. Suggestions are welcome for more specific (and better) iptables commands.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=75016\"][{POST_SNAPBACK}][/a][/div]

On my system (Debian Sarge), the --to should be replaced by --to-source and followed by the address of the standard network interface of the PC (eth0).

Hope this helps
Zaurus SL-C1000 - OpenZaurus 3.5.4.1-alpha1 w/ GPE image (some packages "custom made", compiled at home from bitbake+openembedded)

dansawyer

  • Sr. Member
  • ****
  • Posts: 293
    • View Profile
    • http://
Usb Connection Howto
« Reply #8 on: May 26, 2005, 09:56:16 am »
The howto is very helpful as it is.  I would suggest a 'debug' section to help when the interface freezes. My Z on a FC2 freezes about every 2 days. Sometimes it is on the Linux side; it seems that usbnet does not like to suspend-resume and have the Z connnection change. So one debug note is the use of lsusb. Is there a way to force reload usbnet w/o rebooting?

The Z hangs occationally as well. The interface will not come up. I am not sure what to do about this? There used to be a change to the suspend resume scripts. Does anyone know if this will help? If it will then I will dig them up, try them, and post here.

Dan

niv

  • Full Member
  • ***
  • Posts: 237
    • View Profile
Usb Connection Howto
« Reply #9 on: June 19, 2005, 09:48:48 pm »
Windowz:
you may want to use NT/2000/XP routing to get ur zaurus to the web.
use these commands:

netsh routing ip nat install
netsh routing ip nat add interface “YOUR LAN INTERFACE NAME” full
netsh routing ip nat add interface Internal private

YOUR LAN INTERFACE NAME has to be replaced with the name of the interface connected to the internet

I think I am missing a line, as it doesn't work yet. will fix it soon.

Niv

charcler

  • Newbie
  • *
  • Posts: 1
    • View Profile
Usb Connection Howto
« Reply #10 on: August 04, 2005, 11:50:10 pm »
HELLO
sysops... gurus... wanna.. new... all ;)

My (very) first time with Zaurus, (old) model SL 5500, strong Arm 1110 rev 9
Unpack :
Zaurus + dock + SD 128 + flash 128 + wifi Dlink + multicards usb reader + cables ;)

"kernel card 3.1.2" = kernel 2.4.18 rmk7 pxa3 embedix 021129 compiled by mickey@r2d2 ;))
OpenZaurus 3.5.2
Opie, Open PalmTop Integrated Environnement v 1.1.7
Zaurus has been 'burned, cuted' ... cool
tests : gfx rendering : 2560 gops/second // ram performance : 26.5 mb/s Cool!!!

All right's :))

Install first ipk : kismet. ok ! second : wellenreiter. np too. searchin about Zeb paquage to mplayer compil for arm :(( link at it s home at uklinux ... no tarball... any idea ? thanks :)

Well done, The USB Connection :
my workstation :
kernel 2.6.12.6  -- gnu -- mandriva 2005le -- xorg 6.8 -- kde 3.4 --

So :
connect dock with usb and power. Connect Z on.
LSUSB:
Bus 002 Device 003: ID 04dd:8004 Sharp Corp. Zaurus SL-5000D/SL-5500 PDA
ok
less /var/log/kernel/info
Aug  5 05:22:17 charcler kernel: usb 1-2: new full speed USB device using uhci_hcd and address 12
Aug  5 05:22:17 charcler kernel: usb0: register usbnet at usb-0000:00:14.2-2, Sharp Zaurus SL-5x00
Perfect ...

Go into network configuration ...
shutting down shoreline firewall /etc/init.d/shorewall stop (or service shorewall stop or CLICK MandrakeControlCenter - system - services - click on "stop" shorewall )
--CLICK MandrakeControlCenter - Internet/network - Share internet - select usb0 - patient... OK
simply restart firewall (it adapte itself on new nat connection)
Zaurus :
--CLICK settings - network - usb0 - ip/dhcp (hehehe) - start OK
Open Opera : all works good ;) I am on the internet with my Z throught usb connection.
30 secondes for all settings. (2 seconds for settings, 28 seconds to view step-by-step the logs)
roxor.

note : in fixed ip : 4 secondes without log view ;)

Wireless ? too... :))
 now : i have the choice between 3 sync applx. Opie, sync and other one... I think it s not hard to sync with Kontact ;)

see you !
« Last Edit: August 05, 2005, 12:11:29 am by charcler »

ajaygautam

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • http://
Usb Connection Howto
« Reply #11 on: August 11, 2005, 02:47:51 pm »
Z: SL5500, OZ 3.5.3,2.4.18-rmk7-pxa3-embedix
PC: Gentoo Linux / x86, 2.6.12-gentoo-r6

Just got IP forwarding / NAT working, so that I can access internet from my Zaurus via the USB connection. Here is the script that worked for me:

Code: [Select]
# make sure you have iptables stuff / modules compiled
# needs to be run on PC
modprobe ip_tables
modprobe iptable_nat

echo 1 > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv4/ip_dynaddr

EXTIF="eth0"
INTIF="usb0"

iptables -P INPUT ACCEPT
iptables -F INPUT
iptables -P OUTPUT ACCEPT
iptables -F OUTPUT
iptables -P FORWARD DROP
iptables -F FORWARD
iptables -t nat -F

iptables -A FORWARD -i $EXTIF -o $INTIF -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i $INTIF -o $EXTIF -j ACCEPT
iptables -A FORWARD -j LOG

iptables -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE
echo "Make sure Zaurus's /etc/resolv.conf points to correct entries"

Ajay
Zaurus:[/u] SL-5500, 64-0 kernel, OZ 3.5.3-r21
Desktop:[/u] Gentoo Linux / i686 2.6.12-gentoo-r6

NickNak

  • Newbie
  • *
  • Posts: 11
    • View Profile
    • http://www.basilisk.uklinux.net
Usb Connection Howto
« Reply #12 on: September 14, 2005, 12:56:39 pm »
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. Details of how to do it are at the usbnet website. On Gentoo, this is particularly easy:

1. Create symlinks to /etc/init.d/net.lo called /etc/init.d/net.usb0 and /etc/init.d/net.br0
2. Put the following in /etc/conf.d/net:

Code: [Select]
bridge_br0="eth0"
# You need to configure eth0 and usb0 as null so that dhcp is not used,
# we don't want IP addresses etc for these interfaces.
config_eth0=( "null" )
config_usb0=( "null" )
# Could use config_br0=( "dhcp" )
config_br0=( "192.168.2.30" )
depend_br0() {
    need net.eth0
}
gateway="br0/192.168.2.1"
# when hotplug configures usb0, add it to the bridge.
postup() {
    local iface=${1}
    if [[ ${iface} == usb0 ]]; then
        brctl addif br0 ${iface}
    fi
}

Obviously tailor the IP addresses to suit.

3. Configure the TCP/IP connecton on the Zaurus to make it part of the same subnet as your PC, e.g.
IP Address = 192.168.2.50
Subnet Mask = 255.255.255.0
Gateway = 192.168.2.1
First and Second DNS the same as your PC.

4. Test the configuration:
 
Code: [Select]
/etc/init.d/net.eth0 stop
/etc/init.d/net.br0 start

then plug in and switch on the PDA.  Check that your PC and PDA have network access
 
5. Make the new configuration permanent:
 
Code: [Select]
rc-update del net.eth0
 rc-update add net.br0 default
SL-5500 OZ3.5.4 (Opie)
Gentoo

Headrush

  • Newbie
  • *
  • Posts: 4
    • View Profile
Usb Connection Howto
« Reply #13 on: September 19, 2005, 06:11:22 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. Details of how to do it are at the usbnet website. On Gentoo, this is particularly easy:

1. Create symlinks to /etc/init.d/net.lo called /etc/init.d/net.usb0 and /etc/init.d/net.br0
2. Put the following in /etc/conf.d/net:

Code: [Select]
bridge_br0="eth0"
# You need to configure eth0 and usb0 as null so that dhcp is not used,
# we don't want IP addresses etc for these interfaces.
config_eth0=( "null" )
config_usb0=( "null" )
# Could use config_br0=( "dhcp" )
config_br0=( "192.168.2.30" )
depend_br0() {
 Â   need net.eth0
}
gateway="br0/192.168.2.1"
# when hotplug configures usb0, add it to the bridge.
postup() {
 Â   local iface=${1}
 Â   if [[ ${iface} == usb0 ]]; then
 Â       brctl addif br0 ${iface}
 Â   fi
}

Obviously tailor the IP addresses to suit.

3. Configure the TCP/IP connecton on the Zaurus to make it part of the same subnet as your PC, e.g.
IP Address = 192.168.2.50
Subnet Mask = 255.255.255.0
Gateway = 192.168.2.1
First and Second DNS the same as your PC.

4. Test the configuration:
 
Code: [Select]
/etc/init.d/net.eth0 stop
/etc/init.d/net.br0 start

then plug in and switch on the PDA.  Check that your PC and PDA have network access
 
5. Make the new configuration permanent:
 
Code: [Select]
rc-update del net.eth0
 rc-update add net.br0 default
[div align=\"right\"][a href=\"index.php?act=findpost&pid=95837\"][{POST_SNAPBACK}][/a][/div]
NickNak, great guide.

I do have a question though: how do eth0 and usb0 get their IP address.
I can manually create the bridge and add the 2 interfaces (eth0 and usb0) to the bridge, but then I have to use ifconfig to give each an IP address.

Is there a way to do this automatically and is it still possible if eth0 uses DHCP to receive it's IP address?

NickNak

  • Newbie
  • *
  • Posts: 11
    • View Profile
    • http://www.basilisk.uklinux.net
Usb Connection Howto
« Reply #14 on: September 19, 2005, 06:31:31 pm »
Using this method, usb0 and eth0 do not need IP addresses.  There are only two IP addresses involved: the one for the PC, which is assigned to interface br0 by the directive config_br0=( "192.168.2.30" ), and the one for the PDA which I configured using the Network settings GUI to "192.168.2.50".  I think both of these could be assigned using dhcp but I haven't tried it. Using a bridge at the ethernet level means that the PDA "looks like" any other device on the same ethernet segment as the PC.
SL-5500 OZ3.5.4 (Opie)
Gentoo