diff options
author | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2009-05-27 10:01:24 +0000 |
---|---|---|
committer | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2009-05-27 10:01:24 +0000 |
commit | 18c6813f2c788b603dab363b9138d65d24252167 (patch) | |
tree | 92402484268f2bc1d5e4e55f7321b9204ad47c5f /kernel/xpp/utils/xpp_fxloader | |
parent | 2a73224819e867eaf56371d6055e2ca4d36396b6 (diff) |
Big dump of newer xpp code.
For finer details and separate commits, you are advised to look into the
commit log of dahdi-{linux,tools}.
xpp.r7150
* 116x Astribanks:
- Support for the TwinStar capability and for FXO and (BRI|PRI) on
same device.
- New control protocol ("MPP").
- astribank_hextool - a low-level firmware loading tool instead of
fpga_load .
- astribank_tool - Other MPP activities .
- Can still reset (but just that) through older protocol.
- astribank_hexload is required for loading FPGA firmware for USB_FW.hex
rev > 6885.
- USB_FW rev. 7071 .
- More modular FPGA firmware (1161 only).
- FPGA_1161.hex rev. 7131. PIC_TYPE_* rev. 7107.
- software-settings of some capabilities with astribank_allow .
* XPP:
- init_card_* script are less verbose.
- Reduced rate of "Is a DAHDI sync master" message.
- Replace member bus_id with dev_name() and set_dev_name() for
building with 2.6.30.
- Conditionally remove 'owner' property of procfs was dropped in 2.6.30.
- astribank_hook now enabled by default.
- Has an optional hook for TwinStar.
* BRI:
- hardhdlc support: The bri_dchan patch is no longer needed.
- If bri_dchan patch applied: old code is used, and "dchan" is used.
- If not: new code and "hardhdlc" is used.
- zapconf will generate the right configuration, depending on the new
sysfs driver attribute bri_hardhdlc, but default to "dchan" as
before if not explicitly told.
- Bugfix: explicitly turn off leds on startup.
* FXS:
- Initialization and calibration fixes.
- Notify the user just one about wrong VMWI config
* Dahdi-perl:
- Fix detection of empty slots in wctdm.
- Fix working with ethmf's extra file in /proc/zaptel
- Improved detection of Rhino cards.
- dahdi_genconf's generated text better explains files are generated.
- /etc/xpp_order - allow specifiying an explicit order for
Astribanks to register with Zaptel.
- Dahdi::Xpp::Mpp - A wrapper around astribank_tool .
* dahdi.init:
- A separate waitfor_xpds script. May now have a wait-loop in
some cases.
- xpp_sync needs to only be called after dahdi_cfg .
(for the PRI module).
git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.4@4641 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'kernel/xpp/utils/xpp_fxloader')
-rwxr-xr-x | kernel/xpp/utils/xpp_fxloader | 164 |
1 files changed, 114 insertions, 50 deletions
diff --git a/kernel/xpp/utils/xpp_fxloader b/kernel/xpp/utils/xpp_fxloader index 925ee97..feaf712 100755 --- a/kernel/xpp/utils/xpp_fxloader +++ b/kernel/xpp/utils/xpp_fxloader @@ -2,13 +2,34 @@ # xpp_fxloader: load Xorcom Astribank (XPP) firmware # +# Written by Tzafrir Cohen <tzafrir.cohen@xorcom.com> +# Copyright (C) 2006, 2007, 2008, 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. +# + +# # This script can be run manually or from hotplug/udev. # # 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 -# +# 3. Can be overidden by setting $FIRMWARE_DIR in /etc/sysconfig/zaptel (Red Hat derivatives) +# or /etc/default/zaptel (Debian derivatives) # Manual Run # ########## # @@ -76,10 +97,9 @@ DEVUSB_PREFIX=/dev/bus/usb USB_PREFIX= FIRMWARE_DIR="${FIRMWARE_DIR:-/usr/share/zaptel}" +ASTRIBANK_HEXLOAD=${ASTRIBANK_HEXLOAD:-/usr/sbin/astribank_hexload} +ASTRIBANK_TOOL=${ASTRIBANK_TOOL:-/usr/sbin/astribank_tool} -FIRM_FXS=$FIRMWARE_DIR/FPGA_FXS.hex - -FPGA_LOAD=${FPGA_LOAD:-/usr/sbin/fpga_load} USB_FW="${USB_FW:-USB_FW.hex}" if [ -r "$DEFAULTS" ]; then @@ -112,12 +132,37 @@ find_dev() { lsusb | tr -d : | awk "/ ID $v_id$p_id/{printf \"$USB_PREFIX/%s/%s \",\$2,\$4}" } -do_fxload() { +run_fxload() { sleep_if_race - ( fxload -t fx2 $* 2>&1 1>/dev/null || exit 1 ) | $LOGGER + fxload -t fx2 $* 2>&1 1>/dev/null | $LOGGER + status=$PIPESTATUS + if [ $status != 0 ]; then + $LOGGER "fxload failed with status $status" + exit 55 + fi } -load_fw() { +run_astribank_hexload() { + $LOGGER "Running: $ASTRIBANK_HEXLOAD $*" + $ASTRIBANK_HEXLOAD "$@" | $LOGGER + status=$PIPESTATUS + if [ $status != 0 ]; then + $LOGGER "$ASTRIBANK_HEXLOAD failed with status $status" + exit 77 + fi +} + +run_astribank_tool() { + $LOGGER "Running: $ASTRIBANK_TOOL $*" + $ASTRIBANK_TOOL "$@" | $LOGGER + status=$PIPESTATUS + if [ $status != 0 ]; then + $LOGGER "$ASTRIBANK_TOOL failed with status $status" + exit 77 + fi +} + +load_usb_fw() { v_id=$1 p_id=$2 fw=$3 @@ -125,34 +170,48 @@ load_fw() { 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 + ver=$(awk '/\$Id:/ { print $4 }' $FIRMWARE_DIR/$fw) + $LOGGER "USB Firmware $FIRMWARE_DIR/$fw (Version=$ver) into $dev" + run_fxload -D $dev -I $FIRMWARE_DIR/$fw || exit 1 done } -load_fpga() { +load_fw_device() { + dev=$1 + fw=$2 + $LOGGER "FPGA loading $fw into $dev" + run_astribank_hexload -D "$dev" -F "$FIRMWARE_DIR/$fw" + pic_files=`echo "$FIRMWARE_DIR"/PIC_TYPE_[1-4].hex` + $LOGGER "PIC burning into $dev: $pic_files" + run_astribank_hexload -D "$dev" -p $pic_files + run_astribank_tool -D "$dev" -n # Do renumeration! + $LOGGER "PIC burning finished $pic_files" +} + +# +# Use in manual loading. Parallelize loading +# firmwares to all of our devices +# +firmware_by_id() { v_id=$1 p_id=$2 fw=$3 devices=`find_dev $v_id $p_id` + childs="" for dev in $devices do ( - card_ver=`$FPGA_LOAD -g -D $dev | sed -n 's/^.*Release: *//'` + set -e - $LOGGER "FPGA Firmware into $dev" + load_fw_device "$dev" "$fw" sleep_if_race - $FPGA_LOAD -D "$dev" -I "$FIRMWARE_DIR/$fw" -i | $LOGGER - status=$PIPESTATUS - if [ $status != 0 ]; then - echo "fpga_load failed with status $status" | $LOGGER - exit 77 - fi ) & + childs="$childs $!" sleep 0.4 done - wait + # Wait for specific childs to get their exit status + wait $childs } numdevs() { @@ -188,23 +247,26 @@ wait_renumeration() { reset_fpga() { totaldevs=`numdevs e4e4 '11[3456][012]'` devices=`find_dev e4e4 '11[3456][12]'` - echo "Reseting devices [$totaldevs devices]" + $LOGGER "Reseting devices [$totaldevs devices]" for dev in $devices do $LOGGER "Resetting FPGA Firmware on $dev" sleep_if_race - $FPGA_LOAD -D "$dev" -r 2>&1 >/dev/null | $LOGGER - status=$PIPESTATUS - if [ "$status" != 0 ]; then - echo "fpga_load failed removing with status $status" | $LOGGER - exit 78 - fi + run_astribank_tool -D "$dev" -r full 2>&1 >/dev/null done if [ "$1" = 'wait' ]; then wait_renumeration $totaldevs e4e4 '11[3456]0' fi } +usage() { + echo "$0: Astribank firmware loading script." + echo "Usage: " + echo "$0 load : manual firmware loading." + echo "$0 usb : manual firmware loading: USB firmware only." + echo "$0 help : this text." +} + ######################### ## ## Manual run @@ -226,36 +288,38 @@ reset) ;; xppdetect|load|usb) numdevs=`numdevs e4e4 '11[3456][01]'` - echo "--------- FIRMWARE LOADING: ($1) [$numdevs devices]" + $LOGGER -- "--------- FIRMWARE LOADING: ($1) [$numdevs devices]" - load_fw e4e4 1130 $USB_FW - load_fw e4e4 1140 $USB_FW - load_fw e4e4 1150 $USB_FW - load_fw e4e4 1160 $USB_FW + load_usb_fw e4e4 1130 $USB_FW + load_usb_fw e4e4 1140 $USB_FW + load_usb_fw e4e4 1150 $USB_FW + load_usb_fw e4e4 1160 $USB_FW wait_renumeration $numdevs e4e4 '11[3456]1' if [ "$1" != 'usb' ] then - load_fpga e4e4 1131 FPGA_FXS.hex - load_fpga e4e4 1141 FPGA_1141.hex - load_fpga e4e4 1151 FPGA_1151.hex - load_fpga e4e4 1161 FPGA_1161.hex + firmware_by_id e4e4 1131 FPGA_FXS.hex + firmware_by_id e4e4 1141 FPGA_1141.hex + firmware_by_id e4e4 1151 FPGA_1151.hex + firmware_by_id e4e4 1161 FPGA_1161.hex wait_renumeration $numdevs e4e4 '11[3456]2' fi sleep 3 # Let it stabilize - echo "--------- FIRMWARE IS LOADED" + $LOGGER -- "--------- FIRMWARE IS LOADED" exit 0 ;; help) - echo "$0: Astribank firmware loading script." - echo "Usage: " - echo "$0 load : manual firmware loading." - echo "$0 usb : manual firmware loading: USB firmware only." - echo "$0 help : this text." - echo "" - echo "('xppdetect' is an alias of 'load')" + usage exit 0 ;; +*) + if [ "$ACTION" = '' ]; then # not called from hotplug + echo "$0: Error: unknown command \"$1\"" + echo '' + usage + exit 1 + fi + ;; esac ######################### @@ -274,19 +338,19 @@ then $LOGGER "Trying to find what to do for product $PRODUCT, device $DEVICE" prod_id=`echo "$PRODUCT" | cut -d/ -f2` case "$PRODUCT" in - e4e4/11[345]0/*) + e4e4/11[3456]0/*) FIRM_USB="$FIRMWARE_DIR/$USB_FW" $LOGGER "Loading firmware '$FIRM_USB' into '$DEVICE'" - do_fxload -D "$DEVICE" -I "$FIRM_USB" + run_fxload -D "$DEVICE" -I "$FIRM_USB" ;; - e4e4/11[345]1/*) + e4e4/11[3456]1/*) if [ "$prod_id" = 1131 ]; then - FIRM_FPGA="$FIRMWARE_DIR/FPGA_FXS.hex" # Legacy + FIRM_FPGA="FPGA_FXS.hex" # Legacy else - FIRM_FPGA="$FIRMWARE_DIR/FPGA_$prod_id.hex" + FIRM_FPGA="FPGA_$prod_id.hex" fi sleep_if_race - $FPGA_LOAD -D "$DEVICE" -I "$FIRM_FPGA" 2>&1 >/dev/null | $LOGGER + load_fw_device "$DEVICE" "$FIRM_FPGA" ;; esac fi |