OpenWrt – Blame information for rev 4

Subversion Repositories:
Rev:
Rev Author Line No. Line
4 office 1 #!/bin/sh
2  
3 [ -e /lib/firmware/$FIRMWARE ] && exit 0
4  
5 . /lib/functions.sh
6 . /lib/functions/system.sh
7  
8 ath9k_eeprom_die() {
9 echo "ath9k eeprom: " "$*"
10 exit 1
11 }
12  
13 ath9k_eeprom_extract() {
14 local part=$1
15 local offset=$2
16 local count=$3
17 local mtd
18  
19 mtd=$(find_mtd_chardev $part)
20 [ -n "$mtd" ] || \
21 ath9k_eeprom_die "no mtd device found for partition $part"
22  
23 dd if=$mtd of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \
24 ath9k_eeprom_die "failed to extract from $mtd"
25 }
26  
27 ath9k_ubi_eeprom_extract() {
28 local part=$1
29 local offset=$2
30 local count=$3
31 local ubidev=$(nand_find_ubi $CI_UBIPART)
32 local ubi
33  
34 ubi=$(nand_find_volume $ubidev $part)
35 [ -n "$ubi" ] || \
36 ath9k_eeprom_die "no UBI volume found for $part"
37  
38 dd if=/dev/$ubi of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \
39 ath9k_eeprom_die "failed to extract from $ubi"
40 }
41  
42 ath9k_patch_firmware_mac() {
43 local mac=$1
44  
45 [ -z "$mac" ] && return
46  
47 macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=2 count=6
48 }
49  
50 board=$(board_name)
51  
52 case "$FIRMWARE" in
53 "pci_wmac0.eeprom")
54 case $board in
55 netgear,wndr4700)
56 . /lib/upgrade/nand.sh
57  
58 if [ -n "$(nand_find_volume ubi0 caldata)" ]; then
59 ath9k_ubi_eeprom_extract "caldata" 20480 4096
60 else
61 ath9k_eeprom_extract "wifi_data" 20480 4096
62 ath9k_patch_firmware_mac $(mtd_get_mac_binary wifi_data 12)
63 fi
64 ;;
65 *)
66 ath9k_eeprom_die "board $board is not supported yet"
67 ;;
68 esac
69 ;;
70  
71 "pci_wmac1.eeprom")
72 case $board in
73 netgear,wndr4700)
74 . /lib/upgrade/nand.sh
75  
76 if [ -n "$(nand_find_volume ubi0 caldata)" ]; then
77 ath9k_ubi_eeprom_extract "caldata" 4096 4096
78 else
79 ath9k_eeprom_extract "wifi_data" 4096 4096
80 ath9k_patch_firmware_mac $(mtd_get_mac_binary wifi_data 0)
81 fi
82 ;;
83 *)
84 ath9k_eeprom_die "board $board is not supported yet"
85 ;;
86 esac
87 ;;
88 esac