#!/bin/sh

# Load bulk/interrupt transfer firmware into
# Polhemus Liberty HST EZ-USB USB device
#
# Assumes 2002_04_11 release of fxload (or later)
#
# Original from Hotplug project
# Modified by Daniel Myall <daniel@westco.co.nz> for Liberty

LOADER=/sbin/fxload
A3LOAD=/usr/share/usb/a3load.hex

# pre-renumeration device IDs
case $PRODUCT in

# Liberty HST Loader
f44/ff11/*)
    FIRMWARE=/usr/share/usb/LibertyUSB.hex
    FLAGS="-t fx -s $A3LOAD"
    ;;

esac

# quit unless we were called to download some firmware
if [ "$FIRMWARE" = "" ]; then
    # OR:  restructure to do other things for
    # specific post-renumeration devices
    exit 0
fi

# missing firmware?
if [ ! -r $FIRMWAREA ]; then
    if [ -x /usr/bin/logger ]; then
    /usr/bin/logger -t $0 "missing $FIRMWAREA for $PRODUCT ??"
    fi
    exit 1
fi

# missing loader?
if [ ! -x $LOADER ]; then
    if [ -x /usr/bin/logger ]; then
    /usr/bin/logger -t $0 "missing $LOADER ??"
    fi
    exit 1
fi

if [ -x /usr/bin/logger ]; then
    /usr/bin/logger -t $0 "load $FIRMWAREA for $PRODUCT to $DEVICE"
fi

$LOADER $FLAGS -I $FIRMWARE