1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2012 OpenWrt.org
7 EXTRA_COMMANDS
="dslstat lucistat"
8 EXTRA_HELP
=" dslstat Get DSL status information
9 lucistat Get status information in lua friendly format"
11 [ -f /lib
/functions
/lantiq_dsl.sh
] && .
/lib
/functions
/lantiq_dsl.sh
14 # ITU-T G.997.1 (06/2012) - Section 7.3.1.1.1 (xTU transmission system enabling (XTSE))
15 # ITU-T G.997.1 Amendment 2 (04/2013) - Section 2.1 - (Vectoring mode enable (VECTORMODE_ENABLE))
19 # G.992.3 Annex A / L-US1 / L_US-2 / M
23 xtse_xdsl_a
="05_01_04_00_4C_01_04_07"
30 xtse_xdsl_b
="10_00_10_00_00_04_00_07"
39 xtse_xdsl_j
="10_00_10_40_00_04_01_07"
42 xtse_xdsl_bdmt
="10_00_00_00_00_00_00_00"
45 xtse_xdsl_b2
="00_00_10_00_00_00_00_00"
48 xtse_xdsl_b2p
="00_00_00_00_00_04_00_00"
51 xtse_xdsl_at1
="01_00_00_00_00_00_00_00"
54 xtse_xdsl_alite
="00_01_00_00_00_00_00_00"
57 xtse_xdsl_admt
="04_00_00_00_00_00_00_00"
60 xtse_xdsl_a2
="00_00_04_00_00_00_00_00"
63 xtse_xdsl_a2p
="00_00_00_00_00_01_00_00"
66 xtse_xdsl_l
="00_00_00_00_0C_00_00_00"
70 xtse_xdsl_m
="00_00_00_00_40_00_04_00"
73 xtse_xdsl_m2
="00_00_00_00_40_00_00_00"
76 xtse_xdsl_m2p
="00_00_00_00_00_00_04_00"
79 # ITU-T G.994.1 (06/2012) - Table 2 (Mandatory carrier sets)
83 tone_adsl_a
="0x142" # A43C + J43 + A43
84 tone_vdsl_a
="0x142" # A43C + J43 + A43
87 tone_adsl_av
="0x142" # A43C + J43 + A43
88 tone_vdsl_av
="0x146" # A43C + J43 + A43 + V43
91 tone_adsl_b
="0x81" # B43 + B43c
92 tone_vdsl_b
="0x1" # B43
95 tone_adsl_bv
="0x81" # B43 + B43c
96 tone_vdsl_bv
="0x5" # B43 + V43
98 # create ADSL autoboot script. Used for SNR margin tweak
100 echo "[WaitForConfiguration]={
104 [WaitForLinkActivate]={
115 echo "# VRX Low Level Configuration File
117 # Parameters must be separated by tabs or spaces.
118 # Empty lines and comments will be ignored.
133 # nHsToneGroupMode nHsToneGroup_A nHsToneGroup_V nHsToneGroup_AV
135 # NA = -1 NA = -1 see see
136 # AUTO = 0 VDSL2_B43 = 0x0001 nHsToneGroup_A nHsToneGroup_A
137 # MANUAL = 1 VDSL2_A43 = 0x0002
139 # VDSL1_V43P = 0x0008
140 # VDSL1_V43I = 0x0010
143 # ADSL2_B43C = 0x0080
144 # ADSL2_A43C = 0x0100
146 # (dec) (hex) (hex) (hex)
154 # nUtopiaPhyAdr nUtopiaBusWidth nPosPhyParity
155 # default(16b) = 0 NA = -1
166 0" > /tmp
/lowlevel.cfg
170 procd_add_reload_trigger network
188 config_get tone dsl tone
189 config_get annex dsl annex
190 config_get firmware dsl firmware
191 config_get xfer_mode dsl xfer_mode
192 config_get line_mode dsl line_mode
193 config_get snr dsl ds_snr_offset
195 eval "xtse=\"\${xtse_xdsl_$annex}\""
197 case "${xfer_mode}" in
199 tc_layer
="-T1:0x1:0x1_1:0x1:0x1"
202 tc_layer
="-T2:0x1:0x1_2:0x1:0x1"
206 case "${line_mode}" in
210 # mask out VDSL bits when ADSL is requested
216 # mask out ADSL bits when VDSL is requested
217 xtse
="00_00_00_00_00_00_00_${xtse##*_}"
221 local annexgpio
="/sys/class/gpio/annex"
222 if [ -d "${annexgpio}a" ] && [ -d "${annexgpio}b" ]; then
225 echo 1 > "${annexgpio}a/value"
226 echo 0 > "${annexgpio}b/value"
229 echo 0 > "${annexgpio}a/value"
230 echo 1 > "${annexgpio}b/value"
235 if [ -z "${firmware}" ]; then
236 # search for the firmware provided by dsl-vrx200-firmware-xdsl-*
237 if grep -qE "system type.*: (VR9|xRX200)" /proc
/cpuinfo
; then
240 if [ -f "/lib/firmware/lantiq-vrx200-a.bin" ]; then
241 firmware
="/lib/firmware/lantiq-vrx200-a.bin"
242 elif [ -f "/tmp/lantiq-vrx200-a.bin" ]; then
243 firmware
="/tmp/lantiq-vrx200-a.bin"
244 elif [ -f "/lib/firmware/lantiq-vrx200-b.bin" ] && [ -f "/lib/firmware/lantiq-vrx200-b-to-a.bspatch" ]; then
245 bspatch
/lib
/firmware
/lantiq-vrx200-b.bin \
246 /tmp
/lantiq-vrx200-a.bin \
247 /lib
/firmware
/lantiq-vrx200-b-to-a.bspatch
248 firmware
="/tmp/lantiq-vrx200-a.bin"
250 echo "firmware for annex a not found"
255 if [ -f "/lib/firmware/vr9_dsl_fw_annex_b.bin" ]; then
256 firmware
="/lib/firmware/vr9_dsl_fw_annex_b.bin"
257 elif [ -f "/lib/firmware/lantiq-vrx200-b.bin" ]; then
258 firmware
="/lib/firmware/lantiq-vrx200-b.bin"
259 elif [ -f "/tmp/lantiq-vrx200-b.bin" ]; then
260 firmware
="/tmp/lantiq-vrx200-b.bin"
261 elif [ -f "/lib/firmware/lantiq-vrx200-a.bin" ] && [ -f "/lib/firmware/lantiq-vrx200-a-to-b.bspatch" ]; then
262 bspatch
/lib
/firmware
/lantiq-vrx200-a.bin \
263 /tmp
/lantiq-vrx200-b.bin \
264 /lib
/firmware
/lantiq-vrx200-a-to-b.bspatch
265 firmware
="/tmp/lantiq-vrx200-b.bin"
267 echo "firmware for annex b not found"
272 echo "annex type not supported use a or b"
279 [ -z "${firmware}" ] && firmware
=/lib
/firmware
/vdsl.bin
280 [ -f "${firmware}" ] ||
{
281 echo failed to
find $firmware
285 eval "tone_adsl=\"\${tone_adsl_$tone}\""
286 eval "tone_vdsl=\"\${tone_vdsl_$tone}\""
287 [ -n "${tone_adsl}" ] && [ -n "${tone_vdsl}" ] && {
288 lowlevel_cfg
"${tone_adsl}" "${tone_vdsl}"
289 lowlevel
="-l /tmp/lowlevel.cfg"
293 # for SNR offset setting
294 autoboot_script
"$snr"
295 autoboot
="-a /tmp/dsl.scr -A /tmp/dsl.scr"
299 procd_set_param
command /sbin
/vdsl_cpe_control \
301 -n /sbin
/dsl_notify.sh \
311 # do not use dsl_cmd to not block when this is locked up by some other proess
312 echo quit
> /tmp
/pipe
/dsl_cpe0_cmd
313 DSL_NOTIFICATION_TYPE
="DSL_INTERFACE_STATUS" \
314 DSL_INTERFACE_STATUS
="DOWN" \