diff options
Diffstat (limited to 'xpp/utils/xpp_fxloader')
-rw-r--r-- | xpp/utils/xpp_fxloader | 53 |
1 files changed, 29 insertions, 24 deletions
diff --git a/xpp/utils/xpp_fxloader b/xpp/utils/xpp_fxloader index b14f746..918a712 100644 --- a/xpp/utils/xpp_fxloader +++ b/xpp/utils/xpp_fxloader @@ -1,8 +1,8 @@ #!/bin/sh -# xpp_fxload: load XPP firmware +# xpp_fxloader: load Xorcom Astribank (XPP) firmware # -# This script can be run manually or from hotplug. +# This script can be run manually or from hotplug/udev. # # Firmware files should be located in $FIRMWARE_DIR which defaults: # 1. /usr/share/zaptel @@ -12,28 +12,21 @@ # Manual Run # ########## # -# path/to/xpp_fxloader xppdetect +# path/to/xpp_fxloader load # # Make sure the firmware files are in $FIRMWARE_DIR # +# UDEV Installation +# ################# # -# Hotplg Run -# ########## +# Copy xpp.rules to /etc/udev/udev.d and xpp_fxloader to /etc/hotplug/usb/ . # -# 1. Copy this file and the file xpp_fxloader.usermap to /etc/hotplug/usb/ -# 2. tail -f /var/log/messages... +# Hotplug Installation +# #################### # -# -# Suggested udev configuration: I used the following file as -# /etc/udev/rules.d/z60_zaptel.rules : +# Copy this file and the file xpp_fxloader.usermap to /etc/hotplug/usb/ . # -# BUS!="usb", ACTION!="add", GOTO="zaptel_usb_add_end" # -# SYSFS{idVendor}=="e4e4", SYSFS{idProduct}=="11[345][01]", \ -# RUN+="/etc/hotplug/usb/xpp_fxloader udev $sysfs{idVendor}/$sysfs{idProduct}/$sysfs{bcdDevice}" -# -# LABEL="zaptel_usb_add_end" -# # Written by Tzafrir Cohen <tzafrir.cohen@xorcom.com> # Copyright (C) 2006, Xorcom # @@ -64,16 +57,28 @@ else LOGGER="logger -i -t '$me'" fi -if [ -r "$DEFAULTS" ]; then - . "$DEFAULTS" -fi +USBFS_PREFIX=/proc/bus/usb +DEVUSB_PREFIX=/dev/bus/usb +USB_PREFIX= FIRMWARE_DIR="${FIRMWARE_DIR:-/usr/share/zaptel}" FIRM_FXS=$FIRMWARE_DIR/FPGA_FXS.hex REENUM_SLEEP_TIME=3 # only used on manual runs -FPGA_LOAD="/usr/sbin/fpga_load" +FPGA_LOAD=${FPGA_LOAD:-/usr/sbin/fpga_load} + +if [ -r "$DEFAULTS" ]; then + . "$DEFAULTS" +fi + +if [ "$USB_PREFIX" = '' ]; then + if [ -d "$DEVUSB_PREFIX" ]; then + USB_PREFIX=$DEVUSB_PREFIX + elif [ -r "$USBFS_PREFIX/devices" ]; then + USB_PREFIX=$USBFS_PREFIX + fi +fi # With Kernels older that 2.6.10 it seems to be possible # to trigger a race condition by running fxload or fpga_load @@ -90,7 +95,7 @@ find_dev() { v_id=$1 p_id=$2 - lsusb | tr -d : | awk "/ ID $v_id$p_id/{printf \"/proc/bus/usb/%s/%s \",\$2,\$4}" + lsusb | tr -d : | awk "/ ID $v_id$p_id/{printf \"$USB_PREFIX/%s/%s \",\$2,\$4}" } do_fxload() { @@ -128,7 +133,7 @@ load_fpga() { devices=`find_dev $v_id $p_id` for dev in $devices do - card_ver=`$FPGA_LOAD -d -D $dev` + card_ver=`$FPGA_LOAD -g -D $dev | sed -n 's/^.*Release: *//'` firm_ver=`hexfile_version $FIRMWARE_DIR/$fw` $LOGGER "FPGA Firmware $FIRMWARE_DIR/$fw into $dev" @@ -151,7 +156,7 @@ load_fpga() { case "$1" in udev) # the following emulate hotplug's environment from udev's environment: - DEVICE=`echo $DEVNAME | sed -e 's|^/dev/|/proc/|'` + DEVICE="$DEVNAME" PRODUCT="$2" # skip on to the rest of the script. Don't exit. ;; @@ -190,7 +195,7 @@ esac ## Hotplug run ## -if [ "$ACTION" = "add" ] && [ -f "$DEVICE" ] +if [ "$ACTION" = "add" ] && [ -w "$DEVICE" ] then $LOGGER "Trying to find what to do for product $PRODUCT, device $DEVICE" prod_id=`echo "$PRODUCT" | cut -d/ -f2` |