#!/bin/sh

# Load bulk/interrupt transfer test firmware into
# various EZ-USB USB devices that will run it
#
# Assumes 2002_04_11 release of fxload (or later)

FIRMWARE=
FLAGS=
LOADER=/sbin/fxload

# use "-s $A3LOAD" for firmware that goes into external RAM
A3LOAD=/usr/share/usb/a3load.hex


# pre-renumeration device IDs
case $PRODUCT in

# (USB 2.0) FX2 development kit
4b4/8613/*)
    FIRMWARE=usb/perf.fw/bulksrc-fx2.ihx
    FLAGS="-t fx2"
    ;;

# (USB 1.1) Keyspan USA-19Q PDA adapter
# ... we can use any non-FX2 device with this firmware
6cd/10b/*)
    FIRMWARE=usb/perf.fw/bulktest-fx.ihx
    FLAGS="-t an21"
    ;;

# other pre-renumeration IDs could go here
# but most would fit one of the two cases above

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 $FIRMWARE ]; then
    if [ -x /usr/bin/logger ]; then
	/usr/bin/logger -t $0 "missing $FIRMWARE 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 $FIRMWARE for $PRODUCT to $DEVICE"
fi
$LOADER $FLAGS -I $FIRMWARE