diff options
author | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2006-07-08 00:43:31 +0000 |
---|---|---|
committer | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2006-07-08 00:43:31 +0000 |
commit | ec6b220aa7a334ccbd0fcb41d35c66560fc78a11 (patch) | |
tree | 8ee3f2338f95b3fa67f8512adb8fe4842643c391 /xpp/utils/xpp_fxloader | |
parent | 4e4b79bf56f6477b65973c869e5a8936aea27864 (diff) |
xpp Release 1.1.0 :
* FPGA firmware now loaded from PC (for newer models)
* Driver for the FXO module (xpd_fxo.ko)
* Moved most userspace files to the subdirectory utils (see also next commit)
* Explicit license for firmware files
* Optionally avoid auto-registration
* Registers initializations code is done by a userspace script.
* Remove obsolete .inc initialization files (we use user-space init)
* Added an install target to the utils dir.
* Updated README.Astribank accordingly.
* Using RBS signalling, as caller ID did not work well otherwise.
* Better handling of USB protocol errors.
* Fixed some procfs-related races.
* per-card-module ioctls.
* fxotune support.
* opermode support (set through /etc/default/zaptel for now)
* Userspace initialization script can also read registers.
* Power calibration works (and implemented in perl)
* some fine-tuning to the regster initialization parameters.
* Leds turn on before registration and turn off after it.
git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.2@1212 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'xpp/utils/xpp_fxloader')
-rw-r--r-- | xpp/utils/xpp_fxloader | 163 |
1 files changed, 163 insertions, 0 deletions
diff --git a/xpp/utils/xpp_fxloader b/xpp/utils/xpp_fxloader new file mode 100644 index 0000000..ca29fd2 --- /dev/null +++ b/xpp/utils/xpp_fxloader @@ -0,0 +1,163 @@ +#!/bin/sh + +# xpp_fxload: load XPP firmware +# +# This script can be run manually or from hotplug. +# +# Firmware files should be located in $FIRMWARE_DIR which defaults: +# 1. /usr/share/zaptel +# 2. Can be overidden by setting $FIRMWARE_DIR in the environment +# 3. Can be overidden by setting $FIRMWARE_DIR in /etc/default/zaptel +# +# Manual Run +# ########## +# +# path/to/xpp_fxloader xppdetect +# +# Make sure the firmware files are in $FIRMWARE_DIR +# +# +# Hotplg Run +# ########## +# +# 1. Copy this file and the file xpp_fxloader.usermap to /etc/hotplug/usb/ +# 2. tail -f /var/log/messages... +# +# +# Written by Tzafrir Cohen <tzafrir.cohen@xorcom.com> +# Copyright (C) 2006, Xorcom +# +# All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +set -e + +me=`basename $0` +DEFAULTS="/etc/default/zaptel" + +if [ -t 2 ]; then + LOGGER="logger -i -t '$me' -s" +else + LOGGER="logger -i -t '$me'" +fi + +if [ -r "$DEFAULTS" ]; then + . "$DEFAULTS" +fi + +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" + +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}" +} + +do_fxload() { + ( fxload -t fx2 $* 2>&1 1>/dev/null || exit 1 ) | $LOGGER +} + +load_fw() { + v_id=$1 + p_id=$2 + fw=$3 + + devices=`find_dev $v_id $p_id` + for dev in $devices + do + $LOGGER "USB Firmware $FIRMWARE_DIR/$fw into $dev" + do_fxload -D $dev -I $FIRMWARE_DIR/$fw || exit 1 + done + + # Allow time for reenumeration: This only matters in the manual case. + if [ "$devices" != '' ]; then sleep $REENUM_SLEEP_TIME; fi +} + +hexfile_version() { + hexfile=$1 + + grep '$Id:' "$hexfile" | sed -e 's/^.*$Id: *[^ ]\+ *//' -e 's/ .*$//' +} + +load_fpga() { + v_id=$1 + p_id=$2 + fw=$3 + + devices=`find_dev $v_id $p_id` + for dev in $devices + do + card_ver=`$FPGA_LOAD -d -D $dev` + firm_ver=`hexfile_version $FIRMWARE_DIR/$fw` + + $LOGGER "FPGA Firmware $FIRMWARE_DIR/$fw into $dev" + $FPGA_LOAD -D "$dev" -I "$FIRMWARE_DIR/$fw" 2>&1 >/dev/null | $LOGGER + status=$PIPESTATUS + if [ $status != 0 ]; then + echo "fpga_load failed with status $status" | $LOGGER + exit 77 + fi + done +} + +######################### +## +## Manual run +## + +# to run manually, pass the parameter 'xppdetect' +if [ "$1" = 'xppdetect' ]; then + echo "--------- FIRMWARE LOADING" + load_fw 04b4 8613 USB_8613.hex + load_fw e4e4 1130 USB_1130.hex + load_fpga e4e4 1131 FPGA_FXS.hex + + sleep 3 # Let it stabilize + echo "--------- FIRMWARE IS LOADED" + exit $? +fi + +######################### +## +## Hotplug run +## + +if [ "$ACTION" = "add" ] && [ -f "$DEVICE" ] +then + $LOGGER "Trying to find what to do for product $PRODUCT, device $DEVICE" + prod_id=`echo "$PRODUCT" | cut -d/ -f2` + case "$PRODUCT" in + 4b4/8613/*|e4e4/1130/*|e4e4/1140/*) + FIRM_USB="$FIRMWARE_DIR/USB_$prod_id.hex" + $LOGGER "Loading firmware '$FIRM_USB' into '$DEVICE'" + do_fxload -D "$DEVICE" -I "$FIRM_USB" + ;; + e4e4/1131/*|e4e4/1141/*) + if [ "$prod_id" = 1131 ]; then + FIRM_FPGA="$FIRMWARE_DIR/FPGA_FXS.hex" # Legacy + else + FIRM_FPGA="$FIRMWARE_DIR/FPGA_$prod_id.hex" + fi + $FPGA_LOAD -D "$DEVICE" -I "$FIRM_FPGA" 2>&1 >/dev/null | $LOGGER + ;; + esac +fi |