Howto make a network connection to the Zaurus from a Linux machine using USB.
This document is a generic howto. See your respective distributions howto for possible packages and or information pertaining to specific distributions.
Patching the Linux Kernel
If you are using the kernel 2.4.21 or later then you do not need to patch your kernel and you can jump to step 1.3.
RHEL/CentOS 4 users can skip to section 2. The CDCEther and acm modules do not seem to be installed, so it is possible to go straight to configuring the network.
Download the appropriate patch for your kernel
Patch the kernel source.
Assuming the Linux sources are in /usr/src/linux do the following (replacing usbdnet-2.4.x.patch.gz with the patch you downloaded):
cp usbdnet-2.4.x.patch.gz /usr/src cd /usr/src zcat usbdnet-2.4.x.patch.gz | patch -p0
Reconfigure the kernel to add support.
Pull up the kernel menuconfig.
cd /usr/src/linux make menuconfig
In "Code maturity level options", select "Prompt for development and/or incomplete code/drivers"
With kernels 2.4.21 and later, in "USB support", section "USB Network adapters", select (as a module) "USB-to-USB Networking cables, Linux PDAs (EXPERIMENTAL)"
With earlier kernels, in "USB support", section "USB Network adapters", select (as a module) "USBD Network (Encapsulated) Host-to-Host Link (EXPERIMENTAL)"
Then enter 04dd in USBD Network idVendor and 8004 in USBD Network idProduct
With all kernels, make sure the option "USB Communication Class Ethernet device support" is completely turned off.
Make sure that the core usb support (usbcore) is supported in your kernel either as a module or built in. Also make sure that a host controller (usb-uhci or usb-ohci) is a build in or a module. If you don't know which usb module to use for your machine ( usb-uhci or usb-ohci ) then check this page, it contains instructions on how to find out.
Build the kernel and modules.
If you set everything as a module simply run:
make clean dep modules modules_install
which will build the modules and install them.
If you built the components into the kernel you need to build a kernel image, install it into your bootloader, and the system should be rebooted. These steps are outside of the scope of this document and http://www.linuxdoc.org should be consulted. On the plus side you can skip step 5.
Running the new modules.
Install the new modules using modprobe. You need to be root to run this utility. The following three items need to be running to connect to the Zaurus. If they were all build as modules simply run "modprobe module". To see what modules are currently running run the application "lsmod".
usbcore - USB core, needed for any usb activity.
usb-uhci or usb-ohci - USB host controller driver.
With kernels 2.4.21 and later, the following module is built and used:
usbnet - USB networking which is what the Zaurus uses.
With all earlier kernels, the following module is built and used:
usbdnet - USB networking which is what the Zaurus uses (and is the above patch).
Check to make sure the drivers are working.
Put the Zaurus in the cradle. Make sure it is on of course.
You should see a message like the following in /var/log/messages for kernels 2.4.21 and later:
hub.c: new USB device 02:03.3-1, assigned address 2 usb0: register usbnet usb-02:03.3-1, Sharp Zaurus SL-5x00
For all earlier kernels, you should see a message like the following in /var/log/messages:
hub.c: USB new device connect on bus1/1, assigned device number 38 usb.c: USB device 38 (vend/prod 0x4dd/0x8004) is not claimed by any active driver. v0.4b firstname.lastname@example.org, email@example.com usbdnet.c: v0.4b firstname.lastname@example.org, email@example.com usbdnet.c: USB Host to Device Network - for Linux USB Devices using MDLM/CDC usb.c: registered new driver usbdnet
If you don't see this, try pushing the sync button on the cradle, it should help
Run "ifconfig "-a in a root shell. A new interface ( more then likely usb0 ) should appear along with lo, eth0 etc. If this does not happen check over the above steps.
Note (kernel 2.4.21 and later): If the new interface after "ifconfig -a" is not usb0 (for example you see the following in /var/log/messages:
hub.c: new USB device 00:07.2-1, assigned address 3 CDCEther.c: eth1: Sharp SL-5500 (your Zaurus's MAC address here)
and pinging does not work after completing step 2) (even if you literally replace "usb0" with "eth1")
then undock the Zaurus and unload the CDCEther and acm modules: as root:
/sbin/rmmod CDCEther /sbin/rmmod acm
redock the Zaurus, and check /var/log/messages :
usb.c: deregistering driver CDCEther usb.c: deregistering driver acm hub.c: new USB device 00:07.2-1, assigned address 4 usb0: register usbnet usb-00:07.2-1, Sharp Zaurus SL-5x00
(now you can continue on to step 2), and work with usb0)
- As mentioned by many people, make sure you've compiled in the correct driver into the kernel in the USB Controllers subsection of the USB configuration.
- Some people report that they're getting the following message when loading the usbdnet module echo_tx not found it looks like you can safely ignore it since it does not prevent the driver from working.
- Some people have reported file transfer problem on file larger than 65kB, it appears that is was due to the fact that they where using the uhci module instead of the usb-uhci. If you're having this kind of problem and you are using the uhci module, try using usb-uhci instead.
- I've also received reports of kernel crashes when transferring large files with some motherboards ( at least Gigabyte X71 ) and kernel versions ( 2.4.10 and 2.4.18 ). The solution seems to update to a kernel 2.4.19pre8 or higher.
Setting up the network.
USB Networking is similar to PPP. Each device on either end gets an IP address. The IP address on the Zaurus is set via the network setup tool. If it is not "192.168.129.201" then use the given IP address when trying to ping the Zaurus below.
If when you put the Zaurus in the cradle an interface other then usb0 is created replace all instances with usb0 with that interface name for this section of the howto. You should be able to configure the device using the following commands:
ifconfig usb0 192.168.129.1 netmask 255.255.255.0 up route add -host 192.168.129.201 usb0
Then try to ping the Zaurus "ping 192.168.129.201", if you've got a reply then you are successfully connected!
Note that if you are using a ROM newer then 2.37 you need to run a dhcp client (such as dhcpcd or pump) on your desktop to get an IP address from the Zaurus. (i.e. you can't connect until you have an ip.) It is a security measure to only allow those connecting via the usb port to connect to the device. The dhcp server on the Zaurus only runs on the usb interface and will not give out ip's over 802.11b, LAN, etc. The networking will only allow those that have one of the IP addresses that were given out by the dhcp server to connect.
Connecting to the Internet from the Zaurus
To get the Zaurus on the Internet through the host machine you need to masquerade the Zaurus's IP address. Assuming on the desktop the interface eth0 with ip address 192.168.1.100 is connected to the Internet you need to do the following: (Replace eth0 and 192.168.1.100 with your interface and its ip address of course.)
Enable masquerading in the kernel.
Make sure that the following options are turned on in the kernel:
In "Networking options", select :
- Network packet filtering (replaces ipchains)
- in "IP: Netfilter Configuration" select at least
- "IP tables support (required for filtering/masq/NAT)" (as a module if you want)
- "Connection tracking (required for masq/NAT)" (as a module if you want)
- "Full NAT" (as a module if you want)
- "MASQUERADE target support (NEW)" (as a module if you want)
Install on the desktop the new kernel and modules, rebooting if needed.
Enable the masquerading
On the desktop turn on the masquerading for the Zaurus. Note that you may need to replace "192.168.129.1" and "usb0" with the appropriate values as found in sections 1.6 and section 2.0.
ifconfig usb0 192.168.129.1 netmask 255.255.255.255 up route add -host 192.168.129.201 usb0 iptables -t nat -F iptables -t nat -A POSTROUTING -j SNAT -o ethX --to MY_IP echo 1 > /proc/sys/net/ipv4/ip_forward
Configure the Zaurus
Add a default route pointing to your linux PC:
__route add -host 192.168.129.1 usbd0__ __route delete -net 192.168.129.0/24 usbd0__ __route add default gw 192.168.129.1__
then edit /etc/resolv.conf to add the IP of your DNS server.
Add a line like this __nameserver xxx.xxx.xxx.xxx__ where xxx.xxx.xxx.xxx is the address of a nameserver as found in "/etc/resolv.conf".
To automate all of the above steps you can make it so when you put the Zaurus in the cradle it will automatically configure itself. This step is different depending on the distribution and you should look at the specific distributions howtos.
Depending on your distribution the following may or may not work:
In order to have hotplug setup everything when you plug your Zaurus on your PC, you'll need to create a script /etc/hotplug/usb/usbdnet (/etc/hotplug/usb/usbnet is the default name for RHEL) that should look like this ( feel free to adapt it to your needs )
__Remember to replace eth0, 192.168.1.1, usb0, 192.168.129.1, and 192.168.129.201 with the correct values on your system!__
#! /bin/bash localIface=eth0 localIp=192.168.1.1 zIface=usb0 zIfaceIP=192.168.129.1 zIP=192.168.129.201
typeset -i num num=`ifconfig | grep $zIface | wc -l` if [ $num -eq 0 ] ; then ifconfig $zIface $zIfaceIP netmask 255.255.255.255 up route add -host $zIP $zIface fi iptables -t nat -F iptables -t nat -A POSTROUTING -j SNAT -o $localIface --to $localIp echo 1 > /proc/sys/net/ipv4/ip_forward