fa99ed2777510e88de7a0a00eba46debacb99d6d
[openwrt/openwrt.git] / package / kernel / lantiq / ltq-vdsl-fw / src / vdsl_fw_install.sh
1 #!/bin/sh
2 . /lib/functions.sh
3
4 FW="/tmp/firmware-speedport-w921v-1.44.000.bin"
5 URL="https://www.telekom.de/hilfe/downloads/firmware-speedport-w921v-1.44.000.bin"
6 FW_TAPI="vr9_tapi_fw.bin"
7 FW_DSL="vr9_dsl_fw_annex_b.bin"
8 MD5_FW="cefbeb7073e02e0fa4ddb6b31ecb3d1e"
9 MD5_TAPI="57f2d07f59e11250ce1219bad99c1eda"
10 MD5_DSL="655442e31deaa42c9c68944869361ec0"
11
12 [ -f /lib/firmware/vdsl.bin ] && exit 0
13
14 [ -z "$1" ] || URL=$1
15
16 [ -f "${FW}" ] || {
17 echo "${FW} does not exist. Try to Download it ? (y/N)"
18 read -n 1 R
19 echo ""
20 [ "$R" = "y" ] || {
21 echo "Please manually download the firmware from ${URL} and copy the file to ${FW}"
22 echo "See also https://xdarklight.github.io/lantiq-xdsl-firmware-info/ for alternatives"
23 exit 1
24 }
25 echo "Download w921v Firmware"
26 wget "${URL}" -O "${FW}"
27 [ $? -eq 0 -a -f "${FW}" ] || exit 1
28 }
29
30 F=`md5sum -b ${FW} | cut -d" " -f1`
31 [ "$F" = "${MD5_FW}" ] || {
32 echo "Failed to verify Firmware MD5"
33 exit 1
34 }
35
36 cd /tmp
37 echo "Unpack and decompress w921v Firmware"
38
39 w921v_fw_cutter
40 [ $? -eq 0 ] || exit 1
41
42 T=`md5sum -b ${FW_TAPI} | cut -d" " -f1`
43 D=`md5sum -b ${FW_DSL} | cut -d" " -f1`
44
45 [ "$T" = "${MD5_TAPI}" -a "$D" = "${MD5_DSL}" ] || {
46 echo "Failed to verify MD5"
47 exit 1
48 }
49
50 MTD=$(find_mtd_index dsl_fw)
51 if [ "$MTD" -gt 0 -a -e "/dev/mtd$MTD" ]; then
52 echo "Storing firmware in flash"
53 tar cvz ${FW_TAPI} ${FW_DSL} | mtd write - "/dev/mtd$MTD"
54 /etc/init.d/dsl_fs boot
55 else
56 cp ${FW_TAPI} ${FW_DSL} /lib/firmware/
57 ln -s /lib/firmware/vr9_dsl_fw_annex_b.bin /lib/firmware/vdsl.bin
58 fi