Handhelds.org - Open source for handheld devices

UserPreferences

UsbNetHotplug


iPAQ usbnet+hotplug


Note: this document is out of date, please see UsbNet instead. - PaulEggleton

This page covers the changes you may need to make to your Linux desktop system in order to have the USB network adapter (module usbnet) connected automatically every time you plug in your iPAQ. You will need to have USB working and the hotplug package installed.

Currently the following applies only to the iPAQ H3870 connecting to a SuSe Linux 8.2 desktop. (To be updated for other models/distributions - PaulEggleton)

  1. Create a backup copy of your existing usb.usermap file:

    cp -p /etc/hotplug/usb.usermap ~
    

  2. To change the configuration of the system we've to become superuser:

    su
    

  3. Edit /etc/hotplug/usb.usermap:

    vi /etc/hotplug/usb.usermap
    

  4. Now add the following:

    # usb module         match_flags idVendor idProduct bcdDevice_lo bcdDevice_hi bDeviceClass bDeviceSubClass bDeviceProtocol bInterfaceClass bInterfaceSubClass bInterfaceProtocol driver_info
    iPAQ           0x0003      0x049f   0x505a    0x0000       0x0000       0xff         0x00            0x00            0x00            0x00               0x00               0x00000000
    

  5. Add the following script to your /etc/init.d (e.g. as SA1100-USB-NIC)

    #!/bin/bash
    #
    # Control script for iPAQ USBNet connection
    #
    # Author: Michel Stempin
    # Creation: 11/08/2002
    #
    # 04.02.2004, pgf, > NAT added
    
    
    PC_ADDR=192.168.0.1
    IPAQ_ADDR=192.168.0.202/32
    IPAQ_NET=192.168.0.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 [ ${UPLINK_IF} -ne 0 ]; then
    #        exit 1
    #    fi
    #    echo "1" >/proc/sys/net/ipv4/conf/${UPLINK_IF}/proxy_arp
        echo "0" > /proc/sys/net/ipv4/ip_forward
        ip route del $IPAQ_NET  dev usb0
        ip route add $IPAQ_ADDR dev usb0
        iptables -t nat --flush
        iptables -t nat -A POSTROUTING -s ${IPAQ_ADDR} -j MASQUERADE
    #   iptables -t nat -A POSTROUTING -s ${IPAQ_NET} -j SNAT --to-source 1.1.1.0
        iptables -L -t nat
        echo "1" > /proc/sys/net/ipv4/ip_forward
    }
    
    stop() {
        ifconfig usb0 down
        rmmod -r usbnet
        iptables -t nat --flush
    }
    case "$1" in
        start|add)
            start
            ;;
        stop|remove)
            stop
            ;;
        *)
            echo $"Usage: $0 {start|stop|add|remove}"
            exit 1
    esac
    

  6. Add this script to /etc/hotplug/usb as ipaq:

    #!/bin/sh
    # iPAQ3870 - ${DEVICE} USB Event: ${ACTION}
    if [ -x /etc/init.d/SA1100-USB-NIC ]; then
            if [ "${ACTION}" = "add" ]; then
                    /etc/init.d/SA1100-USB-NIC start && exit 0
            else
                    /etc/init.d/SA1100-USB-NIC stop  && exit 0
            fi
    fi
    

Patrik Gfeller, gfellerpatrik@gmx.net