[backfire] merge r27449
[openwrt-10.03/.git] / target / linux / ifxmips / extract.sh
1 #!/bin/sh
2
3 DIR="$1/"
4 FILE="$1/$2"
5
6 echo "This tool downloads the arcor a800 firmware release and extracts the voip firmware for the danube."
7 echo "Please only do so if it is legal in your country"
8
9 [ ! -f ${FILE} ] && {
10         echo ${FILE} is missing
11         exit 1
12 }
13
14 [ -f ${DIR}/ifxmips_fw_decodev2.tar.bz2 -a ! -f ${DIR}voip_coef.bin ] && {
15         [ ! -f ${DIR}decode_ifx_fw ] && {
16                 tar xjf ${DIR}ifxmips_fw_decodev2.tar.bz2 ifxmips_fw_decode/decode.c -O > ${DIR}decode.c
17                 gcc -o ${DIR}decode_ifx_fw ${DIR}decode.c
18         }
19         [ ! -f ${DIR}voip_coef.lzma ] && {
20                 ${DIR}decode_ifx_fw $FILE ${DIR}voip_coef.lzma
21         }
22         lzma d ${DIR}voip_coef.lzma ${DIR}voip_coef.bin
23 }
24 [ ! -f ${DIR}dsl_a.bin ] && {
25         dd if=${FILE} of=${DIR}dsl1.lzma bs=1 skip=2168832 count=150724
26         lzma d ${DIR}dsl2.lzma ${DIR}dsl_a.bin
27 }
28
29 [ ! -f ${DIR}dsl_b.bin ] && {
30         dd if=${FILE} of=${DIR}dsl2.lzma bs=1 skip=2320384 count=148343
31         lzma d ${DIR}dsl1.lzma ${DIR}dsl_b.bin
32 }
33
34 [ ! -f ${DIR}voip.bin ] && {
35         dd if=${FILE} of=${DIR}voip.lzma bs=1 skip=2468864 count=452105
36         lzma d ${DIR}voip.lzma ${DIR}voip.bin
37 }
38 exit 0
39
40 # get lzma offsets
41 # hexdump -C arcor_A800_452CPW_FW_1.02.206\(20081201\).bin | grep "5d 00 00 80"
42 # hexdump -C arcor_A800_452CPW_FW_1.02.206\(20081201\).bin | grep "00 d5 08 00"