1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2012 OpenWrt.org
4 # needs to start before the atm layer which starts at 50
8 EXTRA_COMMANDS
="status lucistat"
9 EXTRA_HELP
=" status Get DSL status information
10 lucistat Get status information if lua friendly format"
12 [ -f /lib
/functions
/lantiq_dsl.sh
] && .
/lib
/functions
/lantiq_dsl.sh
15 # ITU-T G.997.1 (06/2012) - Section 7.3.1.1.1 (xTU transmission system enabling (XTSE))
16 # ITU-T G.997.1 Amendment 2 (04/2013) - Section 2.1 - (Vectoring mode enable (VECTORMODE_ENABLE))
20 # G.992.3 Annex A / L-US1 / L_US-2 / M
24 xtse_xdsl_a
="05_01_04_00_4C_01_04_07"
31 xtse_xdsl_b
="10_00_10_00_00_04_00_07"
40 xtse_xdsl_j
="10_00_10_40_00_04_01_07"
43 xtse_xdsl_bdmt
="10_00_00_00_00_00_00_00"
46 xtse_xdsl_b2
="00_00_10_00_00_00_00_00"
49 xtse_xdsl_b2p
="00_00_00_00_00_04_00_00"
52 xtse_xdsl_at1
="01_00_00_00_00_00_00_00"
55 xtse_xdsl_alite
="00_01_00_00_00_00_00_00"
58 xtse_xdsl_admt
="04_00_00_00_00_00_00_00"
61 xtse_xdsl_a2
="00_00_04_00_00_00_00_00"
64 xtse_xdsl_a2p
="00_00_00_00_00_01_00_00"
67 xtse_xdsl_l
="00_00_00_00_0C_00_00_00"
71 xtse_xdsl_m
="00_00_00_00_40_00_04_00"
74 xtse_xdsl_m2
="00_00_00_00_40_00_00_00"
77 xtse_xdsl_m2p
="00_00_00_00_00_00_04_00"
80 # ITU-T G.994.1 (06/2012) - Table 2 (Mandatory carrier sets)
84 tone_adsl_a
="0x142" # A43C + J43 + A43
85 tone_vdsl_a
="0x142" # A43C + J43 + A43
88 tone_adsl_av
="0x142" # A43C + J43 + A43
89 tone_vdsl_av
="0x146" # A43C + J43 + A43 + V43
92 tone_adsl_b
="0x81" # B43 + B43c
93 tone_vdsl_b
="0x1" # B43
96 tone_adsl_bv
="0x81" # B43 + B43c
97 tone_vdsl_bv
="0x5" # B43 + V43
99 # create ADSL autoboot script. Used for SNR margin tweak
101 echo "[WaitForConfiguration]={
105 [WaitForLinkActivate]={
116 echo "# VRX Low Level Configuration File
118 # Parameters must be separated by tabs or spaces.
119 # Empty lines and comments will be ignored.
134 # nHsToneGroupMode nHsToneGroup_A nHsToneGroup_V nHsToneGroup_AV
136 # NA = -1 NA = -1 see see
137 # AUTO = 0 VDSL2_B43 = 0x0001 nHsToneGroup_A nHsToneGroup_A
138 # MANUAL = 1 VDSL2_A43 = 0x0002
140 # VDSL1_V43P = 0x0008
141 # VDSL1_V43I = 0x0010
144 # ADSL2_B43C = 0x0080
145 # ADSL2_A43C = 0x0100
147 # (dec) (hex) (hex) (hex)
155 # nUtopiaPhyAdr nUtopiaBusWidth nPosPhyParity
156 # default(16b) = 0 NA = -1
167 0" > /tmp
/lowlevel.cfg
171 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 [ -z "${xfer_mode}" ] && xfer_mode
=ptm
199 case "${xfer_mode}" in
201 # in most cases atm is used on top of adsl
202 [ -z "${line_mode}" ] && line_mode
=adsl
205 # in most cases ptm is used on top of vdsl
206 [ -z "${line_mode}" ] && line_mode
=vdsl
210 case "${line_mode}" in
214 # mask out VDSL bits when ADSL is requested
220 # mask out ADSL bits when VDSL is requested
221 xtse
="00_00_00_00_00_00_00_${xtse##*_}"
225 local annexgpio
="/sys/class/gpio/annex"
226 if [ -d "${annexgpio}a" ] && [ -d "${annexgpio}b" ]; then
229 echo 1 > "${annexgpio}a/value"
230 echo 0 > "${annexgpio}b/value"
233 echo 0 > "${annexgpio}a/value"
234 echo 1 > "${annexgpio}b/value"
239 if [ -z "${firmware}" ]; then
240 # search for the firmware provided by dsl-vrx200-firmware-xdsl-*
241 if grep -qE "system type.*: (VR9|xRX200)" /proc
/cpuinfo
; then
244 if [ -f "/lib/firmware/lantiq-vrx200-a.bin" ]; then
245 firmware
="/lib/firmware/lantiq-vrx200-a.bin"
246 elif [ -f "/tmp/lantiq-vrx200-a.bin" ]; then
247 firmware
="/tmp/lantiq-vrx200-a.bin"
248 elif [ -f "/lib/firmware/lantiq-vrx200-b.bin" ] && [ -f "/lib/firmware/lantiq-vrx200-b-to-a.bspatch" ]; then
249 bspatch
/lib
/firmware
/lantiq-vrx200-b.bin \
250 /tmp
/lantiq-vrx200-a.bin \
251 /lib
/firmware
/lantiq-vrx200-b-to-a.bspatch
252 firmware
="/tmp/lantiq-vrx200-a.bin"
254 echo "firmware for annex a not found"
259 if [ -f "/lib/firmware/lantiq-vrx200-b.bin" ]; then
260 firmware
="/lib/firmware/lantiq-vrx200-b.bin"
261 elif [ -f "/tmp/lantiq-vrx200-b.bin" ]; then
262 firmware
="/tmp/lantiq-vrx200-b.bin"
263 elif [ -f "/lib/firmware/lantiq-vrx200-a.bin" ] && [ -f "/lib/firmware/lantiq-vrx200-a-to-b.bspatch" ]; then
264 bspatch
/lib
/firmware
/lantiq-vrx200-a.bin \
265 /tmp
/lantiq-vrx200-b.bin \
266 /lib
/firmware
/lantiq-vrx200-a-to-b.bspatch
267 firmware
="/tmp/lantiq-vrx200-b.bin"
269 echo "firmware for annex b not found"
274 echo "annex type not supported use a or b"
281 [ -z "${firmware}" ] && firmware
=/lib
/firmware
/vdsl.bin
282 [ -f "${firmware}" ] ||
{
283 echo failed to
find $firmware
287 eval "tone_adsl=\"\${tone_adsl_$tone}\""
288 eval "tone_vdsl=\"\${tone_vdsl_$tone}\""
289 [ -n "${tone_adsl}" ] && [ -n "${tone_vdsl}" ] && {
290 lowlevel_cfg
"${tone_adsl}" "${tone_vdsl}"
291 lowlevel
="-l /tmp/lowlevel.cfg"
295 # for SNR offset setting
296 autoboot_script
"$snr"
297 autoboot
="-a /tmp/adsl.scr"
301 procd_set_param
command /sbin
/vdsl_cpe_control \
303 -n /sbin
/dsl_notify.sh \
312 # do not use dsl_cmd to not block when this is locked up by some other proess
313 echo quit
> /tmp
/pipe
/dsl_cpe0_cmd
314 DSL_NOTIFICATION_TYPE
="DSL_INTERFACE_STATUS" \
315 DSL_INTERFACE_STATUS
="DOWN" \