mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
dectmngr: Support DCX81 firmware upgrade via init script
This commit is contained in:
parent
558bd40b9f
commit
a053e7752f
1 changed files with 49 additions and 9 deletions
|
|
@ -57,13 +57,53 @@ get_dcx81_device() {
|
||||||
device_name_line="$(grep '^DEVNAME=' "$uevent_file")" || return 1
|
device_name_line="$(grep '^DEVNAME=' "$uevent_file")" || return 1
|
||||||
readonly device="/dev/${device_name_line##DEVNAME=}"
|
readonly device="/dev/${device_name_line##DEVNAME=}"
|
||||||
[ -c "$device" ] || return 1
|
[ -c "$device" ] || return 1
|
||||||
printf "%s" "$device"
|
printf "%s" "$(basename $device)"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_dcx81_firmware() {
|
||||||
|
local dcx81_uart=$1
|
||||||
|
local fw_link="/lib/firmware/dcx81_firmware"
|
||||||
|
local fw_file
|
||||||
|
|
||||||
|
[ -L "$fw_link" ] || return
|
||||||
|
|
||||||
|
fw_file=$(readlink -f $fw_link)
|
||||||
|
[ -f "$fw_file" ] || return
|
||||||
|
|
||||||
|
# the symbolic link is not needed
|
||||||
|
rm -f $fw_link
|
||||||
|
|
||||||
|
eval $(/sbin/cmbs_tcx -comname "$dcx81_uart" -fw_version |grep DCX81_FW_Version)
|
||||||
|
[ -n "$DCX81_FW_Version" ] || return
|
||||||
|
|
||||||
|
if echo $(basename $fw_file) | grep -qi "$DCX81_FW_Version" ; then
|
||||||
|
logger -t "$PROG" "DCX81 running expected $DCX81_FW_Version"
|
||||||
|
return;
|
||||||
|
fi
|
||||||
|
|
||||||
|
logger -t "$PROG" "DCX81 firmware upgrading to $fw_file"
|
||||||
|
/sbin/cmbs_tcx -comname "$dcx81_uart" -fwu "$fw_file" 2>&1 >/dev/null &
|
||||||
|
|
||||||
|
echo -n "Updrading DCX81 firmware.." >/dev/console
|
||||||
|
local wait_time=0
|
||||||
|
while pidof cmbs_tcx >/dev/null && [ "$wait_time" -lt "200" ] ; do
|
||||||
|
sleep 5
|
||||||
|
wait_time=$(($wait_time + 5))
|
||||||
|
echo -n "." >/dev/console
|
||||||
|
done
|
||||||
|
|
||||||
|
if pidof cmbs_tcx >/dev/null ; then
|
||||||
|
killall -9 cmbs_tcx
|
||||||
|
logger -t "$PROG" "DCX81 firmware upgrade timeout"
|
||||||
|
else
|
||||||
|
logger -t "$PROG" "DCX81 firmware upgrade done"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
start_service() {
|
start_service() {
|
||||||
local opt_ext=
|
local opt_ext=
|
||||||
local rfpi=
|
local rfpi=
|
||||||
|
|
@ -75,14 +115,16 @@ start_service() {
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
opt_ext="-extensionShift $(get_extension_shift)"
|
|
||||||
|
|
||||||
local dcx81_uart_device
|
local dcx81_uart_device
|
||||||
if ! dcx81_uart_device="$(get_dcx81_device)"; then
|
if ! dcx81_uart_device="$(get_dcx81_device)"; then
|
||||||
logger -t "$PROG" -p daemon.warning "Could not determine DCX81 UART device. Falling back to default ttyH0."
|
logger -t "$PROG" -p daemon.warning "Could not determine DCX81 UART device. Falling back to default ttyH0."
|
||||||
dcx81_uart_device=/dev/ttyH0
|
dcx81_uart_device="ttyH0"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
check_dcx81_firmware $dcx81_uart_device
|
||||||
|
|
||||||
|
opt_ext="-extensionShift $(get_extension_shift)"
|
||||||
|
|
||||||
rfpi=$(db -q get hw.board.dect_rfpi)
|
rfpi=$(db -q get hw.board.dect_rfpi)
|
||||||
[ -n "$rfpi" -a ${#rfpi} -eq 14 ] && opt_ext="$opt_ext -rfpi $rfpi"
|
[ -n "$rfpi" -a ${#rfpi} -eq 14 ] && opt_ext="$opt_ext -rfpi $rfpi"
|
||||||
|
|
||||||
|
|
@ -106,21 +148,19 @@ start_service() {
|
||||||
|
|
||||||
procd_open_instance
|
procd_open_instance
|
||||||
|
|
||||||
# dectmngr takes expects device without /dev
|
|
||||||
readonly dcx81_uart_device_wo_dev="${dcx81_uart_device##/dev/}"
|
|
||||||
case "$log_dect_cmbs" in
|
case "$log_dect_cmbs" in
|
||||||
none)
|
none)
|
||||||
echo "Starting dectmngr with cmbs logging disabled"
|
echo "Starting dectmngr with cmbs logging disabled"
|
||||||
procd_set_param command "$PROG" -comname "$dcx81_uart_device_wo_dev" $opt_ext
|
procd_set_param command "$PROG" -comname "$dcx81_uart_device" $opt_ext
|
||||||
rm -f $LOG_PATH/*
|
rm -f $LOG_PATH/*
|
||||||
;;
|
;;
|
||||||
file)
|
file)
|
||||||
echo "Starting dectmngr with cmbs logging enabled to file"
|
echo "Starting dectmngr with cmbs logging enabled to file"
|
||||||
procd_set_param command "$PROG" -comname "$dcx81_uart_device_wo_dev" -log $LOG_PATH/dect-cmbs.log $opt_ext
|
procd_set_param command "$PROG" -comname "$dcx81_uart_device" -log $LOG_PATH/dect-cmbs.log $opt_ext
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Starting dectmngr with cmbs logging enabled to syslog"
|
echo "Starting dectmngr with cmbs logging enabled to syslog"
|
||||||
procd_set_param command "$PROG" -comname "$dcx81_uart_device_wo_dev" -syslog $opt_ext
|
procd_set_param command "$PROG" -comname "$dcx81_uart_device" -syslog $opt_ext
|
||||||
rm -f $LOG_PATH/*
|
rm -f $LOG_PATH/*
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue