Skip to content

Intercepting hotplug on the Freecom FSG-3

The Freecom FSG-3 wireless storage router has four USB ports, and has support for hotplug built into the kernel.  This makes it ideal for use as a docking station for OpenMoko phones.

Unfortunately, it does not have the normal hotplug agent scripts that you expect to find on a desktop Linux distribution.

So you have to roll your own:

  1. Run “mv /sbin/hotplug /sbin/hotplug.freecom
  2. Create a new “/sbin/hotplug” shell script (the following is an example of how to automatically enable USB networking for an OpenMoko phone):
    #!/bin/sh
    
    case $1 in
      ( usb )
        case $PRODUCT/$INTERFACE in
          ( 1457/5122/212/2/6/0 ) # OpenMoko GTA01 cdc-ether
            case $ACTION in
              ( add )
                ifconfig usb0 192.168.0.200 up
                ;;
              ( remove )
                ifconfig usb0 192.168.0.200 down
                ;;
            esac
            ;;
        esac
        ;;
    esac
    
    /sbin/hotplug.freecom "$@"
    

  3. Run “chmod ugo+x /sbin/hotplug” to ensure that your new hotplug script is executable.
  4. See http://linux-hotplug.sourceforge.net/?selected=usb for the list of environment variables you can use to distinguish different devices.