diff options
Diffstat (limited to 'target/linux/ipq806x/base-files')
9 files changed, 317 insertions, 11 deletions
diff --git a/target/linux/ipq806x/base-files/etc/board.d/01_leds b/target/linux/ipq806x/base-files/etc/board.d/01_leds index b32c1cc21d..17f1a28abc 100755 --- a/target/linux/ipq806x/base-files/etc/board.d/01_leds +++ b/target/linux/ipq806x/base-files/etc/board.d/01_leds @@ -11,14 +11,26 @@ board_config_update board=$(ipq806x_board_name) case "$board" in +c2600) + ucidef_set_led_usbdev "usb1" "USB 1" "usb_2:blue" "2-1" + ucidef_set_led_usbdev "usb2" "USB 2" "usb_4:blue" "4-1" + ucidef_set_led_netdev "wan" "WAN" "wan:blue" "eth0" + ucidef_set_led_netdev "lan" "LAN" "lan:blue" "br-lan" + ucidef_set_led_default "general" "general" "ledgnr:blue" "1" + ;; d7800 |\ -r7500) - ucidef_set_led_usbdev "usb1" "USB 1" "r7500:white:usb1" "1-1" - ucidef_set_led_usbdev "usb2" "USB 2" "r7500:white:usb3" "3-1" - ucidef_set_led_netdev "wan" "WAN" "r7500:white:wan" "eth0" - ucidef_set_led_ide "esata" "eSATA" "r7500:amber:esata" - ucidef_set_led_default "wps" "WPS" "r7500:white:wps" "0" - ucidef_set_led_default "rfkill" "rfkill" "r7500:white:rfkill" "0" +r7500 |\ +r7800) + ucidef_set_led_usbdev "usb1" "USB 1" "${board}:white:usb1" "1-1" + ucidef_set_led_usbdev "usb2" "USB 2" "${board}:white:usb3" "3-1" + ucidef_set_led_netdev "wan" "WAN" "${board}:white:wan" "eth0" + ucidef_set_led_ide "esata" "eSATA" "${board}:amber:esata" + ucidef_set_led_default "wps" "WPS" "${board}:white:wps" "0" + ucidef_set_led_default "rfkill" "rfkill" "${board}:white:rfkill" "0" + ;; +ea8500) + ucidef_set_led_wlan "wifi" "WIFI" "ea8500:green:wifi" "phy0radio" + ucidef_set_led_default "wps" "WPS" "ea8500:green:wps" "0" ;; *) ;; diff --git a/target/linux/ipq806x/base-files/etc/board.d/02_network b/target/linux/ipq806x/base-files/etc/board.d/02_network index 6e18297e99..16cc13cfc0 100755 --- a/target/linux/ipq806x/base-files/etc/board.d/02_network +++ b/target/linux/ipq806x/base-files/etc/board.d/02_network @@ -6,6 +6,7 @@ . /lib/functions/uci-defaults.sh . /lib/ipq806x.sh +. /lib/functions/system.sh board_config_update @@ -13,8 +14,10 @@ board=$(ipq806x_board_name) case "$board" in ap148 |\ +c2600 |\ d7800 |\ -r7500) +r7500 |\ +r7800) ucidef_add_switch "switch0" \ "1:lan" "2:lan" "3:lan" "4:lan" "6@eth1" "5:wan" "0@eth0" ;; @@ -23,6 +26,14 @@ db149) ucidef_add_switch "switch0" \ "1:lan" "2:lan" "3:lan" "4:lan" "6@eth1" "5:wan" "0@eth0" ;; +ea8500) + + hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr) + ucidef_add_switch "switch0" \ + "1:lan" "2:lan" "3:lan" "4:lan" "0t@eth0" "5:wan" "0t@eth0" + ucidef_set_interface_macaddr "lan" "$hw_mac_addr" + ucidef_set_interface_macaddr "wan" "$hw_mac_addr" + ;; *) echo "Unsupported hardware. Network interfaces not intialized" ;; diff --git a/target/linux/ipq806x/base-files/etc/diag.sh b/target/linux/ipq806x/base-files/etc/diag.sh new file mode 100755 index 0000000000..6b3622dc58 --- /dev/null +++ b/target/linux/ipq806x/base-files/etc/diag.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +. /lib/functions/leds.sh +. /lib/ipq806x.sh + +get_status_led() { + case $(ipq806x_board_name) in + c2600) + status_led="status:blue" + ;; + ea8500) + status_led="ea8500:white:power" + ;; + esac +} + +set_state() { + get_status_led + + case "$1" in + preinit) + status_led_blink_preinit + ;; + failsafe) + status_led_blink_failsafe + ;; + preinit_regular) + status_led_blink_preinit_regular + ;; + done) + status_led_on + ;; + esac +} diff --git a/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata new file mode 100644 index 0000000000..a23dd80a00 --- /dev/null +++ b/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -0,0 +1,82 @@ +#!/bin/sh + +ath10kcal_die() { + echo "ath10cal: " "$*" + exit 1 +} + +ath10kcal_from_file() { + local source=$1 + local offset=$2 + local count=$3 + + dd if=$source of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \ + ath10kcal_die "failed to extract calibration data from $source" +} + +ath10kcal_extract() { + local part=$1 + local offset=$2 + local count=$3 + local mtd + + mtd=$(find_mtd_chardev $part) + [ -n "$mtd" ] || \ + ath10kcal_die "no mtd device found for partition $part" + + dd if=$mtd of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \ + ath10kcal_die "failed to extract calibration data from $mtd" +} + +ath10kcal_patch_mac() { + local mac=$1 + + [ -z "$mac" ] && return + + macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=6 count=6 +} + +[ -e /lib/firmware/$FIRMWARE ] && exit 0 + +. /lib/ipq806x.sh +. /lib/functions.sh +. /lib/functions/system.sh + +board=$(ipq806x_board_name) + + +case "$FIRMWARE" in +"ath10k/cal-pci-0000:01:00.0.bin") + case $board in + c2600) + ath10kcal_extract "radio" 4096 12064 +# ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary default-mac 8) -1) + ;; + ea8500) + hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr) + ath10kcal_extract "art" 4096 12064 + ;; + r7800) + ath10kcal_extract "art" 4096 12064 + ;; + esac + ;; +"ath10k/cal-pci-0001:01:00.0.bin") + case $board in + c2600) + ath10kcal_extract "radio" 20480 12064 +# ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary default-mac 8) -2) + ;; + ea8500) + hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr) + ath10kcal_extract "art" 20480 12064 + ;; + r7800) + ath10kcal_extract "art" 20480 12064 + ;; + esac + ;; +*) + exit 1 + ;; +esac diff --git a/target/linux/ipq806x/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ipq806x/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac new file mode 100644 index 0000000000..1ae4352686 --- /dev/null +++ b/target/linux/ipq806x/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac @@ -0,0 +1,23 @@ +#!/bin/ash + +[ "$ACTION" == "add" ] || exit 0 + +PHYNBR=${DEVPATH##*/phy} + +[ -n $PHYNBR ] || exit 0 + +. /lib/ipq806x.sh +. /lib/functions/system.sh + +board=$(ipq806x_board_name) + +case "$board" in + c2600) + echo $(macaddr_add $(mtd_get_mac_binary default-mac 8) $(($PHYNBR - 1)) ) > /sys${DEVPATH}/macaddress + ;; + ea8500) + echo $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) $(($PHYNBR + 1)) ) > /sys${DEVPATH}/macaddress + ;; + *) + ;; +esac diff --git a/target/linux/ipq806x/base-files/etc/init.d/linksys_recovery b/target/linux/ipq806x/base-files/etc/init.d/linksys_recovery new file mode 100755 index 0000000000..b9ea004207 --- /dev/null +++ b/target/linux/ipq806x/base-files/etc/init.d/linksys_recovery @@ -0,0 +1,20 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2015 OpenWrt.org + +START=97 +boot() { +. /lib/functions.sh +. /lib/ipq806x.sh + +case $(ipq806x_board_name) in + ea8500) + # make sure auto_recovery in uboot is always on + AUTO_RECOVERY_ENA="`fw_printenv -n auto_recovery`" + if [ "$AUTO_RECOVERY_ENA" != "yes" ] ; then + fw_setenv auto_recovery yes + fi + # reset the boot counter + mtd resetbc s_env + ;; +esac +} diff --git a/target/linux/ipq806x/base-files/lib/ipq806x.sh b/target/linux/ipq806x/base-files/lib/ipq806x.sh index db227087f4..adac916f6b 100644 --- a/target/linux/ipq806x/base-files/lib/ipq806x.sh +++ b/target/linux/ipq806x/base-files/lib/ipq806x.sh @@ -17,6 +17,9 @@ ipq806x_board_detect() { *"AP148") name="ap148" ;; + *"C2600") + name="c2600" + ;; *"D7800") name="d7800" ;; @@ -26,6 +29,12 @@ ipq806x_board_detect() { *"R7500") name="r7500" ;; + *"Linksys EA8500"*) + name="ea8500" + ;; + *"R7800") + name="r7800" + ;; esac [ -z "$name" ] && name="unknown" diff --git a/target/linux/ipq806x/base-files/lib/upgrade/linksys.sh b/target/linux/ipq806x/base-files/lib/upgrade/linksys.sh new file mode 100644 index 0000000000..ca5161a61b --- /dev/null +++ b/target/linux/ipq806x/base-files/lib/upgrade/linksys.sh @@ -0,0 +1,88 @@ +# +# Copyright (C) 2014-2015 OpenWrt.org +# + +linksys_get_target_firmware() { + cur_boot_part=`/usr/sbin/fw_printenv -n boot_part` + target_firmware="" + if [ "$cur_boot_part" = "1" ] + then + # current primary boot - update alt boot + target_firmware="kernel2" + fw_setenv boot_part 2 + #In EA8500 bootcmd is always "bootipq", so don't change + #fw_setenv bootcmd "run altnandboot" + elif [ "$cur_boot_part" = "2" ] + then + # current alt boot - update primary boot + target_firmware="kernel1" + fw_setenv boot_part 1 + #In EA8500 bootcmd is always "bootipq", so don't change + #fw_setenv bootcmd "run nandboot" + fi + + # re-enable recovery so we get back if the new firmware is broken + fw_setenv auto_recovery yes + + echo "$target_firmware" +} + +linksys_get_root_magic() { + (get_image "$@" | dd skip=786432 bs=4 count=1 | hexdump -v -n 4 -e '1/1 "%02x"') 2>/dev/null +} + +platform_do_upgrade_linksys() { + local magic_long="$(get_magic_long "$1")" + + mkdir -p /var/lock + local part_label="$(linksys_get_target_firmware)" + touch /var/lock/fw_printenv.lock + + if [ ! -n "$part_label" ] + then + echo "cannot find target partition" + exit 1 + fi + + local target_mtd=$(find_mtd_part $part_label) + + [ "$magic_long" = "73797375" ] && { + CI_KERNPART="$part_label" + if [ "$part_label" = "kernel1" ] + then + CI_UBIPART="rootfs1" + else + CI_UBIPART="rootfs2" + fi + + nand_upgrade_tar "$1" + } + [ "$magic_long" = "27051956" ] && { + # check firmwares' rootfs types + local target_mtd=$(find_mtd_part $part_label) + local oldroot="$(linksys_get_root_magic $target_mtd)" + local newroot="$(linksys_get_root_magic "$1")" + + if [ "$newroot" = "55424923" -a "$oldroot" = "55424923" ] + # we're upgrading from a firmware with UBI to one with UBI + then + # erase everything to be safe + mtd erase $part_label + get_image "$1" | mtd -n write - $part_label + else + get_image "$1" | mtd write - $part_label + fi + } +} + +linksys_preupgrade() { + export RAMFS_COPY_BIN="${RAMFS_COPY_BIN} /usr/sbin/fw_printenv /usr/sbin/fw_setenv" + export RAMFS_COPY_BIN="${RAMFS_COPY_BIN} /bin/mkdir /bin/touch" + export RAMFS_COPY_DATA="${RAMFS_COPY_DATA} /etc/fw_env.config /var/lock/fw_printenv.lock" + + [ -f /tmp/sysupgrade.tgz ] && { + cp /tmp/sysupgrade.tgz /tmp/syscfg/sysupgrade.tgz + } +} + +append sysupgrade_pre_upgrade linksys_preupgrade diff --git a/target/linux/ipq806x/base-files/lib/upgrade/platform.sh b/target/linux/ipq806x/base-files/lib/upgrade/platform.sh index 542b5cecde..cfd7cd7ed6 100644 --- a/target/linux/ipq806x/base-files/lib/upgrade/platform.sh +++ b/target/linux/ipq806x/base-files/lib/upgrade/platform.sh @@ -8,10 +8,20 @@ platform_check_image() { case "$board" in ap148 |\ d7800 |\ - r7500) + ea8500 |\ + r7500 |\ + r7800) nand_do_platform_check $board $1 return $?; ;; + c2600) + local magic_long="$(get_magic_long "$1")" + [ "$magic_long" != "27051956" ] && { + echo "Invalid image, bad magic: $magic_long" + return 1 + } + return 0; + ;; *) return 1; esac @@ -23,10 +33,27 @@ platform_pre_upgrade() { case "$board" in ap148 |\ d7800 |\ - r7500) + r7500 |\ + r7800) nand_do_upgrade "$1" ;; + ea8500) + linksys_preupgrade "$1" + ;; esac } -# use default for platform_do_upgrade() +platform_do_upgrade() { + local board=$(ipq806x_board_name) + + case "$board" in + c2600) + PART_NAME="os-image:rootfs" + MTD_CONFIG_ARGS="-s 0x200000" + default_do_upgrade "$ARGV" + ;; + ea8500) + platform_do_upgrade_linksys "$ARGV" + ;; + esac +} |