lantiq: support loading the dsl firmware from a flash partition as a raw gzipped...
[openwrt.git] / target / linux / lantiq / base-files / etc / init.d / dsl_fs
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2014 OpenWrt.org
3
4 . /lib/functions.sh
5
6 START=30
7
8 boot() {
9         MTD=$(find_mtd_index dsl_fw)
10
11         grep /lib/firmware/lantiq /proc/mounts && umount /lib/firmware/lantiq
12
13         mkdir -p /lib/firmware/lantiq
14         [ "$MTD" -gt 0 ] || return 0
15
16         mount -t tmpfs none /lib/firmware/lantiq
17         case "$(dd if=/dev/mtd$MTD bs=2 count=1 2>/dev/null | hexdump -n 2 -e '1/1 "%02x"')" in
18                 1985)
19                         mkdir -p /tmp/fw_mnt
20                         mount -t jffs2 /dev/mtdblock$MTD /tmp/fw_mnt
21                         cp -a /tmp/fw_mnt/*.bin /lib/firmware/lantiq/
22                         umount /tmp/fw_mnt
23                         rmdir /tmp/fw_mnt
24                 ;;
25                 1f8b)
26                         tar xz -C /lib/firmware/lantiq < /dev/mtd$MTD
27                 ;;
28                 *)
29                         echo "No DSL firmware detected in /dev/mtd$MTD (dsl_fw)"
30                         return 0
31                 ;;
32         esac
33
34         [ -e /lib/firmware/vdsl.bin ] || ln -s /lib/firmware/lantiq/vr9_dsl_fw_annex_b.bin /lib/firmware/vdsl.bin
35 }