For this step, work is needed both on the GNU/Linux host and on the iPAQ.
You need to have a supported USB hub in your PC, and have the kernel module installed for it. You should also obtain the kernel module named usbnet, which is bundled in Linux kernel since version 2.4.10, but working version is only bundled since 2.4.13. However, I found the experimental module in my stock Red Hat 7.2 distribution (kernel 2.4.7), and it seems not to behave too badly...
It is normally found as /lib/modules/kernel_version/kernel/drivers/usb.
If you cannot find the module, but have a supported kernel, you need to enable the CONFIG_USB_USBNET option in the kernel config (from the main config menu, go into "USB Support", you may need the "Code maturity level option" set to "EXPERIMENTAL"), and compile it with a command line like:
bash$ gcc -O2 -I /usr/src/linux/include -DMODULE -D__KERNEL__ -c usbnet.c |
Note: You must have gcc and correct kernel headers installed in order for this to work.
Otherwise, consider upgrading your kernel. As an alternative, you can continue to download all the required files using the serial method, it will only be slower.
Once the module is compiled, copy usbnet.o into the module directories and update the module dependencies with:
bash# cp build_dir/usbnet.o /lib/modules/kernel_version/kernel/drivers/usb bash# depmod -a |
you can then insert it with:
bash# modprobe usbnet |
On the iPAQ side, the USB driver is included in the bootstrap image. However, we need to create all the files needed to start/stop/suspend/resume the USB network.
Note: At the time of this writing, there is an existing unstable package named usbnet_1.1_arm.ipk that is supposed to do what we describe here. Unfortunately, it is relying on ifup/ifdown configuration that is not described, so we will not use it.
Download the following file onto your GNU/Linux host, and name it usbnet:
#!/bin/sh # chkconfig: 2 45 96 # processname: usbnet # pidfile: /var/run/usbnet.pid # lockfile: /var/lock/subsys/usbnet usage() { echo "Usage: $0 {start|stop|status}" } PC_ADDR=192.168.1.100 IPAQ_ADDR=192.168.1.101 GW_ADDR=192.168.1.100 DRIVER=usb-eth INTERFACE=usbf if [ $# -lt 1 ]; then usage break fi case "$1" in start) modprobe $DRIVER ifconfig $INTERFACE inet $IPAQ_ADDR up route add default gw $GW_ADDR ;; stop) ifconfig $INTERFACE down modprobe -r $DRIVER ;; status) ifconfig $INTERFACE ;; *) usage ;; esac |
Replace the IP addresses by the ones corresponding to your network, then transfer it using the zmodem protocol. When you have set up a terminal connection using minicom, as described in Chapter 3, issue the following commands on the iPAQ:
# cd /etc/init.d # rz .. waiting to receive.**B0100000023be50 |
This command tells the iPAQ to be ready to receive the package using the zmodem protocol. You just have to feed it from the running minicom window, by pressing Ctrl-A and S. A small popup window will appear, allowing you to choose the transfer protocol. Using the arrow down key, move down to the "zmodem" entry and press Enter.
A file selector window will open, where you need to specify the file to download. Using the arrow right key and pressing Enter, you can go to the directory containing the usbnet file. Using the arrow down key, move down to the correct file, and hit space to select the file, then press Enter.
A window will open, and minicom will beep. Press Esc to close the window. Press Enter to get back the shell prompt.
Make this script executable by issuing:
# chmod +x /etc/init.d/usbnet |
Based on this file, we will create the necessary setup needed to launch USB networking automatically when you boot, so we have to create a symbolic link to this script into the /etc/rc2.d directory, which is the directory containing the scripts to launch when you go into runlevel 2 (the normal runlevel):
# cd /etc/rc2.d # ln -s ../init.d/usbnet S45usbnet.sh |
For this first time, we can just launch it manually by typing:
# /etc/init.d/usbnet start SA1100 USB Controller Core Initialized usbctl: Opened for usb-eth usbctl: Started for usb-eth |
We also need to create the files required to stop/start the USB network when going into suspend/resume mode. Using the previous script, they are easy to create:
# cat >/etc/suspend-scripts/S33usbnet #!/bin/sh /etc/init.d/usbnet stop Ctrl-D # cat >/etc/resume-scripts/R33usbnet #!/bin/sh /etc/init.d/usbnet start Ctrl-D # chmod +x /etc/*scripts/*usbnet |
If you have not already done it, insert the usbnet module on the GNU/Linux host:
bash# modprobe usbnet |
Note: Depending on your GNU/Linux USB configuration, you may not have to issue this command: it will be done automatically for you by the USB subsystem.
Make sure the cradle's USB and serial cables are connected to the host PC. Remove the iPAQ from the cradle and put it back. If you run minicom, you should see the following message in the terminal emulator window:
usbctl: zombie suspended --> [resume] --> zombie. Device in powered state. usbctl: zombie --> [reset] --> default. Device in default state. usbctl: Resetting usbctl: default --> [address assigned] --> address. Device in address state. usbep0: I have been assigned address: 14 usbctl: address --> [configure] --> configured. Device in configured state. usbep0: Configured (OMP=00000040 IMP=00000040) usbep0: fixme: set interface not supported |
This means that our host's USB subsystem has correctly detected and configured the iPAQ. On the iPAQ, you can check that everything is working by issuing the following command:
# ifconfig lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:8 errors:0 dropped:0 overruns:0 frame:0 TX packets:8 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:728 (728.0 b) TX bytes:728 (728.0 b) usbf Link encap:Ethernet HWaddr 9A:4D:0E:33:E7:01 inet addr:192.168.1.101 Mask:255.255.255.0 UP RUNNING MTU:1500 Metric:1 RX packets:4 errors:0 dropped:0 overruns:0 frame:0 TX packets:4 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:100 RX bytes:224 (224.0 b) TX bytes:280 (280.0 b) |
This last paragraph provides the necessary information about the USB network interface.
On the GNU/Linux host, a new network interface usbN (where N is a number starting from 0) will appear when the iPAQ is connected to the USB bus. You can then configure it like any other ethernet interface.
To save a lot of typing if you are going to use it on a regular basis, I suggest you to create the following ipaqnet script on your GNU/Linux host (please replace the addresses and UPLINK_IF with your appropriate values):
#!/bin/bash # # ipaqnet Control script for iPAQ USBNet connection # # Author: Michel Stempin # Creation: 11/08/2002 PC_ADDR=192.168.1.100 IPAQ_ADDR=192.168.1.101/32 IPAQ_NET=192.168.1.0/24 UPLINK_IF=ppp0 start() { modprobe usbnet ifconfig usb0 inet $PC_ADDR up if [ $? -ne 0 ]; then exit 1 fi echo "1" >/proc/sys/net/ipv4/conf/usb0/proxy_arp UPLINK=`ifconfig $UPLINK_IF >/dev/null 2>&1` if [ $? -ne 0 ]; then exit 1 fi echo "1" >/proc/sys/net/ipv4/conf/$UPLINK_IF/proxy_arp echo "1" >/proc/sys/net/ipv4/ip_forward ip route del $IPAQ_NET dev usb0 ip route add $IPAQ_ADDR dev usb0 } stop() { ifconfig usb0 down rmmod -r usbnet } case "$1" in start|add) start ;; stop|remove) stop ;; *) echo $"Usage: $0 {start|stop|add|remove}" exit 1 esac |
Make this script executable by typing:
bash# chmod +x path_to_ipaqnet/ipaqnet |
We should now be able to launch the connection by typing:
bash# path_to_ipaqnet/ipaqnet start |
If some sort of error message appears at this point, it means that the iPAQ insertions was not correctly handled, try re-inserting it.
This script uses the proxy_arp mechanism introduced above to forward data to the iPAQ.
On the GNU/Linux host, you can check that everything is working by issuing the following command:
# ifconfig lo Link encap:Local loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:14 errors:0 dropped:0 overruns:0 frame:0 TX packets:14 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 lg file transmission:0 RX bytes:748 (748.0 b) TX bytes:748 (748.0 b) ... usb0 Link encap:Ethernet HWaddr C0:E3:56:1A:B8:CD inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0 UP BROADCAST RUNNING 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 lg file transmission:100 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) |
Again, this last paragraph provides the necessary information about the USB network interface.