You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openwrt/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom

195 lines
4.1 KiB
Plaintext

#!/bin/sh
[ -e /lib/firmware/$FIRMWARE ] && exit 0
. /lib/functions.sh
. /lib/functions/system.sh
ath9k_eeprom_die() {
echo "ath9k eeprom: " "$*"
exit 1
}
ath9k_eeprom_extract() {
local part=$1
local offset=$2
local count=$3
local mtd
mtd=$(find_mtd_chardev $part)
[ -n "$mtd" ] || \
ath9k_eeprom_die "no mtd device found for partition $part"
dd if=$mtd of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \
ath9k_eeprom_die "failed to extract from $mtd"
}
ath9k_eeprom_extract_reverse() {
local part=$1
local offset=$2
local count=$3
local mtd
local reversed
local caldata
mtd=$(find_mtd_chardev "$part")
reversed=$(hexdump -v -s $offset -n $count -e '/1 "%02x "' $mtd)
for byte in $reversed; do
caldata="\x${byte}${caldata}"
done
printf "%b" "$caldata" > /lib/firmware/$FIRMWARE
}
xor() {
local val
local ret="0x$1"
local retlen=${#1}
shift
while [ -n "$1" ]; do
val="0x$1"
ret=$((ret ^ val))
shift
done
printf "%0${retlen}x" "$ret"
}
ath9k_patch_fw_mac() {
local mac=$1
local mac_offset=$2
local chksum_offset=$3
local xor_mac
local xor_fw_mac
local xor_fw_chksum
[ -z "$mac" -o -z "$mac_offset" ] && return
[ -n "$chksum_offset" ] && {
xor_mac=${mac//:/}
xor_mac="${xor_mac:0:4} ${xor_mac:4:4} ${xor_mac:8:4}"
xor_fw_mac=$(hexdump -v -n 6 -s $mac_offset -e '/1 "%02x"' /lib/firmware/$FIRMWARE)
xor_fw_mac="${xor_fw_mac:0:4} ${xor_fw_mac:4:4} ${xor_fw_mac:8:4}"
xor_fw_chksum=$(hexdump -v -n 2 -s $chksum_offset -e '/1 "%02x"' /lib/firmware/$FIRMWARE)
xor_fw_chksum=$(xor $xor_fw_chksum $xor_fw_mac $xor_mac)
printf "%b" "\x${xor_fw_chksum:0:2}\x${xor_fw_chksum:2:2}" | \
dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$chksum_offset count=2
}
macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$mac_offset count=6
}
ath9k_patch_fw_mac_crc() {
local mac=$1
local mac_offset=$2
local chksum_offset=$((mac_offset - 10))
ath9k_patch_fw_mac "${mac}" "${mac_offset}" "${chksum_offset}"
}
board=$(board_name)
case "$FIRMWARE" in
"ath9k-eeprom-ahb-18100000.wmac.bin")
case $board in
ath79: add support for Fritz!Box 4020 This commit adds support for the AVM Fritz!Box 4020 WiFi-router. SoC: Qualcomm Atheros QCA9561 (Dragonfly) 750MHz RAM: Winbond W971GG6KB-25 FLASH: Macronix MX25L12835F WiFi: QCA9561 b/g/n 3x3 450Mbit/s USB: 1x USB 2.0 IN: WPS button, WiFi button OUT: Power LED green, Internet LED green, WLAN LED green, LAN LED green, INFO LED green, INFO LED red UART: Header Next to Black metal shield Pinout is 3.3V - RX - TX - GND (Square Pad is 3.3V) The Serial setting is 115200-8-N-1. Tested and working: - Ethernet (LAN + WAN) - WiFi (correct MAC) - Installation via EVA bootloader - OpenWRT sysupgrade - Buttons - LEDs The USB port doesn't work. Both Root Hubs are detected as having 0 Ports: [ 3.670807] kmodloader: loading kernel modules from /etc/modules-boot.d/* [ 3.723267] usbcore: registered new interface driver usbfs [ 3.729058] usbcore: registered new interface driver hub [ 3.734616] usbcore: registered new device driver usb [ 3.744181] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver [ 3.758357] SCSI subsystem initialized [ 3.766026] ehci-platform: EHCI generic platform driver [ 3.771548] ehci-platform ehci-platform.0: EHCI Host Controller [ 3.777708] ehci-platform ehci-platform.0: new USB bus registered, assigned bus number 1 [ 3.788169] ehci-platform ehci-platform.0: irq 48, io mem 0x1b000000 [ 3.816647] ehci-platform ehci-platform.0: USB 2.0 started, EHCI 0.00 [ 3.824001] hub 1-0:1.0: USB hub found [ 3.828219] hub 1-0:1.0: config failed, hub doesn't have any ports! (err -19) [ 3.835825] ehci-platform ehci-platform.1: EHCI Host Controller [ 3.842009] ehci-platform ehci-platform.1: new USB bus registered, assigned bus number 2 [ 3.852481] ehci-platform ehci-platform.1: irq 49, io mem 0x1b400000 [ 3.886631] ehci-platform ehci-platform.1: USB 2.0 started, EHCI 0.00 [ 3.894011] hub 2-0:1.0: USB hub found [ 3.898190] hub 2-0:1.0: config failed, hub doesn't have any ports! (err -19) [ 3.908928] usbcore: registered new interface driver usb-storage [ 3.915634] kmodloader: done loading kernel modules from /etc/modules-boot.d/* A few words about the shift-register: AVM used a trick to control the shift-register for the LEDs with only 2 pins, SERCLK and MOSI. Q7S, normally used for daisy-chaining multiple shift-registers, pulls the latch, moving the shift register-state to the storage register. It also pulls down MR (normally pulled up) to clear the storage register, so the latch gets released and will not be pulled by the remaining bits in the shift-register. Shift register is all-zero after this. For that we need to make sure output 7 is set to high on driver probe. We accomplish this by using gpio-hogging. Installation via EVA: In the first seconds after Power is connected, the bootloader will listen for FTP connections on 169.254.157.1 (Might also be 192.168.178.1). Firmware can be uploaded like following: ftp> quote USER adam2 ftp> quote PASS adam2 ftp> binary ftp> debug ftp> passive ftp> quote MEDIA FLSH ftp> put openwrt-sysupgrade.bin mtd1 Note that this procedure might take up to two minutes. After transfer is complete you need to powercycle the device to boot OpenWRT. Signed-off-by: David Bauer <mail@david-bauer.net>
6 years ago
avm,fritz4020)
ath9k_eeprom_extract_reverse "urlader" 5441 1088
;;
iodata,wn-ac1167dgr|\
iodata,wn-ac1600dgr2)
ath9k_eeprom_extract "art" 4096 1088
ath9k_patch_fw_mac $(mtd_get_mac_ascii u-boot-env ethaddr) 2
;;
*)
ath9k_eeprom_die "board $board is not supported yet"
;;
esac
;;
"ath9k-eeprom-pci-0000:00:00.0.bin")
case $board in
avm,fritz300e)
ath9k_eeprom_extract_reverse "urloader" 5441 1088
;;
buffalo,whr-g301n|\
tplink,tl-wr841-v5|\
tplink,tl-wr941-v4)
ath9k_eeprom_extract "art" 4096 3768
;;
buffalo,wzr-hp-g450h)
ath9k_eeprom_extract "ART" 4096 1088
;;
ocedo,raccoon|\
tplink,tl-wdr3600|\
tplink,tl-wdr4300|\
tplink,tl-wdr4900-v2)
ath9k_eeprom_extract "art" 20480 1088
;;
netgear,wnr612-v2|\
on,n150r|\
pcs,cap324|\
tplink,tl-mr3220-v1|\
tplink,tl-mr3420-v1|\
tplink,tl-wr2543-v1|\
tplink,tl-wr740n-v1|\
tplink,tl-wr740n-v3|\
tplink,tl-wr741-v1|\
tplink,tl-wr743nd-v1|\
tplink,tl-wr841-v7|\
ubnt,bullet-m|\
ubnt,nano-m|\
ubnt,rocket-m)
ath9k_eeprom_extract "art" 4096 4096
;;
ubnt,unifi)
ath9k_eeprom_extract "art" 4096 2048
;;
wd,mynet-wifi-rangeextender)
ath9k_eeprom_extract "art" 4096 4096
ath9k_patch_fw_mac_crc $(nvram get wl0_hwaddr) "$mac" 2
;;
*)
ath9k_eeprom_die "board $board is not supported yet"
;;
esac
;;
"ath9k-eeprom-pci-0000:00:11.0.bin")
case $board in
ath79: add support for Buffalo WZR-HP-AG300H Buffalo WZR-HP-AG300H is a dual band router based on Qualcom Atheros AR7161 rev 2 Specification: - 680 MHz CPU (Qualcomm Atheros AR7161) - 128 MiB RAM (2x Samsung K4H511638G-LCCC) - 32 MiB Flash (2x Winbond 25Q128BVFG) - WiFi 5 GHz a/n (Atheros AR9220) - WiFi 2.4 GHz b/g/n (Atheros AR9223) - 1000Base-T WAN (Atheros AR7161) - 4x 1000Base-T Switch (Atheros AR8316) - 1x USB 2.0 - 3 Buttons (AOSS/WPS, Reset, USB Eject) - 2 Slide switches (Router (on/off/auto), Movie Engine (on/off)) - 9 LEDs (Power green, WLAN 2GHz green, WLAN 2GHz amber, WLAN 5GHz green, WLAN 5GHz LED amber, Router green, Diag red, Movie Engine blue, USB green) It is already supported by the ar71xx target. For more information on the device visit the wiki: <https://openwrt.org/toh/buffalo/wzr-hp-ag300h> Serial console: - The UART Header is next to Movie Engine Switch. - Pinout is RX - TX - GND - 3.3V (Square Pad is 3.3V) - The Serial setting is 115200-8-N-1. Installation of OpenWRT from vendor firmware: - Connect to the Web-interface at http://192.168.11.1 - Go to “Administration” → “Firmware Upgrade” - Upload the OpenWrt factory image Tested: - Ethernet (LAN, WAN) - WiFi - Installation - via TFTP rescue - via factory image - on firmware v1.77 (28-05-2012) - on pro firmware v24SP2 r30356 (26-03-2018) - via sysupgrade from ar71xx (wlan devices don't work because of new names) - via sysupgrade from itself - Buttons - LEDS - USB (Power control and device recognition) Signed-off-by: Bernhard Frauendienst <openwrt@nospam.obeliks.de>
6 years ago
buffalo,wzr-hp-ag300h|\
netgear,wndr3700|\
netgear,wndr3700v2|\
netgear,wndr3800)
ath9k_eeprom_extract "art" 4096 3768
;;
ath79: add support for Buffalo WZR-HP-AG300H Buffalo WZR-HP-AG300H is a dual band router based on Qualcom Atheros AR7161 rev 2 Specification: - 680 MHz CPU (Qualcomm Atheros AR7161) - 128 MiB RAM (2x Samsung K4H511638G-LCCC) - 32 MiB Flash (2x Winbond 25Q128BVFG) - WiFi 5 GHz a/n (Atheros AR9220) - WiFi 2.4 GHz b/g/n (Atheros AR9223) - 1000Base-T WAN (Atheros AR7161) - 4x 1000Base-T Switch (Atheros AR8316) - 1x USB 2.0 - 3 Buttons (AOSS/WPS, Reset, USB Eject) - 2 Slide switches (Router (on/off/auto), Movie Engine (on/off)) - 9 LEDs (Power green, WLAN 2GHz green, WLAN 2GHz amber, WLAN 5GHz green, WLAN 5GHz LED amber, Router green, Diag red, Movie Engine blue, USB green) It is already supported by the ar71xx target. For more information on the device visit the wiki: <https://openwrt.org/toh/buffalo/wzr-hp-ag300h> Serial console: - The UART Header is next to Movie Engine Switch. - Pinout is RX - TX - GND - 3.3V (Square Pad is 3.3V) - The Serial setting is 115200-8-N-1. Installation of OpenWRT from vendor firmware: - Connect to the Web-interface at http://192.168.11.1 - Go to “Administration” → “Firmware Upgrade” - Upload the OpenWrt factory image Tested: - Ethernet (LAN, WAN) - WiFi - Installation - via TFTP rescue - via factory image - on firmware v1.77 (28-05-2012) - on pro firmware v24SP2 r30356 (26-03-2018) - via sysupgrade from ar71xx (wlan devices don't work because of new names) - via sysupgrade from itself - Buttons - LEDS - USB (Power control and device recognition) Signed-off-by: Bernhard Frauendienst <openwrt@nospam.obeliks.de>
6 years ago
dlink,dir-825-b1)
ath9k_eeprom_extract "caldata" 4096 3768
ath9k_patch_fw_mac_crc $(mtd_get_mac_text "caldata" 65440) 524
;;
*)
ath9k_eeprom_die "board $board is not supported yet"
;;
esac
;;
"ath9k-eeprom-pci-0000:00:12.0.bin")
case $board in
ath79: add support for Buffalo WZR-HP-AG300H Buffalo WZR-HP-AG300H is a dual band router based on Qualcom Atheros AR7161 rev 2 Specification: - 680 MHz CPU (Qualcomm Atheros AR7161) - 128 MiB RAM (2x Samsung K4H511638G-LCCC) - 32 MiB Flash (2x Winbond 25Q128BVFG) - WiFi 5 GHz a/n (Atheros AR9220) - WiFi 2.4 GHz b/g/n (Atheros AR9223) - 1000Base-T WAN (Atheros AR7161) - 4x 1000Base-T Switch (Atheros AR8316) - 1x USB 2.0 - 3 Buttons (AOSS/WPS, Reset, USB Eject) - 2 Slide switches (Router (on/off/auto), Movie Engine (on/off)) - 9 LEDs (Power green, WLAN 2GHz green, WLAN 2GHz amber, WLAN 5GHz green, WLAN 5GHz LED amber, Router green, Diag red, Movie Engine blue, USB green) It is already supported by the ar71xx target. For more information on the device visit the wiki: <https://openwrt.org/toh/buffalo/wzr-hp-ag300h> Serial console: - The UART Header is next to Movie Engine Switch. - Pinout is RX - TX - GND - 3.3V (Square Pad is 3.3V) - The Serial setting is 115200-8-N-1. Installation of OpenWRT from vendor firmware: - Connect to the Web-interface at http://192.168.11.1 - Go to “Administration” → “Firmware Upgrade” - Upload the OpenWrt factory image Tested: - Ethernet (LAN, WAN) - WiFi - Installation - via TFTP rescue - via factory image - on firmware v1.77 (28-05-2012) - on pro firmware v24SP2 r30356 (26-03-2018) - via sysupgrade from ar71xx (wlan devices don't work because of new names) - via sysupgrade from itself - Buttons - LEDS - USB (Power control and device recognition) Signed-off-by: Bernhard Frauendienst <openwrt@nospam.obeliks.de>
6 years ago
buffalo,wzr-hp-ag300h|\
netgear,wndr3700|\
netgear,wndr3700v2|\
netgear,wndr3800)
ath9k_eeprom_extract "art" 20480 3768
;;
ath79: add support for Buffalo WZR-HP-AG300H Buffalo WZR-HP-AG300H is a dual band router based on Qualcom Atheros AR7161 rev 2 Specification: - 680 MHz CPU (Qualcomm Atheros AR7161) - 128 MiB RAM (2x Samsung K4H511638G-LCCC) - 32 MiB Flash (2x Winbond 25Q128BVFG) - WiFi 5 GHz a/n (Atheros AR9220) - WiFi 2.4 GHz b/g/n (Atheros AR9223) - 1000Base-T WAN (Atheros AR7161) - 4x 1000Base-T Switch (Atheros AR8316) - 1x USB 2.0 - 3 Buttons (AOSS/WPS, Reset, USB Eject) - 2 Slide switches (Router (on/off/auto), Movie Engine (on/off)) - 9 LEDs (Power green, WLAN 2GHz green, WLAN 2GHz amber, WLAN 5GHz green, WLAN 5GHz LED amber, Router green, Diag red, Movie Engine blue, USB green) It is already supported by the ar71xx target. For more information on the device visit the wiki: <https://openwrt.org/toh/buffalo/wzr-hp-ag300h> Serial console: - The UART Header is next to Movie Engine Switch. - Pinout is RX - TX - GND - 3.3V (Square Pad is 3.3V) - The Serial setting is 115200-8-N-1. Installation of OpenWRT from vendor firmware: - Connect to the Web-interface at http://192.168.11.1 - Go to “Administration” → “Firmware Upgrade” - Upload the OpenWrt factory image Tested: - Ethernet (LAN, WAN) - WiFi - Installation - via TFTP rescue - via factory image - on firmware v1.77 (28-05-2012) - on pro firmware v24SP2 r30356 (26-03-2018) - via sysupgrade from ar71xx (wlan devices don't work because of new names) - via sysupgrade from itself - Buttons - LEDS - USB (Power control and device recognition) Signed-off-by: Bernhard Frauendienst <openwrt@nospam.obeliks.de>
6 years ago
dlink,dir-825-b1)
ath9k_eeprom_extract "caldata" 20480 3768
ath9k_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_text "caldata" 65460) 1) 524
;;
*)
ath9k_eeprom_die "board $board is not supported yet"
;;
esac
;;
esac