未验证 提交 2289184a 编写于 作者: A AmadeusGhost 提交者: GitHub

files: sync from openwrt v19.07 (#2690)

上级 9b593a88
......@@ -105,6 +105,13 @@ menuconfig DEVEL
help
If enabled, log files will be written to the ./log directory.
config BUILD_LOG_DIR
string "Log folder" if DEVEL
default ""
help
Store build logs in this directory.
If not set, uses './logs'
config SRC_TREE_OVERRIDE
bool "Enable package source tree override" if DEVEL
help
......
......@@ -14,11 +14,12 @@ menu "Target Images"
choice
prompt "Compression"
default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_ar71xx
default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_ramips
default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_apm821xx
default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_mpc85xx
default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_ar71xx
default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_ipq40xx
default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_lantiq
default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_mpc85xx
default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_ramips
default TARGET_INITRAMFS_COMPRESSION_NONE
depends on TARGET_ROOTFS_INITRAMFS
help
......@@ -194,7 +195,7 @@ menu "Target Images"
depends on TARGET_ROOTFS_EXT4FS || TARGET_ROOTFS_ISO || TARGET_ROOTFS_JFFS2 || TARGET_ROOTFS_SQUASHFS
select PACKAGE_grub2
default y
config EFI_IMAGES
bool "Build EFI GRUB images (Linux x86 or x86_64 host only)"
depends on TARGET_x86
......@@ -254,6 +255,7 @@ menu "Target Images"
select GRUB_IMAGES
select TARGET_IMAGES_PAD
select PACKAGE_kmod-e1000
default n
config VMDK_IMAGES
bool "Build VMware image files (VMDK)"
......@@ -262,22 +264,22 @@ menu "Target Images"
select TARGET_IMAGES_PAD
select PACKAGE_kmod-e1000
default y
config VHD_IMAGES
bool "Build Hyper-V image files (VHD)"
depends on TARGET_x86 || TARGET_x86_64
default n
depends on GRUB_IMAGES || EFI_IMAGES
select TARGET_IMAGES_PAD
select PACKAGE_kmod-tulip
select PACKAGE_kmod-tulip
default n
config QCOW2_IMAGES
bool "Build PVE/KVM image files (QCOW2)"
depends on TARGET_x86 || TARGET_x86_64
default n
depends on GRUB_IMAGES || EFI_IMAGES
select TARGET_IMAGES_PAD
select PACKAGE_kmod-e1000
select PACKAGE_kmod-e1000
default n
config TARGET_IMAGES_PAD
bool "Pad images to filesystem size (for JFFS2)"
......@@ -286,7 +288,7 @@ menu "Target Images"
config TARGET_IMAGES_GZIP
bool "GZip images"
depends on TARGET_IMAGES_PAD || TARGET_ROOTFS_EXT4FS || TARGET_x86
depends on TARGET_ROOTFS_EXT4FS || TARGET_x86 || TARGET_armvirt || TARGET_malta
default n
comment "Image Options"
......
......@@ -46,7 +46,7 @@ config KERNEL_DEBUG_FS
config KERNEL_MIPS_FPU_EMULATOR
bool "Compile the kernel with MIPS FPU Emulator"
default y
default y if TARGET_pistachio
depends on (mips || mipsel || mips64 || mips64el)
config KERNEL_ARM_PMU
......@@ -596,7 +596,7 @@ endif
config KERNEL_NAMESPACES
bool "Enable kernel namespaces"
default n
default y if !SMALL_FLASH
if KERNEL_NAMESPACES
......@@ -665,13 +665,13 @@ config KERNEL_POSIX_MQUEUE
config KERNEL_SECCOMP_FILTER
bool
default n
default y if !SMALL_FLASH
config KERNEL_SECCOMP
bool "Enable seccomp support"
depends on !(TARGET_uml)
select KERNEL_SECCOMP_FILTER
default n
default y if !SMALL_FLASH
help
Build kernel with support for seccomp.
......
......@@ -103,6 +103,7 @@ define Host/Configure/Default
-DCMAKE_INSTALL_PREFIX=$(HOST_BUILD_PREFIX) \
-DCMAKE_PREFIX_PATH=$(HOST_BUILD_PREFIX) \
-DCMAKE_SKIP_RPATH=TRUE \
-DCMAKE_INSTALL_LIBDIR=lib \
$(CMAKE_HOST_OPTIONS) \
$(HOST_CMAKE_SOURCE_DIR) \
)
......
......@@ -48,4 +48,3 @@ debug_eval:=
warn_eval = $(4)
endif
......@@ -288,6 +288,7 @@ endef
define Download/default
FILE:=$(PKG_SOURCE)
URL:=$(PKG_SOURCE_URL)
URL_FILE:=$(PKG_SOURCE_URL_FILE)
SUBDIR:=$(PKG_SOURCE_SUBDIR)
PROTO:=$(PKG_SOURCE_PROTO)
$(if $(PKG_SOURCE_MIRROR),MIRROR:=$(filter 1,$(PKG_MIRROR)))
......
......@@ -61,4 +61,3 @@ ifdef CONFIG_PKG_RELRO_FULL
TARGET_LDFLAGS += -znow -zrelro
endif
endif
......@@ -3,6 +3,10 @@
IMAGE_KERNEL = $(word 1,$^)
IMAGE_ROOTFS = $(word 2,$^)
define rootfs_align
$(patsubst %-256k,0x40000,$(patsubst %-128k,0x20000,$(patsubst %-64k,0x10000,$(patsubst squashfs%,0x4,$(patsubst root.%,%,$(1))))))
endef
define Build/uImage
mkimage -A $(LINUX_KARCH) \
-O linux -T kernel \
......@@ -271,6 +275,13 @@ define Build/check-size
}
endef
define Build/check-kernel-size
@[ $$(($(subst k,* 1024,$(subst m, * 1024k,$(1))))) -ge "$$(stat -c%s $(IMAGE_KERNEL))" ] || { \
echo "WARNING: Kernel for $@ is too big > $(1)" >&2; \
rm -f $@; \
}
endef
define Build/combined-image
-sh $(TOPDIR)/scripts/combined-image.sh \
"$(IMAGE_KERNEL)" \
......@@ -308,7 +319,7 @@ endef
define Build/qsdk-ipq-factory-nor
$(TOPDIR)/scripts/mkits-qsdk-ipq-image.sh \
$@.its hlos $(IMAGE_KERNEL) rootfs $(IMAGE_ROOTFS)
$@.its kernel $(IMAGE_KERNEL) rootfs $(IMAGE_ROOTFS)
PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $@.its $@.new
@mv $@.new $@
endef
......@@ -335,6 +346,24 @@ define Build/tplink-v1-header
@mv $@.new $@
endef
# combine kernel and rootfs into one image
# mktplinkfw <type> <optional extra arguments to mktplinkfw binary>
# <type> is "sysupgrade" or "factory"
#
# -a align the rootfs start on an <align> bytes boundary
# -j add jffs2 end-of-filesystem markers
# -s strip padding from end of the image
# -X reserve <size> bytes in the firmware image (hexval prefixed with 0x)
define Build/tplink-v1-image
-$(STAGING_DIR_HOST)/bin/mktplinkfw \
-H $(TPLINK_HWID) -W $(TPLINK_HWREV) -F $(TPLINK_FLASHLAYOUT) \
-N "$(VERSION_DIST)" -V $(REVISION) -m $(TPLINK_HEADER_VERSION) \
-k $(IMAGE_KERNEL) -r $(IMAGE_ROOTFS) -o $@.new -j -X 0x40000 \
-a $(call rootfs_align,$(FILESYSTEM)) \
$(wordlist 2,$(words $(1)),$(1)) \
$(if $(findstring sysupgrade,$(word 1,$(1))),-s) && mv $@.new $@ || rm -f $@
endef
define Build/tplink-v2-header
$(STAGING_DIR_HOST)/bin/mktplinkfw2 \
-c -H $(TPLINK_HWID) -W $(TPLINK_HWREV) -L $(KERNEL_LOADADDR) \
......
......@@ -420,6 +420,7 @@ define Device/Init
DEVICE_DTS :=
DEVICE_DTS_CONFIG :=
DEVICE_DTS_DIR :=
SOC :=
BOARD_NAME :=
UIMAGE_NAME :=
......@@ -437,7 +438,7 @@ DEFAULT_DEVICE_VARS := \
DEVICE_NAME KERNEL KERNEL_INITRAMFS KERNEL_INITRAMFS_IMAGE KERNEL_SIZE \
CMDLINE UBOOTENV_IN_UBI KERNEL_IN_UBI BLOCKSIZE PAGESIZE SUBPAGESIZE \
VID_HDR_OFFSET UBINIZE_OPTS UBINIZE_PARTS MKUBIFS_OPTS DEVICE_DTS \
DEVICE_DTS_CONFIG DEVICE_DTS_DIR BOARD_NAME UIMAGE_NAME SUPPORTED_DEVICES \
DEVICE_DTS_CONFIG DEVICE_DTS_DIR SOC BOARD_NAME UIMAGE_NAME SUPPORTED_DEVICES \
IMAGE_METADATA KERNEL_ENTRY KERNEL_LOADADDR UBOOT_PATH DEVICE_VENDOR \
DEVICE_MODEL DEVICE_VARIANT \
DEVICE_ALT0_VENDOR DEVICE_ALT0_MODEL DEVICE_ALT0_VARIANT \
......
......@@ -160,5 +160,3 @@ define Kernel/Clean/Default
rm -f $(LINUX_KERNEL)
$(_SINGLE)$(MAKE) -C $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) clean
endef
......@@ -104,6 +104,7 @@ endif
KERNEL_MAKE = $(MAKE) $(KERNEL_MAKEOPTS)
KERNEL_MAKE_FLAGS = \
KCFLAGS="$(call iremap,$(BUILD_DIR),$(notdir $(BUILD_DIR)))" \
HOSTCFLAGS="$(HOST_CFLAGS) -Wall -Wmissing-prototypes -Wstrict-prototypes" \
CROSS_COMPILE="$(KERNEL_CROSS)" \
ARCH="$(LINUX_KARCH)" \
......@@ -113,6 +114,7 @@ KERNEL_MAKE_FLAGS = \
KBUILD_BUILD_TIMESTAMP="$(KBUILD_BUILD_TIMESTAMP)" \
KBUILD_BUILD_VERSION="0" \
HOST_LOADLIBES="-L$(STAGING_DIR_HOST)/lib" \
KBUILD_HOSTLDLIBS="-L$(STAGING_DIR_HOST)/lib" \
CONFIG_SHELL="$(BASH)" \
$(if $(findstring c,$(OPENWRT_VERBOSE)),V=1,V='') \
$(if $(PKG_BUILD_ID),LDFLAGS_MODULE=--build-id=0x$(PKG_BUILD_ID)) \
......@@ -129,6 +131,11 @@ ifdef CONFIG_USE_SPARSE
KERNEL_MAKEOPTS += C=1 CHECK=$(STAGING_DIR_HOST)/bin/sparse
endif
ifneq ($(HOST_OS),Linux)
KERNEL_MAKEOPTS += CONFIG_STACK_VALIDATION=
export SKIP_STACK_VALIDATION:=1
endif
PKG_EXTMOD_SUBDIRS ?= .
define populate_module_symvers
......@@ -294,4 +301,3 @@ kernel_patchver_ge=$(call kernel_version_cmp,-ge,$(KERNEL_PATCHVER),$(1))
kernel_patchver_eq=$(call kernel_version_cmp,-eq,$(KERNEL_PATCHVER),$(1))
kernel_patchver_le=$(call kernel_version_cmp,-le,$(KERNEL_PATCHVER),$(1))
kernel_patchver_lt=$(call kernel_version_cmp,-lt,$(KERNEL_PATCHVER),$(1))
......@@ -12,6 +12,7 @@ HOST_BUILD_PREFIX:=$(TOOLCHAIN_DIR)
BUILD_DIR_HOST:=$(BUILD_DIR_TOOLCHAIN)
include $(INCLUDE_DIR)/host-build.mk
include $(INCLUDE_DIR)/hardening.mk
HOST_STAMP_PREPARED=$(HOST_BUILD_DIR)/.prepared
......
......@@ -3,7 +3,7 @@ PKG_NAME ?= u-boot
ifndef PKG_SOURCE_PROTO
PKG_SOURCE = $(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL = \
http://sources.lede-project.org \
https://sources.openwrt.org \
ftp://ftp.denx.de/pub/u-boot
endif
......
......@@ -42,16 +42,16 @@ VERSION_MANUFACTURER:=$(call qstrip,$(CONFIG_VERSION_MANUFACTURER))
VERSION_MANUFACTURER:=$(if $(VERSION_MANUFACTURER),$(VERSION_MANUFACTURER),OpenWrt)
VERSION_MANUFACTURER_URL:=$(call qstrip,$(CONFIG_VERSION_MANUFACTURER_URL))
VERSION_MANUFACTURER_URL:=$(if $(VERSION_MANUFACTURER_URL),$(VERSION_MANUFACTURER_URL),http://openwrt.org/)
VERSION_MANUFACTURER_URL:=$(if $(VERSION_MANUFACTURER_URL),$(VERSION_MANUFACTURER_URL),https://openwrt.org/)
VERSION_BUG_URL:=$(call qstrip,$(CONFIG_VERSION_BUG_URL))
VERSION_BUG_URL:=$(if $(VERSION_BUG_URL),$(VERSION_BUG_URL),http://bugs.openwrt.org/)
VERSION_BUG_URL:=$(if $(VERSION_BUG_URL),$(VERSION_BUG_URL),https://bugs.openwrt.org/)
VERSION_HOME_URL:=$(call qstrip,$(CONFIG_VERSION_HOME_URL))
VERSION_HOME_URL:=$(if $(VERSION_HOME_URL),$(VERSION_HOME_URL),http://openwrt.org/)
VERSION_HOME_URL:=$(if $(VERSION_HOME_URL),$(VERSION_HOME_URL),https://openwrt.org/)
VERSION_SUPPORT_URL:=$(call qstrip,$(CONFIG_VERSION_SUPPORT_URL))
VERSION_SUPPORT_URL:=$(if $(VERSION_SUPPORT_URL),$(VERSION_SUPPORT_URL),http://forum.lede-project.org/)
VERSION_SUPPORT_URL:=$(if $(VERSION_SUPPORT_URL),$(VERSION_SUPPORT_URL),https://forum.openwrt.org/)
VERSION_PRODUCT:=$(call qstrip,$(CONFIG_VERSION_PRODUCT))
VERSION_PRODUCT:=$(if $(VERSION_PRODUCT),$(VERSION_PRODUCT),Generic)
......@@ -108,4 +108,3 @@ VERSION_SED_SCRIPT:=$(SED) 's,%U,$(call sed_escape,$(VERSION_REPO)),g' \
-e 's,%s,$(call sed_escape,$(VERSION_SUPPORT_URL)),g' \
-e 's,%P,$(call sed_escape,$(VERSION_PRODUCT)),g' \
-e 's,%h,$(call sed_escape,$(VERSION_HWREV)),g'
......@@ -85,12 +85,16 @@ generate_network() {
set network.$1.proto='none'
EOF
[ -n "$macaddr" ] && uci -q batch <<-EOF
delete network.$1_dev
set network.$1_dev='device'
set network.$1_dev.name='$ifname'
set network.$1_dev.macaddr='$macaddr'
EOF
if [ -n "$macaddr" ]; then
for name in $ifname; do
uci -q batch <<-EOF
delete network.$1_${name/./_}_dev
set network.$1_${name/./_}_dev='device'
set network.$1_${name/./_}_dev.name='$name'
set network.$1_${name/./_}_dev.macaddr='$macaddr'
EOF
done
fi
case "$protocol" in
static)
......@@ -213,7 +217,8 @@ generate_switch() {
json_select switch
json_select "$key"
json_get_vars enable reset blinkrate cpu_port
json_get_vars enable reset blinkrate cpu_port \
ar8xxx_mib_type ar8xxx_mib_poll_interval
uci -q batch <<-EOF
add network switch
......@@ -221,6 +226,8 @@ generate_switch() {
set network.@switch[-1].reset='$reset'
set network.@switch[-1].enable_vlan='$enable'
set network.@switch[-1].blinkrate='$blinkrate'
set network.@switch[-1].ar8xxx_mib_type='$ar8xxx_mib_type'
set network.@switch[-1].ar8xxx_mib_poll_interval='$ar8xxx_mib_poll_interval'
EOF
generate_switch_vlans_ports "$1"
......@@ -244,10 +251,10 @@ generate_static_system() {
set system.ntp='timeserver'
set system.ntp.enabled='1'
set system.ntp.enable_server='0'
add_list system.ntp.server='0.openwrt.pool.ntp.org'
add_list system.ntp.server='1.openwrt.pool.ntp.org'
add_list system.ntp.server='2.openwrt.pool.ntp.org'
add_list system.ntp.server='3.openwrt.pool.ntp.org'
add_list system.ntp.server='ntp1.aliyun.com'
add_list system.ntp.server='time1.cloud.tencent.com'
add_list system.ntp.server='time.ustc.edu.cn'
add_list system.ntp.server='pool.ntp.org'
EOF
if json_is_a system object; then
......
root:x:0:
daemon:x:1:
adm:x:4:
tty:x:5:
mail:x:8:
dialout:x:20:
audio:x:29:
www-data:x:33:
ftp:x:55:
......
......@@ -2,7 +2,7 @@
# Copyright (C) 2006-2011 OpenWrt.org
START=10
STOP=98
STOP=90
uci_apply_defaults() {
. /lib/functions/system.sh
......@@ -31,8 +31,9 @@ boot() {
chmod 0700 /tmp/.uci
touch /var/log/wtmp
touch /var/log/lastlog
touch /tmp/resolv.conf.auto
ln -sf /tmp/resolv.conf.auto /tmp/resolv.conf
mkdir -p /tmp/resolv.conf.d
touch /tmp/resolv.conf.d/resolv.conf.auto
ln -sf /tmp/resolv.conf.d/resolv.conf.auto /tmp/resolv.conf
grep -q debugfs /proc/filesystems && /bin/mount -o noatime -t debugfs debugfs /sys/kernel/debug
[ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe
......
#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org
STOP=99
STOP=90
restart() {
:
}
stop() {
sync
/bin/umount -a -d -r
......
#!/bin/sh
[ "${ACTION}" = "released" ] || exit 0
if [ "$SEEN" -ge 5 ]
then
echo "REBOOT" > /dev/console
sync
reboot
fi
return 0
......@@ -8,6 +8,8 @@ fs.suid_dumpable=2
fs.protected_hardlinks=1
fs.protected_symlinks=1
net.core.bpf_jit_enable=1
net.ipv4.conf.default.arp_ignore=1
net.ipv4.conf.all.arp_ignore=1
net.ipv4.ip_forward=1
......
#!/bin/sh
ppwd="$(sed -ne '/^root:/s/^root:\([^:]*\):.*$/\1/p' /etc/passwd)"
spwd="$(sed -ne '/^root:/s/^root:\([^:]*\):.*$/\1/p' /etc/shadow)"
......
#!/bin/sh
[ "$(uci -q get network.globals.ula_prefix)" != "auto" ] && exit 0
r1=$(dd if=/dev/urandom bs=1 count=1 |hexdump -e '1/1 "%02x"')
......@@ -12,4 +10,3 @@ uci -q batch <<-EOF >/dev/null
EOF
exit 0
#!/bin/sh
. /lib/functions.sh
for file in `grep -sl Require-User /usr/lib/opkg/info/*.control`; do
......
......@@ -17,6 +17,22 @@ NO_EXPORT=1
LOAD_STATE=1
LIST_SEP=" "
# xor multiple hex values of the same length
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"
}
append() {
local var="$1"
local value="$2"
......@@ -213,6 +229,7 @@ add_group_and_user() {
default_postinst() {
local root="${IPKG_INSTROOT}"
local pkgname="$(basename ${1%.*})"
local filelist="/usr/lib/opkg/info/${pkgname}.list"
local ret=0
add_group_and_user "${pkgname}"
......@@ -227,14 +244,14 @@ default_postinst() {
rm -fR $root/rootfs-overlay/
fi
if [ -z "$root" ] && grep -q -s "^/etc/modules.d/" "/usr/lib/opkg/info/${pkgname}.list"; then
if [ -z "$root" ] && grep -q -s "^/etc/modules.d/" "$filelist"; then
kmodloader
fi
if [ -z "$root" ] && grep -q -s "^/etc/uci-defaults/" "/usr/lib/opkg/info/${pkgname}.list"; then
if [ -z "$root" ] && grep -q -s "^/etc/uci-defaults/" "$filelist"; then
. /lib/functions/system.sh
[ -d /tmp/.uci ] || mkdir -p /tmp/.uci
for i in $(grep -s "^/etc/uci-defaults/" "/usr/lib/opkg/info/${pkgname}.list"); do
for i in $(grep -s "^/etc/uci-defaults/" "$filelist"); do
( [ -f "$i" ] && cd "$(dirname $i)" && . "$i" ) && rm -f "$i"
done
uci commit
......@@ -243,7 +260,7 @@ default_postinst() {
[ -n "$root" ] || rm -f /tmp/luci-indexcache 2>/dev/null
local shell="$(which bash)"
for i in $(grep -s "^/etc/init.d/" "$root/usr/lib/opkg/info/${pkgname}.list"); do
for i in $(grep -s "^/etc/init.d/" "$root$filelist"); do
if [ -n "$root" ]; then
${shell:-/bin/sh} "$root/etc/rc.common" "$root$i" enable
else
......
# Copyright (C) 2019 OpenWrt.org
. /lib/functions.sh
. /lib/functions/system.sh
caldata_die() {
echo "caldata: " "$*"
exit 1
}
caldata_extract() {
local part=$1
local offset=$(($2))
local count=$(($3))
local mtd
mtd=$(find_mtd_chardev $part)
[ -n "$mtd" ] || caldata_die "no mtd device found for partition $part"
dd if=$mtd of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \
caldata_die "failed to extract calibration data from $mtd"
}
caldata_extract_ubi() {
local part=$1
local offset=$(($2))
local count=$(($3))
local ubidev
local ubi
. /lib/upgrade/nand.sh
ubidev=$(nand_find_ubi $CI_UBIPART)
ubi=$(nand_find_volume $ubidev $part)
[ -n "$ubi" ] || caldata_die "no UBI volume found for $part"
dd if=/dev/$ubi of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \
caldata_die "failed to extract calibration data from $ubi"
}
caldata_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
}
caldata_from_file() {
local source=$1
local offset=$(($2))
local count=$(($3))
dd if=$source of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \
caldata_die "failed to extract calibration data from $source"
}
caldata_valid() {
local expected="$1"
magic=$(hexdump -v -n 2 -e '1/1 "%02x"' /lib/firmware/$FIRMWARE)
[ "$magic" = "$expected" ]
return $?
}
caldata_patch_chksum() {
local mac=$1
local mac_offset=$(($2))
local chksum_offset=$(($3))
local xor_mac
local xor_fw_mac
local xor_fw_chksum
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
}
caldata_patch_mac() {
local mac=$1
local mac_offset=$(($2))
local chksum_offset=$3
[ -z "$mac" -o -z "$mac_offset" ] && return
[ -n "$chksum_offset" ] && caldata_patch_chksum "$mac" "$mac_offset" "$chksum_offset"
macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc oflag=seek_bytes bs=6 seek=$mac_offset count=1 || \
caldata_die "failed to write MAC address to eeprom file"
}
ath9k_patch_mac() {
local mac=$1
caldata_patch_mac "$mac" 0x2
}
ath9k_patch_mac_crc() {
local mac=$1
local mac_offset=$2
local chksum_offset=$((mac_offset - 10))
caldata_patch_mac "$mac" "$mac_offset" "$chksum_offset"
}
ath10k_patch_mac() {
local mac=$1
caldata_patch_mac "$mac" 0x6 0x2
}
#!/bin/sh
. /lib/functions.sh
migrate_led_sysfs() {
local cfg="$1"; shift
local tuples="$@"
local sysfs
local name
config_get sysfs ${cfg} sysfs
config_get name ${cfg} name
[ -z "${sysfs}" ] && return
for tuple in ${tuples}; do
local old=${tuple%=*}
local new=${tuple#*=}
local new_sysfs
new_sysfs=$(echo ${sysfs} | sed "s/${old}/${new}/")
[ "${new_sysfs}" = "${sysfs}" ] && continue
uci set system.${cfg}.sysfs="${new_sysfs}"
logger -t led-migration "sysfs option of LED \"${name}\" updated to ${new_sysfs}"
done;
}
migrate_leds() {
config_load system
config_foreach migrate_led_sysfs led "$@"
}
migrations_apply() {
local realm="$1"
[ -n "$(uci changes ${realm})" ] && uci -q commit ${realm}
}
......@@ -271,6 +271,11 @@ network_is_up()
# 2: interface
network_get_protocol() { __network_ifstatus "$1" "$2" ".proto"; }
# determine the uptime of the given logical interface
# 1: destination variable
# 2: interface
network_get_uptime() { __network_ifstatus "$1" "$2" ".uptime"; }
# determine the metric of the given logical interface
# 1: destination variable
# 2: interface
......
# Copyright (C) 2006-2013 OpenWrt.org
. /usr/share/libubox/jshn.sh
get_mac_binary() {
local path="$1"
local offset="$2"
if [ -z "$path" ]; then
if ! [ -e "$path" ]; then
echo "get_mac_binary: file $path not found!" >&2
return
fi
......@@ -12,6 +14,44 @@ get_mac_binary() {
hexdump -v -n 6 -s $offset -e '5/1 "%02x:" 1/1 "%02x"' $path 2>/dev/null
}
get_mac_label_dt() {
local basepath="/proc/device-tree"
local macdevice="$(cat "$basepath/aliases/label-mac-device" 2>/dev/null)"
local macaddr
[ -n "$macdevice" ] || return
macaddr=$(get_mac_binary "$basepath/$macdevice/mac-address" 0 2>/dev/null)
[ -n "$macaddr" ] || macaddr=$(get_mac_binary "$basepath/$macdevice/local-mac-address" 0 2>/dev/null)
echo $macaddr
}
get_mac_label_json() {
local cfg="/etc/board.json"
local macaddr
[ -s "$cfg" ] || return
json_init
json_load "$(cat $cfg)"
if json_is_a system object; then
json_select system
json_get_var macaddr label_macaddr
json_select ..
fi
echo $macaddr
}
get_mac_label() {
local macaddr=$(get_mac_label_dt)
[ -n "$macaddr" ] || macaddr=$(get_mac_label_json)
echo $macaddr
}
find_mtd_chardev() {
local INDEX=$(find_mtd_index "$1")
local PREFIX=/dev/mtd
......@@ -40,7 +80,7 @@ mtd_get_mac_ascii() {
mtd_get_mac_text() {
local mtdname=$1
local offset=$2
local offset=$(($2))
local part
local mac_dirty
......@@ -79,12 +119,7 @@ mtd_get_mac_binary_ubi() {
local ubidev=$(nand_find_ubi $CI_UBIPART)
local part=$(nand_find_volume $ubidev $1)
if [ -z "$part" ]; then
echo "mtd_get_mac_binary: ubi volume $mtdname not found!" >&2
return
fi
hexdump -v -n 6 -s $offset -e '5/1 "%02x:" 1/1 "%02x"' /dev/$part 2>/dev/null
get_mac_binary "/dev/$part" "$offset"
}
mtd_get_part_size() {
......@@ -105,10 +140,17 @@ macaddr_add() {
local oui=${mac%:*:*:*}
local nic=${mac#*:*:*:}
nic=$(printf "%06x" $((0x${nic//:/} + $val & 0xffffff)) | sed 's/^\(.\{2\}\)\(.\{2\}\)\(.\{2\}\)/\1:\2:\3/')
nic=$(printf "%06x" $((0x${nic//:/} + val & 0xffffff)) | sed 's/^\(.\{2\}\)\(.\{2\}\)\(.\{2\}\)/\1:\2:\3/')
echo $oui:$nic
}
macaddr_geteui() {
local mac=$1
local sep=$2
echo ${mac:9:2}$sep${mac:12:2}$sep${mac:15:2}
}
macaddr_setbit_la() {
local mac=$1
......
......@@ -182,6 +182,19 @@ _ucidef_finish_switch_roles() {
done
}
ucidef_set_ar8xxx_switch_mib() {
local name="$1"
local type="$2"
local interval="$3"
json_select_object switch
json_select_object "$name"
json_add_int ar8xxx_mib_type $type
json_add_int ar8xxx_mib_poll_interval $interval
json_select ..
json_select ..
}
ucidef_add_switch() {
local name="$1"; shift
local port num role device index need_tag prev_role
......@@ -294,6 +307,14 @@ ucidef_set_interface_macaddr() {
ucidef_set_interface "$network" macaddr "$macaddr"
}
ucidef_set_label_macaddr() {
local macaddr="$1"
json_select_object system
json_add_string label_macaddr "$macaddr"
json_select ..
}
ucidef_add_atm_bridge() {
local vpi="$1"
local vci="$2"
......@@ -463,6 +484,7 @@ _ucidef_set_led_timer() {
_ucidef_set_led_common "$1" "$2" "$3"
json_add_string type "$trigger_name"
json_add_string trigger "$trigger_name"
json_add_int delayon "$delayon"
json_add_int delayoff "$delayoff"
......
......@@ -31,6 +31,8 @@ fs_wait_for_key () {
lock $keypress_wait
{
while [ $timer -gt 0 ]; do
pi_failsafe_net_message=true \
preinit_net_echo "Please press button now to enter failsafe"
echo "$timer" >$keypress_sec
timer=$(($timer - 1))
sleep 1
......@@ -88,9 +90,6 @@ failsafe_wait() {
}
grep -q 'failsafe=' /proc/cmdline && FAILSAFE=true && export FAILSAFE
if [ "$FAILSAFE" != "true" ]; then
pi_failsafe_net_message=true
preinit_net_echo "Please press button now to enter failsafe"
pi_failsafe_net_message=false
fs_wait_for_key f 'to enter failsafe mode' $fs_failsafe_wait_timeout && FAILSAFE=true
[ -f "/tmp/failsafe_button" ] && FAILSAFE=true && echo "- failsafe button "`cat /tmp/failsafe_button`" was pressed -"
[ "$FAILSAFE" = "true" ] && export FAILSAFE && touch /tmp/failsafe
......
......@@ -15,4 +15,4 @@ if [ \! -z "$1" -a -d /etc/hotplug.d/$1 ]; then
for script in $(ls /etc/hotplug.d/$1/* 2>&-); do (
[ -f $script ] && . $script
); done
fi
\ No newline at end of file
fi
......@@ -6,7 +6,7 @@
usage() {
cat <<EOF
Usage: $0 [config|up|down|reload|status]
Usage: $0 [config|up|down|reconf|reload|status]
enables (default), disables or configures devices not yet configured.
EOF
exit 1
......
......@@ -8,11 +8,11 @@ HOME_URL="%u"
BUG_URL="%b"
SUPPORT_URL="%s"
BUILD_ID="%R"
LEDE_BOARD="%S"
LEDE_ARCH="%A"
LEDE_TAINTS="%t"
LEDE_DEVICE_MANUFACTURER="%M"
LEDE_DEVICE_MANUFACTURER_URL="%m"
LEDE_DEVICE_PRODUCT="%P"
LEDE_DEVICE_REVISION="%h"
LEDE_RELEASE="%D %V %C"
OPENWRT_BOARD="%S"
OPENWRT_ARCH="%A"
OPENWRT_TAINTS="%t"
OPENWRT_DEVICE_MANUFACTURER="%M"
OPENWRT_DEVICE_MANUFACTURER_URL="%m"
OPENWRT_DEVICE_PRODUCT="%P"
OPENWRT_DEVICE_REVISION="%h"
OPENWRT_RELEASE="%D %V %C"
......@@ -183,7 +183,7 @@ if VERSIONOPT
config VERSION_REPO
string
prompt "Release repository"
default "http://downloads.lede-project.org/snapshots"
default "http://downloads.openwrt.org/snapshots"
help
This is the repository address embedded in the image, it defaults
to the trunk snapshot repo; the url may contain the following placeholders:
......
......@@ -194,9 +194,11 @@ foreach my $mirror (@ARGV) {
push @mirrors, "https://downloads.sourceforge.net/$1";
}
} elsif ($mirror =~ /^\@APACHE\/(.+)$/) {
push @mirrors, "https://mirrors.ustc.edu.cn/apache/$1";
push @mirrors, "https://mirror.netcologne.de/apache.org/$1";
push @mirrors, "https://mirror.aarnet.edu.au/pub/apache/$1";
push @mirrors, "https://mirror.csclub.uwaterloo.ca/apache/$1";
push @mirrors, "https://archive.apache.org/dist/$1";
push @mirrors, "http://mirror.cogentco.com/pub/apache/$1";
push @mirrors, "http://mirror.navercorp.com/apache/$1";
push @mirrors, "http://ftp.jaist.ac.jp/pub/apache/$1";
......@@ -212,6 +214,7 @@ foreach my $mirror (@ARGV) {
push @mirrors, "https://raw.githubusercontent.com/$dir";
}
} elsif ($mirror =~ /^\@GNU\/(.+)$/) {
push @mirrors, "https://mirrors.ustc.edu.cn/gnu/$1";
push @mirrors, "https://mirror.csclub.uwaterloo.ca/gnu/$1";
push @mirrors, "https://mirror.netcologne.de/gnu/$1";
push @mirrors, "http://ftp.kddilabs.jp/GNU/gnu/$1";
......@@ -235,19 +238,20 @@ foreach my $mirror (@ARGV) {
push @extra, "$extra[0]/testing";
} elsif ($filename =~ /linux-(\d+\.\d+(?:\.\d+)?)/) {
push @extra, "$extra[0]/longterm/v$1";
}
}
foreach my $dir (@extra) {
push @mirrors, "http://mirrors.ustc.edu.cn/kernel.org/$dir";
push @mirrors, "https://mirrors.ustc.edu.cn/kernel.org/$dir";
push @mirrors, "https://cdn.kernel.org/pub/$dir";
push @mirrors, "https://mirror.rackspace.com/kernel.org/$dir";
push @mirrors, "http://download.xs4all.nl/ftp.kernel.org/pub/$dir";
push @mirrors, "http://mirrors.mit.edu/kernel/$dir";
push @mirrors, "https://mirror.rackspace.com/kernel.org/pub/$dir";
push @mirrors, "https://download.xs4all.nl/ftp.kernel.org/pub/$dir";
push @mirrors, "https://mirrors.mit.edu/kernel/$dir";
push @mirrors, "http://ftp.nara.wide.ad.jp/pub/kernel.org/$dir";
push @mirrors, "http://www.ring.gr.jp/archives/linux/kernel.org/$dir";
push @mirrors, "ftp://ftp.riken.jp/Linux/kernel.org/$dir";
push @mirrors, "ftp://www.mirrorservice.org/sites/ftp.kernel.org/pub/$dir";
}
} elsif ($mirror =~ /^\@GNOME\/(.+)$/) {
push @mirrors, "https://mirrors.ustc.edu.cn/gnome/sources/$1";
push @mirrors, "https://mirror.csclub.uwaterloo.ca/gnome/sources/$1";
push @mirrors, "http://ftp.acc.umu.se/pub/GNOME/sources/$1";
push @mirrors, "http://ftp.kaist.ac.kr/gnome/sources/$1";
......@@ -263,9 +267,8 @@ foreach my $mirror (@ARGV) {
}
#push @mirrors, 'https://mirror1.openwrt.org';
push @mirrors, 'https://sources.lede-project.org';
push @mirrors, 'https://sources.openwrt.org';
push @mirrors, 'https://mirror2.openwrt.org/sources';
push @mirrors, 'https://downloads.openwrt.org/sources';
while (!-f "$target/$filename") {
my $mirror = shift @mirrors;
......@@ -275,4 +278,3 @@ while (!-f "$target/$filename") {
}
$SIG{INT} = \&cleanup;
此差异已折叠。
......@@ -2,50 +2,7 @@
[ -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 iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \
ath9k_eeprom_die "failed to extract from $mtd"
}
ath9k_ubi_eeprom_extract() {
local part=$1
local offset=$2
local count=$3
local ubidev=$(nand_find_ubi $CI_UBIPART)
local ubi
ubi=$(nand_find_volume $ubidev $part)
[ -n "$ubi" ] || \
ath9k_eeprom_die "no UBI volume found for $part"
dd if=/dev/$ubi of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \
ath9k_eeprom_die "failed to extract from $ubi"
}
ath9k_patch_firmware_mac() {
local mac=$1
[ -z "$mac" ] && return
macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=2 count=6
}
. /lib/functions/caldata.sh
board=$(board_name)
......@@ -56,14 +13,14 @@ case "$FIRMWARE" in
. /lib/upgrade/nand.sh
if [ -n "$(nand_find_volume ubi0 caldata)" ]; then
ath9k_ubi_eeprom_extract "caldata" 20480 4096
caldata_extract_ubi "caldata" 0x5000 0x1000
else
ath9k_eeprom_extract "wifi_data" 20480 4096
ath9k_patch_firmware_mac $(mtd_get_mac_binary wifi_data 12)
caldata_extract "wifi_data" 0x5000 0x1000
ath9k_patch_mac $(mtd_get_mac_binary wifi_data 0xc)
fi
;;
*)
ath9k_eeprom_die "board $board is not supported yet"
caldata_die "board $board is not supported yet"
;;
esac
;;
......@@ -74,14 +31,14 @@ case "$FIRMWARE" in
. /lib/upgrade/nand.sh
if [ -n "$(nand_find_volume ubi0 caldata)" ]; then
ath9k_ubi_eeprom_extract "caldata" 4096 4096
caldata_extract_ubi "caldata" 0x1000 0x1000
else
ath9k_eeprom_extract "wifi_data" 4096 4096
ath9k_patch_firmware_mac $(mtd_get_mac_binary wifi_data 0)
caldata_extract "wifi_data" 0x1000 0x1000
ath9k_patch_mac $(mtd_get_mac_binary wifi_data 0x0)
fi
;;
*)
ath9k_eeprom_die "board $board is not supported yet"
caldata_die "board $board is not supported yet"
;;
esac
;;
......
......@@ -6,7 +6,7 @@ preinit_set_mac_address() {
case $(board_name) in
meraki,mr24|\
meraki,mx60)
mac_lan=$(mtd_get_mac_binary_ubi board-config 102)
mac_lan=$(mtd_get_mac_binary_ubi board-config 0x66)
[ -n "$mac_lan" ] && ifconfig eth0 hw ether "$mac_lan"
;;
esac
......
......@@ -650,10 +650,58 @@ ar71xx_setup_macs()
[ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
}
ar71xx_setup_ar8xxx_switch()
{
local board="$1"
case $board in
ap147-010|\
archer-c25-v1|\
archer-c58-v1|\
archer-c59-v1|\
archer-c59-v2|\
archer-c60-v1|\
archer-c60-v2|\
archer-c7-v4|\
archer-c7-v5|\
cf-e375ac|\
cf-e385ac|\
cr3000|\
dhp-1565-a1|\
mynet-n600|\
rb-2011il|\
rb-2011ils|\
rb-2011l|\
rb-2011uas|\
rb-2011uas-2hnd|\
rb-2011uias|\
rb-2011uias-2hnd|\
rb-750|\
rb-750p-pbr2|\
rb-750-r2|\
rb-750up-r2|\
rb-951ui-2nd|\
rb-952ui-5ac2nd|\
rb-map-2nd|\
tl-wr1043nd-v4|\
tl-wr1043n-v5|\
wndr3700v4|\
wndr4300|\
wnr1000-v2|\
wnr2000-v3|\
wnr2200|\
wnr612-v2|\
wpn824n)
ucidef_set_ar8xxx_switch_mib "switch0" 0 500
;;
esac
}
board_config_update
board=$(board_name)
ar71xx_setup_interfaces $board
ar71xx_setup_macs $board
ar71xx_setup_ar8xxx_switch $board
board_config_flush
exit 0
......@@ -12,8 +12,8 @@ ath9k_eeprom_die() {
ath9k_eeprom_extract() {
local part=$1
local offset=$2
local count=$3
local offset=$(($2))
local count=$(($3))
local mtd
mtd=$(find_mtd_chardev $part)
......@@ -26,8 +26,8 @@ ath9k_eeprom_extract() {
ath9k_ubi_eeprom_extract() {
local part=$1
local offset=$2
local count=$3
local offset=$(($2))
local count=$(($3))
local ubidev=$(nand_find_ubi $CI_UBIPART)
local ubi
......@@ -42,7 +42,7 @@ ath9k_ubi_eeprom_extract() {
ath9k_eeprom_extract_reverse() {
local part=$1
local offset=$2
local count=$3
local count=$(($3))
local mtd
local reversed
local caldata
......@@ -72,53 +72,53 @@ case "$FIRMWARE" in
case $board in
c-55|\
c-60)
ath9k_eeprom_extract "art" 4096 2048
ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary art 0) +1)
ath9k_eeprom_extract "art" 0x1000 0x800
ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary art 0x0) +1)
;;
fritz4020|\
fritz450e)
ath9k_eeprom_extract_reverse "urlader" 5441 1088
ath9k_eeprom_extract_reverse "urlader" 0x1541 0x440
;;
k2t)
ath9k_eeprom_extract "art" 4096 2048
ath9k_eeprom_extract "art" 0x1000 0x800
ath9k_patch_firmware_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +3)
;;
sbr-ac1750)
ath9k_eeprom_extract "art" 4096 2048
ath9k_eeprom_extract "art" 0x1000 0x800
ath9k_patch_firmware_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +1)
;;
mr18)
. /lib/upgrade/nand.sh
if [ -n "$(nand_find_volume ubi0 caldata)" ]; then
ath9k_ubi_eeprom_extract "caldata" 4096 2048
ath9k_ubi_eeprom_extract "caldata" 0x1000 0x800
else
ath9k_eeprom_extract "odm-caldata" 4096 2048
ath9k_eeprom_extract "odm-caldata" 0x1000 0x800
fi
ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 102) +1)
ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 0x66) +1)
;;
r6100 | \
wndr3700v4 | \
wndr4300)
ath9k_eeprom_extract "caldata" 4096 2048
ath9k_patch_firmware_mac $(mtd_get_mac_binary caldata 0)
ath9k_eeprom_extract "caldata" 0x1000 0x800
ath9k_patch_firmware_mac $(mtd_get_mac_binary caldata 0x0)
;;
rambutan)
ath9k_eeprom_extract "art" 4096 2048
ath9k_eeprom_extract "art" 0x1000 0x800
;;
wlr8100)
ath9k_eeprom_extract "art" 4096 2048
ath9k_eeprom_extract "art" 0x1000 0x800
ath9k_patch_firmware_mac $(mtd_get_mac_ascii u-boot-env "ethaddr")
;;
z1)
. /lib/upgrade/nand.sh
if [ -n "$(nand_find_volume ubi0 caldata)" ]; then
ath9k_ubi_eeprom_extract "caldata" 4096 2048
ath9k_ubi_eeprom_extract "caldata" 0x1000 0x800
else
ath9k_eeprom_extract "origcaldata" 4096 2048
ath9k_eeprom_extract "origcaldata" 0x1000 0x800
fi
ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 102) +2)
ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 0x66) +2)
;;
*)
ath9k_eeprom_die "board $board is not supported yet"
......@@ -129,36 +129,36 @@ case "$FIRMWARE" in
"pci_wmac0.eeprom")
case $board in
c-55)
ath9k_eeprom_extract "art" 20480 2048
ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary art 0) +2)
ath9k_eeprom_extract "art" 0x5000 0x800
ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary art 0x0) +2)
;;
fritz300e)
ath9k_eeprom_extract_reverse "urloader" 5441 1088
ath9k_eeprom_extract_reverse "urloader" 0x1541 0x440
;;
mr18)
. /lib/upgrade/nand.sh
if [ -n "$(nand_find_volume ubi0 caldata)" ]; then
ath9k_ubi_eeprom_extract "caldata" 20480 2048
ath9k_ubi_eeprom_extract "caldata" 0x1541 0x440
else
ath9k_eeprom_extract "odm-caldata" 20480 2048
ath9k_eeprom_extract "odm-caldata" 0x5000 0x800
fi
ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 102) +2)
ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 0x66) +2)
;;
wndr3700v4 | \
wndr4300)
ath9k_eeprom_extract "caldata" 20480 2048
ath9k_patch_firmware_mac $(mtd_get_mac_binary caldata 12)
ath9k_eeprom_extract "caldata" 0x5000 0x800
ath9k_patch_firmware_mac $(mtd_get_mac_binary caldata 0xc)
;;
z1)
. /lib/upgrade/nand.sh
if [ -n "$(nand_find_volume ubi0 caldata)" ]; then
ath9k_ubi_eeprom_extract "caldata" 86016 4096
ath9k_ubi_eeprom_extract "caldata" 0x15000 0x1000
else
ath9k_eeprom_extract "origcaldata" 86016 4096
ath9k_eeprom_extract "origcaldata" 0x15000 0x1000
fi
ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 102) +3)
ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 0x66) +3)
;;
*)
ath9k_eeprom_die "board $board is not supported yet"
......@@ -172,11 +172,11 @@ case "$FIRMWARE" in
. /lib/upgrade/nand.sh
if [ -n "$(nand_find_volume ubi0 caldata)" ]; then
ath9k_ubi_eeprom_extract "caldata" 36864 2048
ath9k_ubi_eeprom_extract "caldata" 0x9000 0x800
else
ath9k_eeprom_extract "odm-caldata" 36864 2048
ath9k_eeprom_extract "odm-caldata" 0x9000 0x800
fi
ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 102) +3)
ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 0x66) +3)
;;
*)
ath9k_eeprom_die "board $board is not supported yet"
......
#!/bin/sh
# xor multiple hex values of the same length
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"
}
ath10kcal_die() {
echo "ath10cal: " "$*"
exit 1
......@@ -23,8 +7,8 @@ ath10kcal_die() {
ath10kcal_from_file() {
local source=$1
local offset=$2
local count=$3
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"
......@@ -32,8 +16,8 @@ ath10kcal_from_file() {
ath10kcal_extract() {
local part=$1
local offset=$2
local count=$3
local offset=$(($2))
local count=$(($3))
local mtd cal_size
mtd=$(find_mtd_chardev $part)
......@@ -55,30 +39,7 @@ ath10kcal_patch_mac() {
[ -z "$mac" ] && return
macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=6 count=6
}
ath10kcal_patch_mac_crc() {
local mac=$1
local mac_offset=6
local chksum_offset=2
local xor_mac
local xor_fw_mac
local xor_fw_chksum
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}"
ath10kcal_patch_mac "$mac" && {
xor_mac=${mac//:/}
xor_mac="${xor_mac:0:4} ${xor_mac:4:4} ${xor_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 oflag=seek_bytes bs=6 seek=6 count=1
}
[ -e /lib/firmware/$FIRMWARE ] && exit 0
......@@ -96,17 +57,17 @@ case "$FIRMWARE" in
mr1750|\
mr1750v2|\
om5p-acv2)
ath10kcal_extract "ART" 20480 2116
ath10kcal_extract "ART" 0x5000 0x844
ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +16)
;;
archer-c25-v1|\
tl-wdr6500-v2)
ath10kcal_extract "art" 20480 2116
ath10kcal_extract "art" 0x5000 0x844
ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) -2)
;;
archer-c7-v4|\
archer-c7-v5)
ath10kcal_extract "art" 20480 2116
ath10kcal_extract "art" 0x5000 0x844
ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -1)
;;
cf-e355ac-v1|\
......@@ -119,64 +80,64 @@ case "$FIRMWARE" in
oolite-v5.2-dev|\
sr3200|\
xd3200)
ath10kcal_extract "art" 20480 2116
ath10kcal_extract "art" 0x5000 0x844
;;
dap-2695-a1)
ath10kcal_extract "radiocfg" 20480 2116
ath10kcal_extract "radiocfg" 0x5000 0x844
ath10kcal_patch_mac $(mtd_get_mac_ascii bdcfg wlanmac_a)
;;
dir-869-a1|\
qihoo-c301)
ath10kcal_extract "radiocfg" 20480 2116
ath10kcal_extract "radiocfg" 0x5000 0x844
ath10kcal_patch_mac $(mtd_get_mac_ascii devdata wlan5mac)
;;
dw33d)
ath10kcal_extract "art" 20480 2116
ath10kcal_patch_mac $(mtd_get_mac_binary art 18)
ath10kcal_extract "art" 0x5000 0x844
ath10kcal_patch_mac $(mtd_get_mac_binary art 0x12)
;;
sbr-ac1750)
ath10kcal_extract "art" 20480 2116
ath10kcal_patch_mac_crc $(macaddr_add $(cat /sys/class/net/eth1/address) +1)
ath10kcal_extract "art" 0x5000 0x844
ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) +1)
;;
epg5000|\
esr1750)
ath10kcal_extract "caldata" 20480 2116
ath10kcal_extract "caldata" 0x5000 0x844
ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +1)
;;
gl-ar750s|\
gl-ar750|\
tl-wpa8630)
ath10kcal_extract "art" 20480 2116
ath10kcal_extract "art" 0x5000 0x844
ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +1)
;;
koala)
ath10kcal_extract "art" 20480 2116
ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary art 12) +0)
ath10kcal_extract "art" 0x5000 0x844
ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0xc) +0)
;;
mc-mac1200r)
ath10kcal_extract "art" 20480 2116
ath10kcal_extract "art" 0x5000 0x844
ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) -1)
;;
r6100)
ath10kcal_extract "caldata" 20480 2116
ath10kcal_extract "caldata" 0x5000 0x844
ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) +2)
;;
rb-952ui-5ac2nd|\
rb-wapg-5hact2hnd)
ath10kcal_from_file "/sys/firmware/routerboot/ext_wlan_data" 20480 2116
ath10kcal_from_file "/sys/firmware/routerboot/ext_wlan_data" 0x5000 0x844
;;
re355|\
re450|\
tl-wr902ac-v1)
ath10kcal_extract "art" 20480 2116
ath10kcal_extract "art" 0x5000 0x844
ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -2)
;;
unifiac-lite|\
unifiac-pro)
ath10kcal_extract "EEPROM" 20480 2116
ath10kcal_extract "EEPROM" 0x5000 0x844
;;
wi2a-ac200i)
ath10kcal_extract "ART" 20480 2116
ath10kcal_extract "ART" 0x5000 0x844
;;
esac
;;
......@@ -184,25 +145,25 @@ case "$FIRMWARE" in
case $board in
archer-c5|\
archer-c7)
ath10kcal_extract "art" 20480 2116
ath10kcal_extract "art" 0x5000 0x844
ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) -2)
;;
nbg6616|\
nbg6716)
ath10kcal_extract "RFdata" 20480 2116
ath10kcal_extract "RFdata" 0x5000 0x844
ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) -2)
;;
om5p-ac)
ath10kcal_extract "ART" 20480 2116
ath10kcal_extract "ART" 0x5000 0x844
ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +16)
;;
rb-911g-5hpacd|\
rb-921gs-5hpacd-r2|\
rb-962uigs-5hact2hnt)
ath10kcal_from_file "/sys/firmware/routerboot/ext_wlan_data" 20480 2116
ath10kcal_from_file "/sys/firmware/routerboot/ext_wlan_data" 0x5000 0x844
;;
wlr8100)
ath10kcal_extract "art" 20480 2116
ath10kcal_extract "art" 0x5000 0x844
ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) +1)
;;
esac
......@@ -213,24 +174,29 @@ case "$FIRMWARE" in
archer-c59-v1|\
archer-c59-v2|\
archer-c60-v1|\
archer-c60-v2|\
cf-e355ac-v2|\
cf-e375ac)
ath10kcal_extract "art" 20480 12064
ath10kcal_extract "art" 0x5000 0x2f20
ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \
/lib/firmware/ath10k/QCA9888/hw2.0/board.bin
;;
archer-c60-v2)
ath10kcal_extract "art" 0x5000 0x2f20
ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \
/lib/firmware/ath10k/QCA9888/hw2.0/board.bin
ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -1)
;;
cf-e385ac)
ath10kcal_extract "art" 20480 12064
ath10kcal_extract "art" 0x5000 0x2f20
;;
k2t)
ath10kcal_extract "art" 20480 12064
ath10kcal_extract "art" 0x5000 0x2f20
ath10kcal_patch_mac_crc $(macaddr_add $(cat /sys/class/net/eth0/address) +2)
ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \
/lib/firmware/ath10k/QCA9888/hw2.0/board.bin
;;
tl-wdr6500-v6)
ath10kcal_extract "art" 8192 12064
tl-wdr6500-v6)
ath10kcal_extract "art" 0x2000 0x2f20
ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \
/lib/firmware/ath10k/QCA9888/hw2.0/board.bin
;;
......
......@@ -17,7 +17,7 @@ case "$board" in
archer-c59-v2|\
archer-c60-v1|\
archer-c60-v2)
echo $(macaddr_add $(mtd_get_mac_binary mac 8) $(($PHYNBR - 1)) ) > /sys${DEVPATH}/macaddress
echo $(macaddr_add $(mtd_get_mac_binary mac 0x8) $(($PHYNBR - 1)) ) > /sys${DEVPATH}/macaddress
;;
tl-wdr6500-v6)
echo $(macaddr_add $(mtd_get_mac_binary art 2061) $(($PHYNBR - 2)) ) > /sys${DEVPATH}/macaddress
......@@ -25,4 +25,3 @@ case "$board" in
*)
;;
esac
......@@ -12,6 +12,9 @@
devdir=$(dirname $DEVPATH)
devdir=$(dirname $devdir)
phydir=/sys$devdir/ieee80211
[ -d $phydir ] || exit 0
phyname=$(cat $phydir/phy*/name)
[ -z $phyname -o $ACTION != "add" ] && exit 0
......
......@@ -24,7 +24,7 @@ preinit_set_mac_address() {
case $(board_name) in
c-55|\
c-60)
mac_lan=$(mtd_get_mac_binary art 0)
mac_lan=$(mtd_get_mac_binary art 0x0)
[ -n "$mac_lan" ] && ifconfig eth0 hw ether "$mac_lan"
;;
dir-615-c1|\
......@@ -40,28 +40,28 @@ preinit_set_mac_address() {
;;
mr18|\
z1)
mac_lan=$(mtd_get_mac_binary_ubi board-config 102)
mac_lan=$(mtd_get_mac_binary_ubi board-config 0x66)
[ -n "$mac_lan" ] && ifconfig eth0 hw ether "$mac_lan"
;;
r6100)
mac_lan=$(mtd_get_mac_binary caldata 0)
mac_lan=$(mtd_get_mac_binary caldata 0x0)
[ -n "$mac_lan" ] && ifconfig eth1 hw ether "$mac_lan"
mac_wan=$(mtd_get_mac_binary caldata 6)
mac_wan=$(mtd_get_mac_binary caldata 0x6)
[ -n "$mac_wan" ] && ifconfig eth0 hw ether "$mac_wan"
;;
rambutan)
mac_lan=$(mtd_get_mac_binary art 0)
mac_lan=$(mtd_get_mac_binary art 0x0)
[ -n "$mac_lan" ] && ifconfig eth0 hw ether "$mac_lan"
mac_wan=$(mtd_get_mac_binary art 6)
mac_wan=$(mtd_get_mac_binary art 0x6)
[ -n "$mac_wan" ] && ifconfig eth1 hw ether "$mac_wan"
;;
wrt160nl)
fetch_mac_from_mtd nvram lan_hwaddr wan_hwaddr
;;
sbr-ac1750)
mac_lan=$(mtd_get_mac_binary ft 0)
mac_lan=$(mtd_get_mac_binary ft 0x0)
[ -n "$mac_lan" ] && ifconfig eth1 hw ether "$mac_lan"
mac_wan=$(mtd_get_mac_binary ft 18)
mac_wan=$(mtd_get_mac_binary ft 0x12)
[ -n "$mac_wan" ] && ifconfig eth0 hw ether "$mac_wan"
;;
esac
......
......@@ -11,11 +11,6 @@ board=$(board_name)
boardname="${board##*,}"
case "$board" in
p2w,r619ac |\
p2w,r619ac-128m)
ucidef_set_led_wlan "wlan2g" "WLAN2G" "r619ac:blue:wlan2g" "phy0tpt"
ucidef_set_led_wlan "wlan5g" "WLAN5G" "r619ac:blue:wlan5g" "phy1tpt"
;;
asus,rt-ac58u)
ucidef_set_led_wlan "wlan2g" "WLAN2G" "${boardname}:blue:wlan2G" "phy0tpt"
ucidef_set_led_wlan "wlan5g" "WLAN5G" "${boardname}:blue:wlan5G" "phy1tpt"
......@@ -46,15 +41,20 @@ engenius,eap1300)
glinet,gl-b1300)
ucidef_set_led_wlan "wlan" "WLAN" "${boardname}:green:wlan" "phy0tpt"
;;
hugo,ac1200)
ucidef_set_led_default "green" "GREEN" "${boardname}:green:ctrl1" "1"
ucidef_set_led_default "red" "RED" "${boardname}:red:ctrl2" "1"
ucidef_set_led_default "blue" "BLUE" "${boardname}:blue:ctrl3" "1"
;;
netgear,ex6100v2 |\
netgear,ex6150v2)
ucidef_set_led_wlan "wlan2g" "WLAN2G" "ex61x0v2:green:router" "phy0tpt"
ucidef_set_led_wlan "wlan5g" "WLAN5G" "ex61x0v2:green:client" "phy1tpt"
;;
hugo,ac1200)
ucidef_set_led_default "green" "GREEN" "${boardname}:green:ctrl1" "1"
ucidef_set_led_default "red" "RED" "${boardname}:red:ctrl2" "1"
ucidef_set_led_default "blue" "BLUE" "${boardname}:blue:ctrl3" "1"
p2w,r619ac |\
p2w,r619ac-128m)
ucidef_set_led_wlan "wlan2g" "WLAN2G" "r619ac:blue:wlan2g" "phy0tpt"
ucidef_set_led_wlan "wlan5g" "WLAN5G" "r619ac:blue:wlan5g" "phy1tpt"
;;
zyxel,nbg6617)
ucidef_set_led_wlan "wlan2g" "WLAN2G" "${boardname}:green:wlan2G" "phy0tpt"
......
......@@ -16,24 +16,20 @@ ipq40xx_setup_interfaces()
ucidef_add_switch "switch0" \
"0t@eth0" "4:lan" "5:wan"
;;
p2w,r619ac|\
p2w,r619ac-128m|\
zyxel,nbg6617)
ucidef_add_switch "switch0" \
"0t@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan:5"
;;
asus,map-ac2200|\
openmesh,a42|\
openmesh,a62)
ucidef_add_switch "switch0" \
"0t@eth0" "5:lan" "4:wan"
;;
hugo,ac1200)
asus,rt-ac58u|\
p2w,r619ac|\
p2w,r619ac-128m|\
zyxel,nbg6617)
ucidef_add_switch "switch0" \
"0t@eth0" "5:wan" "3:lan"
"0t@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
;;
asus,rt-acrh17|\
asus,rt-ac58u|\
avm,fritzbox-4040|\
linksys,ea6350v3)
ucidef_add_switch "switch0" \
......@@ -53,6 +49,10 @@ ipq40xx_setup_interfaces()
ucidef_add_switch "switch0" \
"0t@eth0" "3:lan" "4:lan" "5:wan"
;;
hugo,ac1200)
ucidef_add_switch "switch0" \
"0t@eth0" "5:wan" "3:lan"
;;
*)
echo "Unsupported hardware. Network interfaces not initialized"
;;
......@@ -62,6 +62,9 @@ ipq40xx_setup_interfaces()
ipq40xx_setup_macs()
{
local board="$1"
local lan_mac=""
local wan_mac=""
local label_mac=""
case "$board" in
asus,rt-acrh17|\
......@@ -81,8 +84,9 @@ ipq40xx_setup_macs()
;;
esac
[ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
[ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
[ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
[ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
[ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
}
board_config_update
......
#!/bin/sh
# xor multiple hex values of the same length
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"
}
ath10kcal_die() {
echo "ath10cal: " "$*"
exit 1
}
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 iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \
ath10kcal_die "failed to extract calibration data from $mtd"
}
ath10kcal_ubi_extract() {
local part=$1
local offset=$2
local count=$3
local ubidev
local ubi
. /lib/upgrade/nand.sh
ubidev=$(nand_find_ubi $CI_UBIPART)
ubi=$(nand_find_volume $ubidev $part)
[ -n "$ubi" ] || \
ath10kcal_die "no UBI volume found for $part"
dd if=/dev/$ubi of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \
ath10kcal_die "failed to extract from $ubi"
}
ath10kcal_patch_mac_crc() {
local mac=$1
local mac_offset=6
local chksum_offset=2
local xor_mac
local xor_fw_mac
local xor_fw_chksum
[ -z "$mac" ] && return
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}"
macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=6 count=6
xor_mac=${mac//:/}
xor_mac="${xor_mac:0:4} ${xor_mac:4:4} ${xor_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
}
ath10kcal_is_caldata_valid() {
local expected="$1"
magic=$(hexdump -v -n 2 -e '1/1 "%02x"' /lib/firmware/$FIRMWARE)
[[ "$magic" == "$expected" ]]
return $?
}
[ -e /lib/firmware/$FIRMWARE ] && exit 0
. /lib/functions.sh
. /lib/functions/system.sh
. /lib/functions/caldata.sh
board=$(board_name)
case "$FIRMWARE" in
"ath10k/cal-pci-0000:01:00.0.bin")
case "$board" in
meraki,mr33)
ath10kcal_ubi_extract "ART" 36864 2116
ath10kcal_is_caldata_valid "4408" || ath10kcal_extract "ART" 36864 2116
ath10kcal_patch_mac_crc $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 102) +1)
caldata_extract_ubi "ART" 0x9000 0x844
caldata_valid "4408" || caldata_extract "ART" 0x9000 0x844
ath10k_patch_mac $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66) +1)
;;
esac
;;
"ath10k/pre-cal-pci-0000:01:00.0.bin")
case "$board" in
asus,map-ac2200)
ath10kcal_ubi_extract "Factory" 36864 12064
caldata_extract_ubi "Factory" 0x9000 0x2f20
ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \
/lib/firmware/ath10k/QCA9888/hw2.0/board.bin
;;
asus,rt-acrh17)
CI_UBIPART=UBI_DEV
ath10kcal_ubi_extract "Factory" 36864 12064
caldata_extract_ubi "Factory" 0x9000 0x2f20
;;
openmesh,a62)
ath10kcal_extract "0:ART" 36864 12064
caldata_extract "0:ART" 0x9000 0x2f20
;;
p2w,r619ac |\
p2w,r619ac-128m)
ath10kcal_extract "ART" 36864 12064
caldata_extract "ART" 0x9000 0x2f20
;;
esac
;;
......@@ -132,40 +44,40 @@ case "$FIRMWARE" in
p2w,r619ac |\
p2w,r619ac-128m |\
qcom,ap-dk01.1-c1)
ath10kcal_extract "ART" 4096 12064
caldata_extract "ART" 0x1000 0x2f20
;;
asus,map-ac2200)
ath10kcal_ubi_extract "Factory" 4096 12064
caldata_extract_ubi "Factory" 0x1000 0x2f20
;;
asus,rt-acrh17|\
asus,rt-ac58u)
CI_UBIPART=UBI_DEV
ath10kcal_ubi_extract "Factory" 4096 12064
caldata_extract_ubi "Factory" 0x1000 0x2f20
;;
avm,fritzbox-4040)
/usr/bin/fritz_cal_extract -i 1 -s 0x400 -e 0x207 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader_config")
;;
meraki,mr33)
ath10kcal_ubi_extract "ART" 4096 12064
ath10kcal_is_caldata_valid "202f" || ath10kcal_extract "ART" 4096 12064
ath10kcal_patch_mac_crc $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 102) +2)
;;
netgear,ex6100v2 |\
netgear,ex6150v2)
ath10kcal_extract "ART" 4096 12064
ath10kcal_patch_mac_crc $(mtd_get_mac_binary dnidata 0)
;;
compex,wpj428 |\
engenius,eap1300 |\
hugo,ac1200 |\
openmesh,a42 |\
openmesh,a62)
ath10kcal_extract "0:ART" 4096 12064
caldata_extract "0:ART" 0x1000 0x2f20
;;
meraki,mr33)
caldata_extract_ubi "ART" 0x1000 0x2f20
caldata_valid "202f" || caldata_extract 0x1000 0x2f20
ath10k_patch_mac $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66) +2)
;;
netgear,ex6100v2 |\
netgear,ex6150v2)
caldata_extract "ART" 0x1000 0x2f20
ath10k_patch_mac $(mtd_get_mac_binary dnidata 0x0)
;;
zyxel,nbg6617 |\
zyxel,wre6606)
ath10kcal_extract "ART" 4096 12064
ath10kcal_patch_mac_crc $(macaddr_add $(cat /sys/class/net/eth0/address) -2)
caldata_extract "ART" 0x1000 0x2f20
ath10k_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -2)
;;
esac
;;
......@@ -177,39 +89,39 @@ case "$FIRMWARE" in
p2w,r619ac |\
p2w,r619ac-128m |\
qcom,ap-dk01.1-c1)
ath10kcal_extract "ART" 20480 12064
caldata_extract "ART" 0x5000 0x2f20
;;
asus,map-ac2200)
ath10kcal_ubi_extract "Factory" 20480 12064
caldata_extract "Factory" 0x5000 0x2f20
;;
asus,rt-ac58u)
CI_UBIPART=UBI_DEV
ath10kcal_ubi_extract "Factory" 20480 12064
caldata_extract_ubi "Factory" 0x5000 0x2f20
;;
avm,fritzbox-4040)
/usr/bin/fritz_cal_extract -i 1 -s 0x400 -e 0x208 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader_config")
;;
meraki,mr33)
ath10kcal_ubi_extract "ART" 20480 12064
ath10kcal_is_caldata_valid "202f" || ath10kcal_extract "ART" 20480 12064
ath10kcal_patch_mac_crc $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 102) +3)
;;
netgear,ex6100v2 |\
netgear,ex6150v2)
ath10kcal_extract "ART" 20480 12064
ath10kcal_patch_mac_crc $(mtd_get_mac_binary dnidata 12)
;;
compex,wpj428 |\
engenius,eap1300 |\
hugo,ac1200 |\
openmesh,a42 |\
openmesh,a62)
ath10kcal_extract "0:ART" 20480 12064
caldata_extract "0:ART" 0x5000 0x2f20
;;
meraki,mr33)
caldata_extract_ubi "ART" 0x5000 0x2f20
caldata_valid "202f" || caldata_extract "ART" 0x5000 0x2f20
ath10k_patch_mac $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66) +3)
;;
netgear,ex6100v2 |\
netgear,ex6150v2)
caldata_extract "ART" 0x5000 0x2f20
ath10k_patch_mac $(mtd_get_mac_binary dnidata 0xc)
;;
zyxel,nbg6617 |\
zyxel,wre6606)
ath10kcal_extract "ART" 20480 12064
ath10kcal_patch_mac_crc $(macaddr_add $(cat /sys/class/net/eth0/address) -1)
caldata_extract "ART" 0x5000 0x2f20
ath10k_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -1)
;;
esac
;;
......
......@@ -5,23 +5,24 @@
preinit_set_mac_address() {
case $(board_name) in
asus,map-ac2200)
base_mac=$(mtd_get_mac_binary_ubi Factory 4102)
base_mac=$(mtd_get_mac_binary_ubi Factory 0x1006)
ip link set dev eth0 address $(macaddr_add "$base_mac" +1)
ip link set dev eth1 address $(macaddr_add "$base_mac" +3)
;;
asus,rt-acrh17|\
asus,rt-ac58u)
CI_UBIPART=UBI_DEV
mac=$(macaddr_add $(mtd_get_mac_binary_ubi Factory 4102) +1)
mac=$(macaddr_add $(mtd_get_mac_binary_ubi Factory 0x1006) +1)
ifconfig eth0 hw ether $mac 2>/dev/null
;;
meraki,mr33)
mac_lan=$(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 102)
mac_lan=$(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66)
[ -n "$mac_lan" ] && ip link set dev eth0 address "$mac_lan"
;;
zyxel,nbg6617)
base_mac=$(cat /sys/class/net/eth0/address)
ip link set dev eth0 address $(macaddr_add "$base_mac" +2)
ip link set dev eth1 address $(macaddr_add "$base_mac" +3)
;;
esac
}
......
......@@ -165,6 +165,19 @@ define Device/glinet_gl-b1300
endef
TARGET_DEVICES += glinet_gl-b1300
define Device/hugo_ac1200
$(call Device/FitImage)
DEVICE_TITLE := Hugo AC1200
BOARD_NAME := hugo_ac1200
DEVICE_DTS := qcom-ipq4019-hugo-ac1200
KERNEL_SIZE := 4096k
IMAGE_SIZE := 31232k
IMAGES := sysupgrade.bin
IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata
DEVICE_PACKAGES := ipq-wifi-hugo_ac1200
endef
TARGET_DEVICES += hugo_ac1200
define Device/linksys_ea6350v3
# The Linksys EA6350v3 has a uboot bootloader that does not
# support either booting lzma kernel images nor booting UBI
......@@ -260,22 +273,8 @@ define Device/openmesh_a62
IMAGE/sysupgrade.bin/squashfs := append-rootfs | pad-rootfs | sysupgrade-tar rootfs=$$$$@ | append-metadata
DEVICE_PACKAGES := ath10k-firmware-qca9888-ct uboot-envtools
endef
TARGET_DEVICES += openmesh_a62
define Device/qcom_ap-dk01.1-c1
DEVICE_TITLE := QCA AP-DK01.1-C1
BOARD_NAME := ap-dk01.1-c1
DEVICE_DTS := qcom-ipq4019-ap.dk01.1-c1
KERNEL_INSTALL := 1
KERNEL_SIZE := 4096k
IMAGE_SIZE := 26624k
$(call Device/FitImage)
IMAGES := sysupgrade.bin
IMAGE/sysupgrade.bin := append-kernel | pad-to $$$${KERNEL_SIZE} | append-rootfs | pad-rootfs | append-metadata
endef
TARGET_DEVICES += qcom_ap-dk01.1-c1
define Device/p2w_r619ac
$(call Device/FitzImage)
$(call Device/UbiFit)
......@@ -305,6 +304,19 @@ define Device/p2w_r619ac-128m
endef
TARGET_DEVICES += p2w_r619ac-128m
define Device/qcom_ap-dk01.1-c1
DEVICE_TITLE := QCA AP-DK01.1-C1
BOARD_NAME := ap-dk01.1-c1
DEVICE_DTS := qcom-ipq4019-ap.dk01.1-c1
KERNEL_INSTALL := 1
KERNEL_SIZE := 4096k
IMAGE_SIZE := 26624k
$(call Device/FitImage)
IMAGES := sysupgrade.bin
IMAGE/sysupgrade.bin := append-kernel | pad-to $$$${KERNEL_SIZE} | append-rootfs | pad-rootfs | append-metadata
endef
TARGET_DEVICES += qcom_ap-dk01.1-c1
define Device/qcom_ap-dk04.1-c1
$(call Device/FitImage)
$(call Device/UbiFit)
......@@ -318,19 +330,6 @@ define Device/qcom_ap-dk04.1-c1
endef
TARGET_DEVICES += qcom_ap-dk04.1-c1
define Device/hugo_ac1200
$(call Device/FitImage)
DEVICE_TITLE := Hugo AC1200
BOARD_NAME := hugo_ac1200
DEVICE_DTS := qcom-ipq4019-hugo-ac1200
KERNEL_SIZE := 4096k
IMAGE_SIZE := 31232k
IMAGES := sysupgrade.bin
IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata
DEVICE_PACKAGES := ipq-wifi-hugo_ac1200
endef
TARGET_DEVICES += hugo_ac1200
define Device/zyxel_nbg6617
$(call Device/FitImageLzma)
DEVICE_DTS := qcom-ipq4018-nbg6617
......
#!/bin/sh
# xor multiple hex values of the same length
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"
}
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_crc() {
local mac=$1
local mac_offset=6
local chksum_offset=2
local xor_mac
local xor_fw_mac
local xor_fw_chksum
[ -z "$mac" ] && return
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}"
macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=6 count=6
xor_mac=${mac//:/}
xor_mac="${xor_mac:0:4} ${xor_mac:4:4} ${xor_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
}
[ -e /lib/firmware/$FIRMWARE ] && exit 0
. /lib/functions.sh
. /lib/functions/system.sh
. /lib/functions/caldata.sh
board=$(board_name)
......@@ -80,68 +10,68 @@ case "$FIRMWARE" in
"ath10k/pre-cal-pci-0000:01:00.0.bin")
case $board in
buffalo,wxr-2533dhp)
ath10kcal_extract "ART" 4096 12064
ath10kcal_patch_mac_crc $(mtd_get_mac_binary ART 30)
caldata_extract "ART" 0x1000 0x2f20
ath10k_patch_mac $(mtd_get_mac_binary ART 0x1e)
;;
linksys,ea8500)
ath10kcal_extract "art" 4096 12064
ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) +1)
caldata_extract "art" 0x1000 0x2f20
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) +1)
;;
nec,wg2600hp)
ath10kcal_extract "ART" 4096 12064
ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary PRODUCTDATA 12) +1)
caldata_extract "ART" 0x1000 0x2f20
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary PRODUCTDATA 0xc) +1)
;;
netgear,d7800 |\
netgear,r7500v2 |\
netgear,r7800)
ath10kcal_extract "art" 4096 12064
ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary art 6) +1)
caldata_extract "art" 0x1000 0x2f20
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x6) +1)
;;
tplink,c2600)
ath10kcal_extract "radio" 4096 12064
ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary default-mac 8) -1)
caldata_extract "radio" 0x1000 0x2f20
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary default-mac 0x8) -1)
;;
tplink,vr2600v)
ath10kcal_extract "ART" 4096 12064
ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary default-mac 0) -1)
caldata_extract "ART" 0x1000 0x2f20
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary default-mac 0x0) -1)
;;
zyxel,nbg6817)
ath10kcal_extract "0:ART" 4096 12064
ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii 0:APPSBLENV ethaddr) +1)
caldata_extract "0:ART" 0x1000 0x2f20
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii 0:APPSBLENV ethaddr) +1)
;;
esac
;;
"ath10k/pre-cal-pci-0001:01:00.0.bin")
case $board in
buffalo,wxr-2533dhp)
ath10kcal_extract "ART" 20480 12064
ath10kcal_patch_mac_crc $(mtd_get_mac_binary ART 24)
caldata_extract "ART" 0x5000 0x2f20
ath10k_patch_mac $(mtd_get_mac_binary ART 0x18)
;;
linksys,ea8500)
ath10kcal_extract "art" 20480 12064
ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) +2)
caldata_extract "art" 0x5000 0x2f20
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) +2)
;;
nec,wg2600hp)
ath10kcal_extract "ART" 20480 12064
ath10kcal_patch_mac_crc $(mtd_get_mac_binary PRODUCTDATA 12)
caldata_extract "ART" 0x5000 0x2f20
ath10k_patch_mac $(mtd_get_mac_binary PRODUCTDATA 0xc)
;;
netgear,d7800 |\
netgear,r7500v2 |\
netgear,r7800)
ath10kcal_extract "art" 20480 12064
ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary art 6) +2)
caldata_extract "art" 0x5000 0x2f20
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x6) +2)
;;
tplink,c2600)
ath10kcal_extract "radio" 20480 12064
ath10kcal_patch_mac_crc $(mtd_get_mac_binary default-mac 8)
caldata_extract "radio" 0x5000 0x2f20
ath10k_patch_mac $(mtd_get_mac_binary default-mac 0x8)
;;
tplink,vr2600v)
ath10kcal_extract "ART" 20480 12064
ath10kcal_patch_mac_crc $(mtd_get_mac_binary default-mac 0)
caldata_extract "ART" 0x5000 0x2f20
ath10k_patch_mac $(mtd_get_mac_binary default-mac 0x0)
;;
zyxel,nbg6817)
ath10kcal_extract "0:ART" 20480 12064
ath10kcal_patch_mac_crc $(mtd_get_mac_ascii 0:APPSBLENV ethaddr)
caldata_extract "0:ART" 0x5000 0x2f20
ath10k_patch_mac $(mtd_get_mac_ascii 0:APPSBLENV ethaddr)
;;
esac
;;
......
......@@ -29,4 +29,3 @@ set_ether_mac() {
}
boot_hook_add preinit_main set_ether_mac
......@@ -3,47 +3,18 @@
[ -e /lib/firmware/$FIRMWARE ] && exit 0
. /lib/functions.sh
. /lib/functions/system.sh
. /lib/upgrade/nand.sh
ath10k_caldata_die() {
echo "ath10k caldata: " "$*"
exit 1
}
ath10k_caldata_extract_ubi() {
local part=$1
local offset=$2
local count=$3
local ubidev=$(nand_find_ubi $CI_UBIPART)
local ubi
ubi=$(nand_find_volume $ubidev $part)
[ -n "$ubi" ] || \
ath10k_caldata_die "no UBI volume found for $part"
dd if=/dev/$ubi of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \
ath10k_caldata_die "failed to extract from $ubi"
}
ath10k_caldata_set_macaddr() {
local macaddr=$1
macaddr_2bin $macaddr | dd of=/lib/firmware/$FIRMWARE \
conv=notrunc bs=1 seek=6 count=6
}
. /lib/functions/caldata.sh
case "$FIRMWARE" in
"ath10k/cal-pci-0000:02:00.0.bin")
board=$(board_name)
case $board in
bt,homehub-v5a)
ath10k_caldata_extract_ubi "caldata" 20480 2116
ath10k_caldata_set_macaddr $(macaddr_add $(mtd_get_mac_binary_ubi caldata 4364) +3)
caldata_extract_ubi "caldata" 0x5000 0x844
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary_ubi caldata 0x110c) +3)
;;
*)
ath10k_caldata_die "board $board is not supported yet"
caldata_die "board $board is not supported yet"
;;
esac
;;
......
#!/bin/sh
# Based on ar71xx 10-ath9k-eeprom
[ -e /lib/firmware/$FIRMWARE ] && exit 0
. /lib/functions.sh
. /lib/functions/system.sh
. /lib/upgrade/nand.sh
. /lib/functions/caldata.sh
# xor multiple hex values of the same length
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_eeprom_die() {
echo "ath9k eeprom: $*"
exit 1
}
ath9k_eeprom_extract_raw() {
local source=$1
local offset=$2
local swap=$3
local size=4096
local bs=1
local conv=
if [ $swap -gt 0 ]; then
bs=2
conv="conv=swab"
size=$((size / bs))
offset=$((offset / bs))
fi
dd if=$source of=/lib/firmware/$FIRMWARE bs=$bs skip=$offset count=$size $conv 2>/dev/null || \
ath9k_eeprom_die "failed to extract from $mtd"
}
ath9k_eeprom_extract_reverse() {
caldata_extract_swap() {
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
}
ath9k_eeprom_extract() {
local part=$1
local offset=$2
local swap=$3
local mtd
mtd=$(find_mtd_chardev $part)
[ -n "$mtd" ] || \
ath9k_eeprom_die "no mtd device found for partition $part"
ath9k_eeprom_extract_raw $mtd $offset $swap
}
ath9k_ubi_eeprom_extract() {
local part=$1
local offset=$2
local swap=$3
local ubidev=$(nand_find_ubi $CI_UBIPART)
local ubi
ubi=$(nand_find_volume $ubidev $part)
[ -n "$ubi" ] || \
ath9k_eeprom_die "no UBI volume found for $part"
ath9k_eeprom_extract_raw /dev/$ubi $offset $swap
}
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}"
}
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)
[ -n "$mtd" ] || caldata_die "no mtd device found for partition $part"
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
}
offset=$(($offset / 2))
count=$(($count / 2))
macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$mac_offset count=6
dd if=$mtd of=/lib/firmware/$FIRMWARE bs=2 skip=$offset count=$count conv=swab 2>/dev/null || \
caldata_die "failed to extract calibration data from $mtd"
}
case "$FIRMWARE" in
......@@ -135,43 +28,43 @@ case "$FIRMWARE" in
case "$board" in
arcadyan,arv7518pw)
ath9k_eeprom_extract "boardconfig" 1024 1
caldata_extract_swap "boardconfig" 0x400 0x1000
;;
arcadyan,arv8539pw22)
ath9k_eeprom_extract "art" 1024 1
caldata_extract_swap "art" 0x400 0x1000
;;
bt,homehub-v2b)
ath9k_eeprom_extract "art" 0 1
ath9k_patch_fw_mac_crc "00:00:00:00:00:00" 524
caldata_extract_swap "art" 0x0 0x1000
ath9k_patch_mac_crc "00:00:00:00:00:00" 0x20c
;;
bt,homehub-v3a)
ath9k_eeprom_extract "art-copy" 0 1
ath9k_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_ascii uboot_env ethaddr) +2) 268
caldata_extract_swap "art-copy" 0x0 0x1000
ath9k_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii uboot_env ethaddr) +2) 0x10c
;;
bt,homehub-v5a)
ath9k_ubi_eeprom_extract "caldata" 4096 0
ath9k_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_binary_ubi caldata 4364) +2) 268
caldata_extract_ubi "caldata" 0x1000 0x1000
ath9k_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary_ubi caldata 0x110c) +2) 0x10c
;;
netgear,dgn3500|netgear,dgn3500b)
ath9k_eeprom_extract "calibration" 61440 0
ath9k_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_ascii uboot-env ethaddr) +2) 524
caldata_extract "calibration" 0xf000 0x1000
ath9k_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii uboot-env ethaddr) +2) 0x20c
;;
avm,fritz3370-rev2-hynix|\
avm,fritz3370-rev2-micron|\
avm,fritz7362sl)
ath9k_eeprom_extract_reverse "urlader" 5441 1088
caldata_extract_reverse "urlader" 0x1541 0x440
;;
avm,fritz7312|avm,fritz7320|avm,fritz7360sl)
ath9k_eeprom_extract "urlader" 2437 0
caldata_extract "urlader" 0x985 0x1000
;;
avm,fritz7412)
/usr/bin/fritz_cal_extract -i 1 -s 0x1e000 -e 0x207 -l 4096 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader")
;;
tplink,tdw8970|tplink,tdw8980)
ath9k_eeprom_extract "boardconfig" 135168 0
caldata_extract "boardconfig" 0x21000 0x1000
;;
*)
ath9k_eeprom_die "board $board is not supported yet"
caldata_die "board $board is not supported yet"
;;
esac
;;
......
......@@ -3,37 +3,7 @@
# Copyright (C) 2013 OpenWrt.org
#
LED_OPTIONS_CHANGED=0
. /lib/functions.sh
do_led_update_sysfs()
{
local cfg=$1; shift
local tuples="$@"
local sysfs
local name
config_get sysfs $cfg sysfs
config_get name $cfg name
[ -z "$sysfs" ] && return
for tuple in $tuples; do
local old=${tuple%=*}
local new=${tuple#*=}
local new_sysfs
new_sysfs=$(echo ${sysfs} | sed "s/${old}/${new}/")
[ "$new_sysfs" = "$sysfs" ] && continue
uci set system.${cfg}.sysfs="${new_sysfs}"
LED_OPTIONS_CHANGED=1
logger -t led-migration "sysfs option of LED \"${name}\" updated to ${new_sysfs}"
done;
}
. /lib/functions/migrations.sh
do_internet_led_rename()
{
......@@ -45,38 +15,29 @@ do_internet_led_rename()
uci rename system.led_internet=led_dsl
uci set system.led_dsl.name=dsl
LED_OPTIONS_CHANGED=1
logger -t led-migration "internet led renamed to dsl"
}
migrate_leds()
{
config_load system
config_foreach do_led_update_sysfs led "$@"
}
case "$(board_name)" in
alphanetworks,asl56026|\
arcadyan,arv452cqw|\
arcadyan,arv7510pw22|\
arcadyan,arv7519rw22|\
arcadyan,arv752dpw|\
arcadyan,arv752dpw22|\
alphanetworks,asl56026|\
arcadyan,vg3503j|\
avm,fritz7360sl|\
bt,homehub-v2b|\
bt,homehub-v3a|\
bt,homehub-v5a|\
avm,fritz7360sl|\
arcadyan,vg3503j)
bt,homehub-v5a)
do_internet_led_rename
;;
netgear,dgn3500|\
netgear,dgn3500b)
migrate_leds "dgn3500:blue:wireless=dgn3500:green:wireless"
;;
*)
;;
esac
[ "$LED_OPTIONS_CHANGED" = "1" ] && uci commit system
migrations_apply system
exit 0
#!/bin/sh
. /lib/functions.sh
. /lib/functions/lantiq.sh
IFNAME_CHANGED=0
......
#!/bin/sh
. /lib/functions/lantiq.sh
set_preinit_iface() {
ifname=eth0
}
boot_hook_add preinit_main set_preinit_iface
#!/bin/sh
FW_FILE="/lib/firmware/$FIRMWARE"
[ -e /lib/firmware/$FIRMWARE ] && exit 0
ath9k_eeprom_die() {
echo "ath9k eeprom: " "$*" >&2
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 bs=$offset skip=1 count=1 2>/dev/null | dd of=$FW_FILE bs=$count count=1 2>/dev/null || \
ath9k_eeprom_die "failed to extract from $mtd"
}
tpl_set_wireless_mac()
{
local offset=$1
local mac
mac=$(mtd_get_mac_binary u-boot 326656)
mac=$(macaddr_add $mac $offset)
macaddr_2bin $mac | dd bs=1 count=6 seek=2 conv=notrunc of=$FW_FILE 2>/dev/null
}
[ -e $FW_FILE ] && exit 0
. /lib/functions.sh
. /lib/functions/system.sh
. /lib/functions/caldata.sh
board=$(board_name)
......@@ -43,11 +10,11 @@ case "$FIRMWARE" in
"pci_wmac0.eeprom")
case $board in
tplink,tl-wdr4900-v1)
ath9k_eeprom_extract "caldata" 4096 2048
tpl_set_wireless_mac 0
caldata_extract "caldata" 0x1000 0x800
ath9k_patch_mac $(mtd_get_mac_binary u-boot 0x4fc00)
;;
*)
ath9k_eeprom_die "board $board is not supported yet"
caldata_die "board $board is not supported yet"
;;
esac
;;
......@@ -55,11 +22,11 @@ case "$FIRMWARE" in
"pci_wmac1.eeprom")
case $board in
tplink,tl-wdr4900-v1)
ath9k_eeprom_extract "caldata" 20480 2048
tpl_set_wireless_mac -1
caldata_extract "caldata" 0x5000 0x800
ath9k_patch_mac $(macaddr_add $(mtd_get_mac_binary u-boot 0x4fc00) -1)
;;
*)
ath9k_eeprom_die "board $board is not supported yet"
caldata_die "board $board is not supported yet"
;;
esac
;;
......
......@@ -3,27 +3,54 @@
# Copyright (C) 2013 OpenWrt.org
#
. /lib/functions.sh
ramips_switchdev_from_soc() {
# The ethernet switch driver enables VLAN by default, but
# failsafe uses eth0, making the device unreachable:
# https://dev.openwrt.org/ticket/18768
local switchdev
local RT3X5X=$(grep -E "(RT3.5|RT5350|MT7628|MT7688|MT7620|MT7621)" /proc/cpuinfo)
[ -n "$RT3X5X" ] || return 1
case "$RT3X5X" in
*MT7620*)
switchdev=mt7620
;;
*MT7621*)
switchdev=mt7530
;;
*)
switchdev=rt305x
;;
esac
echo "$switchdev"
}
ramips_switchdev_from_board() {
# For these devices, external ethernet switch should be used
# instead of the SoC internal switch.
local switchdev
local board=$(board_name)
case "$board" in
esac
echo "$switchdev"
}
ramips_set_preinit_iface() {
RT3X5X=$(grep -E "(RT3.5|RT5350|MT7628|MT7688|MT7620|MT7621)" /proc/cpuinfo)
if [ -n "${RT3X5X}" ]; then
# The ethernet switch driver enables VLAN by default, but
# failsafe uses eth0, making the device unreachable:
# https://dev.openwrt.org/ticket/18768
case "${RT3X5X}" in
*MT7620*)
ralink_switchdev=mt7620
;;
*MT7621*)
ralink_switchdev=mt7530
;;
*)
ralink_switchdev=rt305x
;;
esac
swconfig dev $ralink_switchdev set reset 1
swconfig dev $ralink_switchdev set enable_vlan 0
swconfig dev $ralink_switchdev set apply 1
local switchdev=$(ramips_switchdev_from_board)
[ -n "$switchdev" ] || switchdev=$(ramips_switchdev_from_soc)
if [ -n "$switchdev" ]; then
swconfig dev $switchdev set reset 1
swconfig dev $switchdev set enable_vlan 0
swconfig dev $switchdev set apply 1
fi
ifname=eth0
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册