From ecea39f109c34c289f3c25150bdd499a68a8fb9f Mon Sep 17 00:00:00 2001 From: coolsnowwolf Date: Mon, 3 Feb 2020 12:33:25 +0800 Subject: [PATCH] Revert "files: sync from openwrt v19.07 (#2690)" This reverts commit 2289184a623c4da882a376abb649969dee73654f. --- config/Config-devel.in | 7 - config/Config-images.in | 24 +- config/Config-kernel.in | 8 +- include/cmake.mk | 1 - include/debug.mk | 1 + include/download.mk | 1 - include/hardening.mk | 1 + include/image-commands.mk | 31 +- include/image.mk | 3 +- include/kernel-defaults.mk | 2 + include/kernel.mk | 8 +- include/toolchain-build.mk | 1 - include/u-boot.mk | 2 +- include/version.mk | 9 +- package/base-files/files/bin/config_generate | 29 +- package/base-files/files/etc/group | 2 +- package/base-files/files/etc/init.d/boot | 7 +- package/base-files/files/etc/init.d/umount | 7 +- package/base-files/files/etc/rc.button/reboot | 12 - .../files/etc/sysctl.d/10-default.conf | 2 - .../files/etc/uci-defaults/10_migrate-shadow | 2 + .../etc/uci-defaults/12_network-generate-ula | 3 + .../files/etc/uci-defaults/13_fix_group_user | 2 + package/base-files/files/lib/functions.sh | 25 +- .../base-files/files/lib/functions/caldata.sh | 128 -- .../files/lib/functions/migrations.sh | 39 - .../base-files/files/lib/functions/network.sh | 5 - .../base-files/files/lib/functions/system.sh | 60 +- .../files/lib/functions/uci-defaults.sh | 22 - .../files/lib/preinit/30_failsafe_wait | 5 +- package/base-files/files/sbin/hotplug-call | 2 +- package/base-files/files/sbin/wifi | 2 +- package/base-files/files/usr/lib/os-release | 16 +- package/base-files/image-config.in | 2 +- scripts/download.pl | 18 +- scripts/json_add_image_info.py | 1189 ++++++++++++++++- .../etc/hotplug.d/firmware/10-ath9k-eeprom | 61 +- .../lib/preinit/05_set_iface_mac_apm821xx | 2 +- .../ar71xx/base-files/etc/board.d/02_network | 48 - .../etc/hotplug.d/firmware/10-ath9k-eeprom | 68 +- .../etc/hotplug.d/firmware/11-ath10k-caldata | 116 +- .../etc/hotplug.d/ieee80211/10_fix_wifi_mac | 3 +- .../etc/hotplug.d/net/10-ar922x-led-fix | 3 - .../lib/preinit/05_set_iface_mac_ar71xx | 16 +- .../ipq40xx/base-files/etc/board.d/01_leds | 18 +- .../ipq40xx/base-files/etc/board.d/02_network | 26 +- .../etc/hotplug.d/firmware/11-ath10k-caldata | 168 ++- .../lib/preinit/05_set_iface_mac_ipq40xx.sh | 7 +- target/linux/ipq40xx/image/Makefile | 53 +- .../etc/hotplug.d/firmware/11-ath10k-caldata | 128 +- .../lib/preinit/05_set_ether_mac_ixp4xx | 1 + .../etc/hotplug.d/firmware/11-ath10k-caldata | 37 +- .../etc/hotplug.d/firmware/12-ath9k-eeprom | 149 ++- .../etc/uci-defaults/01_led_migration | 51 +- .../etc/uci-defaults/02_migrate_xdsl_iface | 1 + .../lib/preinit/05_set_preinit_iface_lantiq | 3 + .../etc/hotplug.d/firmware/10-ath9k-eeprom | 49 +- .../lib/preinit/07_set_preinit_iface_ramips | 65 +- 58 files changed, 1951 insertions(+), 800 deletions(-) delete mode 100755 package/base-files/files/etc/rc.button/reboot delete mode 100644 package/base-files/files/lib/functions/caldata.sh delete mode 100644 package/base-files/files/lib/functions/migrations.sh mode change 100755 => 100644 scripts/json_add_image_info.py diff --git a/config/Config-devel.in b/config/Config-devel.in index 70ec0ce9a..fd7c3ead1 100644 --- a/config/Config-devel.in +++ b/config/Config-devel.in @@ -105,13 +105,6 @@ 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 diff --git a/config/Config-images.in b/config/Config-images.in index d93f9c2e5..2bfa6bc53 100644 --- a/config/Config-images.in +++ b/config/Config-images.in @@ -14,12 +14,11 @@ menu "Target Images" choice prompt "Compression" - default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_apm821xx 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_LZMA if TARGET_apm821xx + default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_mpc85xx + default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_ipq40xx default TARGET_INITRAMFS_COMPRESSION_NONE depends on TARGET_ROOTFS_INITRAMFS help @@ -195,7 +194,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 @@ -255,7 +254,6 @@ 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)" @@ -264,22 +262,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 - default n - + select PACKAGE_kmod-tulip + 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 - default n + select PACKAGE_kmod-e1000 config TARGET_IMAGES_PAD bool "Pad images to filesystem size (for JFFS2)" @@ -288,7 +286,7 @@ menu "Target Images" config TARGET_IMAGES_GZIP bool "GZip images" - depends on TARGET_ROOTFS_EXT4FS || TARGET_x86 || TARGET_armvirt || TARGET_malta + depends on TARGET_IMAGES_PAD || TARGET_ROOTFS_EXT4FS || TARGET_x86 default n comment "Image Options" diff --git a/config/Config-kernel.in b/config/Config-kernel.in index 4aa7e2bdb..9a82b9ecc 100644 --- a/config/Config-kernel.in +++ b/config/Config-kernel.in @@ -46,7 +46,7 @@ config KERNEL_DEBUG_FS config KERNEL_MIPS_FPU_EMULATOR bool "Compile the kernel with MIPS FPU Emulator" - default y if TARGET_pistachio + default y depends on (mips || mipsel || mips64 || mips64el) config KERNEL_ARM_PMU @@ -596,7 +596,7 @@ endif config KERNEL_NAMESPACES bool "Enable kernel namespaces" - default y if !SMALL_FLASH + default n if KERNEL_NAMESPACES @@ -665,13 +665,13 @@ config KERNEL_POSIX_MQUEUE config KERNEL_SECCOMP_FILTER bool - default y if !SMALL_FLASH + default n config KERNEL_SECCOMP bool "Enable seccomp support" depends on !(TARGET_uml) select KERNEL_SECCOMP_FILTER - default y if !SMALL_FLASH + default n help Build kernel with support for seccomp. diff --git a/include/cmake.mk b/include/cmake.mk index a5ba7d31b..b66665d20 100644 --- a/include/cmake.mk +++ b/include/cmake.mk @@ -103,7 +103,6 @@ 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) \ ) diff --git a/include/debug.mk b/include/debug.mk index 0cedb9cec..59a99c0f7 100644 --- a/include/debug.mk +++ b/include/debug.mk @@ -48,3 +48,4 @@ debug_eval:= warn_eval = $(4) endif + diff --git a/include/download.mk b/include/download.mk index a020273e8..33141910f 100644 --- a/include/download.mk +++ b/include/download.mk @@ -288,7 +288,6 @@ 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))) diff --git a/include/hardening.mk b/include/hardening.mk index 3a065aeea..4e49e6b1b 100644 --- a/include/hardening.mk +++ b/include/hardening.mk @@ -61,3 +61,4 @@ ifdef CONFIG_PKG_RELRO_FULL TARGET_LDFLAGS += -znow -zrelro endif endif + diff --git a/include/image-commands.mk b/include/image-commands.mk index 4cf129372..5dfd6a2c2 100644 --- a/include/image-commands.mk +++ b/include/image-commands.mk @@ -3,10 +3,6 @@ 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 \ @@ -275,13 +271,6 @@ 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)" \ @@ -319,7 +308,7 @@ endef define Build/qsdk-ipq-factory-nor $(TOPDIR)/scripts/mkits-qsdk-ipq-image.sh \ - $@.its kernel $(IMAGE_KERNEL) rootfs $(IMAGE_ROOTFS) + $@.its hlos $(IMAGE_KERNEL) rootfs $(IMAGE_ROOTFS) PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $@.its $@.new @mv $@.new $@ endef @@ -346,24 +335,6 @@ define Build/tplink-v1-header @mv $@.new $@ endef -# combine kernel and rootfs into one image -# mktplinkfw -# is "sysupgrade" or "factory" -# -# -a align the rootfs start on an bytes boundary -# -j add jffs2 end-of-filesystem markers -# -s strip padding from end of the image -# -X reserve 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) \ diff --git a/include/image.mk b/include/image.mk index 26da4d681..8592c19b9 100644 --- a/include/image.mk +++ b/include/image.mk @@ -420,7 +420,6 @@ define Device/Init DEVICE_DTS := DEVICE_DTS_CONFIG := DEVICE_DTS_DIR := - SOC := BOARD_NAME := UIMAGE_NAME := @@ -438,7 +437,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 SOC BOARD_NAME UIMAGE_NAME SUPPORTED_DEVICES \ + DEVICE_DTS_CONFIG DEVICE_DTS_DIR 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 \ diff --git a/include/kernel-defaults.mk b/include/kernel-defaults.mk index 6ae68d918..cc1e2361b 100644 --- a/include/kernel-defaults.mk +++ b/include/kernel-defaults.mk @@ -160,3 +160,5 @@ define Kernel/Clean/Default rm -f $(LINUX_KERNEL) $(_SINGLE)$(MAKE) -C $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) clean endef + + diff --git a/include/kernel.mk b/include/kernel.mk index deaac7e88..19ecf4fa9 100644 --- a/include/kernel.mk +++ b/include/kernel.mk @@ -104,7 +104,6 @@ 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)" \ @@ -114,7 +113,6 @@ 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)) \ @@ -131,11 +129,6 @@ 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 @@ -301,3 +294,4 @@ 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)) + diff --git a/include/toolchain-build.mk b/include/toolchain-build.mk index 35d8c9380..883d74d25 100644 --- a/include/toolchain-build.mk +++ b/include/toolchain-build.mk @@ -12,7 +12,6 @@ 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 diff --git a/include/u-boot.mk b/include/u-boot.mk index 9ba9c5096..babb76497 100644 --- a/include/u-boot.mk +++ b/include/u-boot.mk @@ -3,7 +3,7 @@ PKG_NAME ?= u-boot ifndef PKG_SOURCE_PROTO PKG_SOURCE = $(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL = \ - https://sources.openwrt.org \ + http://sources.lede-project.org \ ftp://ftp.denx.de/pub/u-boot endif diff --git a/include/version.mk b/include/version.mk index 32483c101..8ef0a7e65 100644 --- a/include/version.mk +++ b/include/version.mk @@ -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),https://openwrt.org/) +VERSION_MANUFACTURER_URL:=$(if $(VERSION_MANUFACTURER_URL),$(VERSION_MANUFACTURER_URL),http://openwrt.org/) VERSION_BUG_URL:=$(call qstrip,$(CONFIG_VERSION_BUG_URL)) -VERSION_BUG_URL:=$(if $(VERSION_BUG_URL),$(VERSION_BUG_URL),https://bugs.openwrt.org/) +VERSION_BUG_URL:=$(if $(VERSION_BUG_URL),$(VERSION_BUG_URL),http://bugs.openwrt.org/) VERSION_HOME_URL:=$(call qstrip,$(CONFIG_VERSION_HOME_URL)) -VERSION_HOME_URL:=$(if $(VERSION_HOME_URL),$(VERSION_HOME_URL),https://openwrt.org/) +VERSION_HOME_URL:=$(if $(VERSION_HOME_URL),$(VERSION_HOME_URL),http://openwrt.org/) VERSION_SUPPORT_URL:=$(call qstrip,$(CONFIG_VERSION_SUPPORT_URL)) -VERSION_SUPPORT_URL:=$(if $(VERSION_SUPPORT_URL),$(VERSION_SUPPORT_URL),https://forum.openwrt.org/) +VERSION_SUPPORT_URL:=$(if $(VERSION_SUPPORT_URL),$(VERSION_SUPPORT_URL),http://forum.lede-project.org/) VERSION_PRODUCT:=$(call qstrip,$(CONFIG_VERSION_PRODUCT)) VERSION_PRODUCT:=$(if $(VERSION_PRODUCT),$(VERSION_PRODUCT),Generic) @@ -108,3 +108,4 @@ 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' + diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate index 1c0334475..df221cc26 100755 --- a/package/base-files/files/bin/config_generate +++ b/package/base-files/files/bin/config_generate @@ -85,16 +85,12 @@ generate_network() { set network.$1.proto='none' 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 + [ -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 case "$protocol" in static) @@ -217,8 +213,7 @@ generate_switch() { json_select switch json_select "$key" - json_get_vars enable reset blinkrate cpu_port \ - ar8xxx_mib_type ar8xxx_mib_poll_interval + json_get_vars enable reset blinkrate cpu_port uci -q batch <<-EOF add network switch @@ -226,8 +221,6 @@ 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" @@ -251,10 +244,10 @@ generate_static_system() { set system.ntp='timeserver' set system.ntp.enabled='1' set system.ntp.enable_server='0' - 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' + 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' EOF if json_is_a system object; then diff --git a/package/base-files/files/etc/group b/package/base-files/files/etc/group index 5b06dc6db..e8e2adf4a 100644 --- a/package/base-files/files/etc/group +++ b/package/base-files/files/etc/group @@ -1,8 +1,8 @@ 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: diff --git a/package/base-files/files/etc/init.d/boot b/package/base-files/files/etc/init.d/boot index 44311c9e2..31f245ffc 100755 --- a/package/base-files/files/etc/init.d/boot +++ b/package/base-files/files/etc/init.d/boot @@ -2,7 +2,7 @@ # Copyright (C) 2006-2011 OpenWrt.org START=10 -STOP=90 +STOP=98 uci_apply_defaults() { . /lib/functions/system.sh @@ -31,9 +31,8 @@ boot() { chmod 0700 /tmp/.uci touch /var/log/wtmp touch /var/log/lastlog - 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 + touch /tmp/resolv.conf.auto + ln -sf /tmp/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 diff --git a/package/base-files/files/etc/init.d/umount b/package/base-files/files/etc/init.d/umount index b764ae158..349b2b326 100755 --- a/package/base-files/files/etc/init.d/umount +++ b/package/base-files/files/etc/init.d/umount @@ -1,12 +1,7 @@ #!/bin/sh /etc/rc.common # Copyright (C) 2006 OpenWrt.org -STOP=90 - -restart() { - : -} - +STOP=99 stop() { sync /bin/umount -a -d -r diff --git a/package/base-files/files/etc/rc.button/reboot b/package/base-files/files/etc/rc.button/reboot deleted file mode 100755 index cd547e332..000000000 --- a/package/base-files/files/etc/rc.button/reboot +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -[ "${ACTION}" = "released" ] || exit 0 - -if [ "$SEEN" -ge 5 ] -then - echo "REBOOT" > /dev/console - sync - reboot -fi - -return 0 diff --git a/package/base-files/files/etc/sysctl.d/10-default.conf b/package/base-files/files/etc/sysctl.d/10-default.conf index bc8c57969..46d079b36 100644 --- a/package/base-files/files/etc/sysctl.d/10-default.conf +++ b/package/base-files/files/etc/sysctl.d/10-default.conf @@ -8,8 +8,6 @@ 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 diff --git a/package/base-files/files/etc/uci-defaults/10_migrate-shadow b/package/base-files/files/etc/uci-defaults/10_migrate-shadow index 481444f35..a354844fe 100644 --- a/package/base-files/files/etc/uci-defaults/10_migrate-shadow +++ b/package/base-files/files/etc/uci-defaults/10_migrate-shadow @@ -1,3 +1,5 @@ +#!/bin/sh + ppwd="$(sed -ne '/^root:/s/^root:\([^:]*\):.*$/\1/p' /etc/passwd)" spwd="$(sed -ne '/^root:/s/^root:\([^:]*\):.*$/\1/p' /etc/shadow)" diff --git a/package/base-files/files/etc/uci-defaults/12_network-generate-ula b/package/base-files/files/etc/uci-defaults/12_network-generate-ula index e780365ab..8871427c6 100644 --- a/package/base-files/files/etc/uci-defaults/12_network-generate-ula +++ b/package/base-files/files/etc/uci-defaults/12_network-generate-ula @@ -1,3 +1,5 @@ +#!/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"') @@ -10,3 +12,4 @@ uci -q batch <<-EOF >/dev/null EOF exit 0 + diff --git a/package/base-files/files/etc/uci-defaults/13_fix_group_user b/package/base-files/files/etc/uci-defaults/13_fix_group_user index bf9febdfe..e6dae2419 100644 --- a/package/base-files/files/etc/uci-defaults/13_fix_group_user +++ b/package/base-files/files/etc/uci-defaults/13_fix_group_user @@ -1,3 +1,5 @@ +#!/bin/sh + . /lib/functions.sh for file in `grep -sl Require-User /usr/lib/opkg/info/*.control`; do diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh index e965cfc40..50a7b4086 100755 --- a/package/base-files/files/lib/functions.sh +++ b/package/base-files/files/lib/functions.sh @@ -17,22 +17,6 @@ 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" @@ -229,7 +213,6 @@ 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}" @@ -244,14 +227,14 @@ default_postinst() { rm -fR $root/rootfs-overlay/ fi - if [ -z "$root" ] && grep -q -s "^/etc/modules.d/" "$filelist"; then + if [ -z "$root" ] && grep -q -s "^/etc/modules.d/" "/usr/lib/opkg/info/${pkgname}.list"; then kmodloader fi - if [ -z "$root" ] && grep -q -s "^/etc/uci-defaults/" "$filelist"; then + if [ -z "$root" ] && grep -q -s "^/etc/uci-defaults/" "/usr/lib/opkg/info/${pkgname}.list"; then . /lib/functions/system.sh [ -d /tmp/.uci ] || mkdir -p /tmp/.uci - for i in $(grep -s "^/etc/uci-defaults/" "$filelist"); do + for i in $(grep -s "^/etc/uci-defaults/" "/usr/lib/opkg/info/${pkgname}.list"); do ( [ -f "$i" ] && cd "$(dirname $i)" && . "$i" ) && rm -f "$i" done uci commit @@ -260,7 +243,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$filelist"); do + for i in $(grep -s "^/etc/init.d/" "$root/usr/lib/opkg/info/${pkgname}.list"); do if [ -n "$root" ]; then ${shell:-/bin/sh} "$root/etc/rc.common" "$root$i" enable else diff --git a/package/base-files/files/lib/functions/caldata.sh b/package/base-files/files/lib/functions/caldata.sh deleted file mode 100644 index 3bdb1e4dd..000000000 --- a/package/base-files/files/lib/functions/caldata.sh +++ /dev/null @@ -1,128 +0,0 @@ -# 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 -} diff --git a/package/base-files/files/lib/functions/migrations.sh b/package/base-files/files/lib/functions/migrations.sh deleted file mode 100644 index b180a0242..000000000 --- a/package/base-files/files/lib/functions/migrations.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/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} -} diff --git a/package/base-files/files/lib/functions/network.sh b/package/base-files/files/lib/functions/network.sh index 6b946b9f8..4fdcb6630 100644 --- a/package/base-files/files/lib/functions/network.sh +++ b/package/base-files/files/lib/functions/network.sh @@ -271,11 +271,6 @@ 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 diff --git a/package/base-files/files/lib/functions/system.sh b/package/base-files/files/lib/functions/system.sh index c9f8eb0c3..7ed62804a 100644 --- a/package/base-files/files/lib/functions/system.sh +++ b/package/base-files/files/lib/functions/system.sh @@ -1,12 +1,10 @@ # Copyright (C) 2006-2013 OpenWrt.org -. /usr/share/libubox/jshn.sh - get_mac_binary() { local path="$1" local offset="$2" - if ! [ -e "$path" ]; then + if [ -z "$path" ]; then echo "get_mac_binary: file $path not found!" >&2 return fi @@ -14,44 +12,6 @@ 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 @@ -80,7 +40,7 @@ mtd_get_mac_ascii() { mtd_get_mac_text() { local mtdname=$1 - local offset=$(($2)) + local offset=$2 local part local mac_dirty @@ -119,7 +79,12 @@ mtd_get_mac_binary_ubi() { local ubidev=$(nand_find_ubi $CI_UBIPART) local part=$(nand_find_volume $ubidev $1) - get_mac_binary "/dev/$part" "$offset" + 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 } mtd_get_part_size() { @@ -140,17 +105,10 @@ 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 diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh index c2c6dc3fd..315df7b70 100755 --- a/package/base-files/files/lib/functions/uci-defaults.sh +++ b/package/base-files/files/lib/functions/uci-defaults.sh @@ -182,19 +182,6 @@ _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 @@ -307,14 +294,6 @@ 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" @@ -484,7 +463,6 @@ _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" diff --git a/package/base-files/files/lib/preinit/30_failsafe_wait b/package/base-files/files/lib/preinit/30_failsafe_wait index 85dca398f..dd9c7e2b5 100644 --- a/package/base-files/files/lib/preinit/30_failsafe_wait +++ b/package/base-files/files/lib/preinit/30_failsafe_wait @@ -31,8 +31,6 @@ 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 @@ -90,6 +88,9 @@ 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 diff --git a/package/base-files/files/sbin/hotplug-call b/package/base-files/files/sbin/hotplug-call index f595b9e75..829fdbd75 100755 --- a/package/base-files/files/sbin/hotplug-call +++ b/package/base-files/files/sbin/hotplug-call @@ -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 +fi \ No newline at end of file diff --git a/package/base-files/files/sbin/wifi b/package/base-files/files/sbin/wifi index a8b4451c6..261d2fb50 100755 --- a/package/base-files/files/sbin/wifi +++ b/package/base-files/files/sbin/wifi @@ -6,7 +6,7 @@ usage() { cat < + + + + + + + + + + -if not os.path.exists(json_path): - device_info = { - "id": e("DEVICE_ID"), - "image_prefix": e("IMAGE_PREFIX"), - "images": [], - "metadata_version": 1, - "supported_devices": e("SUPPORTED_DEVICES").split(), - "target": "{}/{}".format(e("TARGET"), e("SUBTARGET", "generic")), - "titles": get_titles(), - "version_commit": e("VERSION_CODE"), - "version_number": e("VERSION_NUMBER"), + + + + + + + + + + + + openwrt/json_add_image_info.py at master · openwrt/openwrt · GitHub + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Skip to content + + + + + + + + + + + +
+ +
+ + +
+ +
+ + + +
+
+
+ + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + Permalink + + + + + +
+ + +
+ + Branch: + master + + + + + + + +
+ +
+ + Find file + + + Copy path + +
+
+ + +
+ + Find file + + + Copy path + +
+
+ + + + +
+
+ + @aparcar + aparcar + + build: create JSON files containing image info + + + + 881ed09 + Sep 29, 2019 + +
+ +
+
+ + 1 contributor + + +
+ +

+ Users who have contributed to this file +

+
+ +
+
+
+
+ + + + + +
+ +
+
+ + executable file + + 56 lines (40 sloc) + + 1.53 KB +
+ +
+ +
+ Raw + Blame + History +
+ + +
+ + + +
+
+
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#!/usr/bin/env python3
+
import json
import os
import hashlib
+
+
def e(variable, default=None):
return os.environ.get(variable, default)
+
+
json_path = "{}{}{}.json".format(e("BIN_DIR"), os.sep, e("IMAGE_PREFIX"))
+
with open(os.path.join(e("BIN_DIR"), e("IMAGE_NAME")), "rb") as image_file:
image_hash = hashlib.sha256(image_file.read()).hexdigest()
+
+
def get_titles():
titles = []
for prefix in ["", "ALT0_", "ALT1_", "ALT2_"]:
title = {}
for var in ["vendor", "model", "variant"]:
if e("DEVICE_{}{}".format(prefix, var.upper())):
title[var] = e("DEVICE_{}{}".format(prefix, var.upper()))
+
if title:
titles.append(title)
+
if not titles:
titles.append({"title": e("DEVICE_TITLE")})
+
return titles
+
+
if not os.path.exists(json_path):
device_info = {
"id": e("DEVICE_ID"),
"image_prefix": e("IMAGE_PREFIX"),
"images": [],
"metadata_version": 1,
"supported_devices": e("SUPPORTED_DEVICES").split(),
"target": "{}/{}".format(e("TARGET"), e("SUBTARGET", "generic")),
"titles": get_titles(),
"version_commit": e("VERSION_CODE"),
"version_number": e("VERSION_NUMBER"),
}
else:
with open(json_path, "r") as json_file:
device_info = json.load(json_file)
+
image_info = {"type": e("IMAGE_TYPE"), "name": e("IMAGE_NAME"), "sha256": image_hash}
device_info["images"].append(image_info)
+
with open(json_path, "w") as json_file:
json.dump(device_info, json_file, sort_keys=True, indent=" ")
+ + + +
+ +
+ + + +
+ + +
+ + +
+
+ + + +
+
+ +
+
+ + +
+ + + + + + +
+ + + You can’t perform that action at this time. +
+ + + + + + + + + + + + + + +
+ + + -with open(json_path, "w") as json_file: - json.dump(device_info, json_file, sort_keys=True, indent=" ") diff --git a/target/linux/apm821xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/apm821xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom index ee58901d1..6d2d18658 100644 --- a/target/linux/apm821xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom +++ b/target/linux/apm821xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom @@ -2,7 +2,50 @@ [ -e /lib/firmware/$FIRMWARE ] && exit 0 -. /lib/functions/caldata.sh +. /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 +} board=$(board_name) @@ -13,14 +56,14 @@ case "$FIRMWARE" in . /lib/upgrade/nand.sh if [ -n "$(nand_find_volume ubi0 caldata)" ]; then - caldata_extract_ubi "caldata" 0x5000 0x1000 + ath9k_ubi_eeprom_extract "caldata" 20480 4096 else - caldata_extract "wifi_data" 0x5000 0x1000 - ath9k_patch_mac $(mtd_get_mac_binary wifi_data 0xc) + ath9k_eeprom_extract "wifi_data" 20480 4096 + ath9k_patch_firmware_mac $(mtd_get_mac_binary wifi_data 12) fi ;; *) - caldata_die "board $board is not supported yet" + ath9k_eeprom_die "board $board is not supported yet" ;; esac ;; @@ -31,14 +74,14 @@ case "$FIRMWARE" in . /lib/upgrade/nand.sh if [ -n "$(nand_find_volume ubi0 caldata)" ]; then - caldata_extract_ubi "caldata" 0x1000 0x1000 + ath9k_ubi_eeprom_extract "caldata" 4096 4096 else - caldata_extract "wifi_data" 0x1000 0x1000 - ath9k_patch_mac $(mtd_get_mac_binary wifi_data 0x0) + ath9k_eeprom_extract "wifi_data" 4096 4096 + ath9k_patch_firmware_mac $(mtd_get_mac_binary wifi_data 0) fi ;; *) - caldata_die "board $board is not supported yet" + ath9k_eeprom_die "board $board is not supported yet" ;; esac ;; diff --git a/target/linux/apm821xx/base-files/lib/preinit/05_set_iface_mac_apm821xx b/target/linux/apm821xx/base-files/lib/preinit/05_set_iface_mac_apm821xx index 11955dd5a..1a27930d2 100644 --- a/target/linux/apm821xx/base-files/lib/preinit/05_set_iface_mac_apm821xx +++ b/target/linux/apm821xx/base-files/lib/preinit/05_set_iface_mac_apm821xx @@ -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 0x66) + mac_lan=$(mtd_get_mac_binary_ubi board-config 102) [ -n "$mac_lan" ] && ifconfig eth0 hw ether "$mac_lan" ;; esac diff --git a/target/linux/ar71xx/base-files/etc/board.d/02_network b/target/linux/ar71xx/base-files/etc/board.d/02_network index 4da3a5482..b83f79333 100755 --- a/target/linux/ar71xx/base-files/etc/board.d/02_network +++ b/target/linux/ar71xx/base-files/etc/board.d/02_network @@ -650,58 +650,10 @@ 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 diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom index d23a307f2..52c9f29c0 100644 --- a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom +++ b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom @@ -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" 0x1000 0x800 - ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary art 0x0) +1) + ath9k_eeprom_extract "art" 4096 2048 + ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary art 0) +1) ;; fritz4020|\ fritz450e) - ath9k_eeprom_extract_reverse "urlader" 0x1541 0x440 + ath9k_eeprom_extract_reverse "urlader" 5441 1088 ;; k2t) - ath9k_eeprom_extract "art" 0x1000 0x800 + ath9k_eeprom_extract "art" 4096 2048 ath9k_patch_firmware_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +3) ;; sbr-ac1750) - ath9k_eeprom_extract "art" 0x1000 0x800 + ath9k_eeprom_extract "art" 4096 2048 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" 0x1000 0x800 + ath9k_ubi_eeprom_extract "caldata" 4096 2048 else - ath9k_eeprom_extract "odm-caldata" 0x1000 0x800 + ath9k_eeprom_extract "odm-caldata" 4096 2048 fi - ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 0x66) +1) + ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 102) +1) ;; r6100 | \ wndr3700v4 | \ wndr4300) - ath9k_eeprom_extract "caldata" 0x1000 0x800 - ath9k_patch_firmware_mac $(mtd_get_mac_binary caldata 0x0) + ath9k_eeprom_extract "caldata" 4096 2048 + ath9k_patch_firmware_mac $(mtd_get_mac_binary caldata 0) ;; rambutan) - ath9k_eeprom_extract "art" 0x1000 0x800 + ath9k_eeprom_extract "art" 4096 2048 ;; wlr8100) - ath9k_eeprom_extract "art" 0x1000 0x800 + ath9k_eeprom_extract "art" 4096 2048 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" 0x1000 0x800 + ath9k_ubi_eeprom_extract "caldata" 4096 2048 else - ath9k_eeprom_extract "origcaldata" 0x1000 0x800 + ath9k_eeprom_extract "origcaldata" 4096 2048 fi - ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 0x66) +2) + ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 102) +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" 0x5000 0x800 - ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary art 0x0) +2) + ath9k_eeprom_extract "art" 20480 2048 + ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary art 0) +2) ;; fritz300e) - ath9k_eeprom_extract_reverse "urloader" 0x1541 0x440 + ath9k_eeprom_extract_reverse "urloader" 5441 1088 ;; mr18) . /lib/upgrade/nand.sh if [ -n "$(nand_find_volume ubi0 caldata)" ]; then - ath9k_ubi_eeprom_extract "caldata" 0x1541 0x440 + ath9k_ubi_eeprom_extract "caldata" 20480 2048 else - ath9k_eeprom_extract "odm-caldata" 0x5000 0x800 + ath9k_eeprom_extract "odm-caldata" 20480 2048 fi - ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 0x66) +2) + ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 102) +2) ;; wndr3700v4 | \ wndr4300) - ath9k_eeprom_extract "caldata" 0x5000 0x800 - ath9k_patch_firmware_mac $(mtd_get_mac_binary caldata 0xc) + ath9k_eeprom_extract "caldata" 20480 2048 + ath9k_patch_firmware_mac $(mtd_get_mac_binary caldata 12) ;; z1) . /lib/upgrade/nand.sh if [ -n "$(nand_find_volume ubi0 caldata)" ]; then - ath9k_ubi_eeprom_extract "caldata" 0x15000 0x1000 + ath9k_ubi_eeprom_extract "caldata" 86016 4096 else - ath9k_eeprom_extract "origcaldata" 0x15000 0x1000 + ath9k_eeprom_extract "origcaldata" 86016 4096 fi - ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 0x66) +3) + ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 102) +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" 0x9000 0x800 + ath9k_ubi_eeprom_extract "caldata" 36864 2048 else - ath9k_eeprom_extract "odm-caldata" 0x9000 0x800 + ath9k_eeprom_extract "odm-caldata" 36864 2048 fi - ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 0x66) +3) + ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 102) +3) ;; *) ath9k_eeprom_die "board $board is not supported yet" diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index dc805a7f4..af6c976d3 100644 --- a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -1,5 +1,21 @@ #!/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 @@ -7,8 +23,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" @@ -16,8 +32,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) @@ -39,7 +55,30 @@ ath10kcal_patch_mac() { [ -z "$mac" ] && return - macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc oflag=seek_bytes bs=6 seek=6 count=1 + 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 + } } [ -e /lib/firmware/$FIRMWARE ] && exit 0 @@ -57,17 +96,17 @@ case "$FIRMWARE" in mr1750|\ mr1750v2|\ om5p-acv2) - ath10kcal_extract "ART" 0x5000 0x844 + ath10kcal_extract "ART" 20480 2116 ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +16) ;; archer-c25-v1|\ tl-wdr6500-v2) - ath10kcal_extract "art" 0x5000 0x844 + ath10kcal_extract "art" 20480 2116 ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) -2) ;; archer-c7-v4|\ archer-c7-v5) - ath10kcal_extract "art" 0x5000 0x844 + ath10kcal_extract "art" 20480 2116 ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -1) ;; cf-e355ac-v1|\ @@ -80,64 +119,64 @@ case "$FIRMWARE" in oolite-v5.2-dev|\ sr3200|\ xd3200) - ath10kcal_extract "art" 0x5000 0x844 + ath10kcal_extract "art" 20480 2116 ;; dap-2695-a1) - ath10kcal_extract "radiocfg" 0x5000 0x844 + ath10kcal_extract "radiocfg" 20480 2116 ath10kcal_patch_mac $(mtd_get_mac_ascii bdcfg wlanmac_a) ;; dir-869-a1|\ qihoo-c301) - ath10kcal_extract "radiocfg" 0x5000 0x844 + ath10kcal_extract "radiocfg" 20480 2116 ath10kcal_patch_mac $(mtd_get_mac_ascii devdata wlan5mac) ;; dw33d) - ath10kcal_extract "art" 0x5000 0x844 - ath10kcal_patch_mac $(mtd_get_mac_binary art 0x12) + ath10kcal_extract "art" 20480 2116 + ath10kcal_patch_mac $(mtd_get_mac_binary art 18) ;; sbr-ac1750) - ath10kcal_extract "art" 0x5000 0x844 - ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) +1) + ath10kcal_extract "art" 20480 2116 + ath10kcal_patch_mac_crc $(macaddr_add $(cat /sys/class/net/eth1/address) +1) ;; epg5000|\ esr1750) - ath10kcal_extract "caldata" 0x5000 0x844 + ath10kcal_extract "caldata" 20480 2116 ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +1) ;; gl-ar750s|\ gl-ar750|\ tl-wpa8630) - ath10kcal_extract "art" 0x5000 0x844 + ath10kcal_extract "art" 20480 2116 ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +1) ;; koala) - ath10kcal_extract "art" 0x5000 0x844 - ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0xc) +0) + ath10kcal_extract "art" 20480 2116 + ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary art 12) +0) ;; mc-mac1200r) - ath10kcal_extract "art" 0x5000 0x844 + ath10kcal_extract "art" 20480 2116 ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) -1) ;; r6100) - ath10kcal_extract "caldata" 0x5000 0x844 + ath10kcal_extract "caldata" 20480 2116 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" 0x5000 0x844 + ath10kcal_from_file "/sys/firmware/routerboot/ext_wlan_data" 20480 2116 ;; re355|\ re450|\ tl-wr902ac-v1) - ath10kcal_extract "art" 0x5000 0x844 + ath10kcal_extract "art" 20480 2116 ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -2) ;; unifiac-lite|\ unifiac-pro) - ath10kcal_extract "EEPROM" 0x5000 0x844 + ath10kcal_extract "EEPROM" 20480 2116 ;; wi2a-ac200i) - ath10kcal_extract "ART" 0x5000 0x844 + ath10kcal_extract "ART" 20480 2116 ;; esac ;; @@ -145,25 +184,25 @@ case "$FIRMWARE" in case $board in archer-c5|\ archer-c7) - ath10kcal_extract "art" 0x5000 0x844 + ath10kcal_extract "art" 20480 2116 ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) -2) ;; nbg6616|\ nbg6716) - ath10kcal_extract "RFdata" 0x5000 0x844 + ath10kcal_extract "RFdata" 20480 2116 ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) -2) ;; om5p-ac) - ath10kcal_extract "ART" 0x5000 0x844 + ath10kcal_extract "ART" 20480 2116 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" 0x5000 0x844 + ath10kcal_from_file "/sys/firmware/routerboot/ext_wlan_data" 20480 2116 ;; wlr8100) - ath10kcal_extract "art" 0x5000 0x844 + ath10kcal_extract "art" 20480 2116 ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) +1) ;; esac @@ -174,29 +213,24 @@ case "$FIRMWARE" in archer-c59-v1|\ archer-c59-v2|\ archer-c60-v1|\ + archer-c60-v2|\ cf-e355ac-v2|\ cf-e375ac) - ath10kcal_extract "art" 0x5000 0x2f20 + ath10kcal_extract "art" 20480 12064 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" 0x5000 0x2f20 + ath10kcal_extract "art" 20480 12064 ;; k2t) - ath10kcal_extract "art" 0x5000 0x2f20 + ath10kcal_extract "art" 20480 12064 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" 0x2000 0x2f20 + tl-wdr6500-v6) + ath10kcal_extract "art" 8192 12064 ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \ /lib/firmware/ath10k/QCA9888/hw2.0/board.bin ;; diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ar71xx/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac index f97f5ac72..a9cb69e7d 100644 --- a/target/linux/ar71xx/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac +++ b/target/linux/ar71xx/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac @@ -17,7 +17,7 @@ case "$board" in archer-c59-v2|\ archer-c60-v1|\ archer-c60-v2) - echo $(macaddr_add $(mtd_get_mac_binary mac 0x8) $(($PHYNBR - 1)) ) > /sys${DEVPATH}/macaddress + echo $(macaddr_add $(mtd_get_mac_binary mac 8) $(($PHYNBR - 1)) ) > /sys${DEVPATH}/macaddress ;; tl-wdr6500-v6) echo $(macaddr_add $(mtd_get_mac_binary art 2061) $(($PHYNBR - 2)) ) > /sys${DEVPATH}/macaddress @@ -25,3 +25,4 @@ case "$board" in *) ;; esac + diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/net/10-ar922x-led-fix b/target/linux/ar71xx/base-files/etc/hotplug.d/net/10-ar922x-led-fix index bd1abb968..c41d4b08f 100644 --- a/target/linux/ar71xx/base-files/etc/hotplug.d/net/10-ar922x-led-fix +++ b/target/linux/ar71xx/base-files/etc/hotplug.d/net/10-ar922x-led-fix @@ -12,9 +12,6 @@ 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 diff --git a/target/linux/ar71xx/base-files/lib/preinit/05_set_iface_mac_ar71xx b/target/linux/ar71xx/base-files/lib/preinit/05_set_iface_mac_ar71xx index 6fba60777..de45a817e 100644 --- a/target/linux/ar71xx/base-files/lib/preinit/05_set_iface_mac_ar71xx +++ b/target/linux/ar71xx/base-files/lib/preinit/05_set_iface_mac_ar71xx @@ -24,7 +24,7 @@ preinit_set_mac_address() { case $(board_name) in c-55|\ c-60) - mac_lan=$(mtd_get_mac_binary art 0x0) + mac_lan=$(mtd_get_mac_binary art 0) [ -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 0x66) + mac_lan=$(mtd_get_mac_binary_ubi board-config 102) [ -n "$mac_lan" ] && ifconfig eth0 hw ether "$mac_lan" ;; r6100) - mac_lan=$(mtd_get_mac_binary caldata 0x0) + mac_lan=$(mtd_get_mac_binary caldata 0) [ -n "$mac_lan" ] && ifconfig eth1 hw ether "$mac_lan" - mac_wan=$(mtd_get_mac_binary caldata 0x6) + mac_wan=$(mtd_get_mac_binary caldata 6) [ -n "$mac_wan" ] && ifconfig eth0 hw ether "$mac_wan" ;; rambutan) - mac_lan=$(mtd_get_mac_binary art 0x0) + mac_lan=$(mtd_get_mac_binary art 0) [ -n "$mac_lan" ] && ifconfig eth0 hw ether "$mac_lan" - mac_wan=$(mtd_get_mac_binary art 0x6) + mac_wan=$(mtd_get_mac_binary art 6) [ -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 0x0) + mac_lan=$(mtd_get_mac_binary ft 0) [ -n "$mac_lan" ] && ifconfig eth1 hw ether "$mac_lan" - mac_wan=$(mtd_get_mac_binary ft 0x12) + mac_wan=$(mtd_get_mac_binary ft 18) [ -n "$mac_wan" ] && ifconfig eth0 hw ether "$mac_wan" ;; esac diff --git a/target/linux/ipq40xx/base-files/etc/board.d/01_leds b/target/linux/ipq40xx/base-files/etc/board.d/01_leds index fb18db950..da794ae03 100755 --- a/target/linux/ipq40xx/base-files/etc/board.d/01_leds +++ b/target/linux/ipq40xx/base-files/etc/board.d/01_leds @@ -11,6 +11,11 @@ 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" @@ -41,20 +46,15 @@ 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" ;; -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" +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" ;; zyxel,nbg6617) ucidef_set_led_wlan "wlan2g" "WLAN2G" "${boardname}:green:wlan2G" "phy0tpt" diff --git a/target/linux/ipq40xx/base-files/etc/board.d/02_network b/target/linux/ipq40xx/base-files/etc/board.d/02_network index 8518f2032..f51be5a8f 100755 --- a/target/linux/ipq40xx/base-files/etc/board.d/02_network +++ b/target/linux/ipq40xx/base-files/etc/board.d/02_network @@ -16,20 +16,24 @@ 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" ;; - asus,rt-ac58u|\ - p2w,r619ac|\ - p2w,r619ac-128m|\ - zyxel,nbg6617) + hugo,ac1200) ucidef_add_switch "switch0" \ - "0t@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" + "0t@eth0" "5:wan" "3:lan" ;; asus,rt-acrh17|\ + asus,rt-ac58u|\ avm,fritzbox-4040|\ linksys,ea6350v3) ucidef_add_switch "switch0" \ @@ -49,10 +53,6 @@ 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,9 +62,6 @@ ipq40xx_setup_interfaces() ipq40xx_setup_macs() { local board="$1" - local lan_mac="" - local wan_mac="" - local label_mac="" case "$board" in asus,rt-acrh17|\ @@ -84,9 +81,8 @@ 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 "$label_mac" ] && ucidef_set_label_macaddr $label_mac + [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac + [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac } board_config_update diff --git a/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index 142c3b82b..64b5a1477 100644 --- a/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -1,38 +1,126 @@ #!/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/caldata.sh +. /lib/functions.sh +. /lib/functions/system.sh board=$(board_name) + case "$FIRMWARE" in "ath10k/cal-pci-0000:01:00.0.bin") case "$board" in meraki,mr33) - 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) + 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) ;; esac ;; "ath10k/pre-cal-pci-0000:01:00.0.bin") case "$board" in asus,map-ac2200) - caldata_extract_ubi "Factory" 0x9000 0x2f20 + ath10kcal_ubi_extract "Factory" 36864 12064 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 - caldata_extract_ubi "Factory" 0x9000 0x2f20 + ath10kcal_ubi_extract "Factory" 36864 12064 ;; openmesh,a62) - caldata_extract "0:ART" 0x9000 0x2f20 + ath10kcal_extract "0:ART" 36864 12064 ;; p2w,r619ac |\ p2w,r619ac-128m) - caldata_extract "ART" 0x9000 0x2f20 + ath10kcal_extract "ART" 36864 12064 ;; esac ;; @@ -44,40 +132,40 @@ case "$FIRMWARE" in p2w,r619ac |\ p2w,r619ac-128m |\ qcom,ap-dk01.1-c1) - caldata_extract "ART" 0x1000 0x2f20 + ath10kcal_extract "ART" 4096 12064 ;; asus,map-ac2200) - caldata_extract_ubi "Factory" 0x1000 0x2f20 + ath10kcal_ubi_extract "Factory" 4096 12064 ;; asus,rt-acrh17|\ asus,rt-ac58u) CI_UBIPART=UBI_DEV - caldata_extract_ubi "Factory" 0x1000 0x2f20 + ath10kcal_ubi_extract "Factory" 4096 12064 ;; 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) - 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) + ath10kcal_extract "0:ART" 4096 12064 ;; zyxel,nbg6617 |\ zyxel,wre6606) - caldata_extract "ART" 0x1000 0x2f20 - ath10k_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -2) + ath10kcal_extract "ART" 4096 12064 + ath10kcal_patch_mac_crc $(macaddr_add $(cat /sys/class/net/eth0/address) -2) ;; esac ;; @@ -89,39 +177,39 @@ case "$FIRMWARE" in p2w,r619ac |\ p2w,r619ac-128m |\ qcom,ap-dk01.1-c1) - caldata_extract "ART" 0x5000 0x2f20 + ath10kcal_extract "ART" 20480 12064 ;; asus,map-ac2200) - caldata_extract "Factory" 0x5000 0x2f20 + ath10kcal_ubi_extract "Factory" 20480 12064 ;; asus,rt-ac58u) CI_UBIPART=UBI_DEV - caldata_extract_ubi "Factory" 0x5000 0x2f20 + ath10kcal_ubi_extract "Factory" 20480 12064 ;; 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) - 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) + ath10kcal_extract "0:ART" 20480 12064 ;; zyxel,nbg6617 |\ zyxel,wre6606) - caldata_extract "ART" 0x5000 0x2f20 - ath10k_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -1) + ath10kcal_extract "ART" 20480 12064 + ath10kcal_patch_mac_crc $(macaddr_add $(cat /sys/class/net/eth0/address) -1) ;; esac ;; diff --git a/target/linux/ipq40xx/base-files/lib/preinit/05_set_iface_mac_ipq40xx.sh b/target/linux/ipq40xx/base-files/lib/preinit/05_set_iface_mac_ipq40xx.sh index 4ca7cbff5..44dc510a0 100644 --- a/target/linux/ipq40xx/base-files/lib/preinit/05_set_iface_mac_ipq40xx.sh +++ b/target/linux/ipq40xx/base-files/lib/preinit/05_set_iface_mac_ipq40xx.sh @@ -5,24 +5,23 @@ preinit_set_mac_address() { case $(board_name) in asus,map-ac2200) - base_mac=$(mtd_get_mac_binary_ubi Factory 0x1006) + base_mac=$(mtd_get_mac_binary_ubi Factory 4102) 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 0x1006) +1) + mac=$(macaddr_add $(mtd_get_mac_binary_ubi Factory 4102) +1) ifconfig eth0 hw ether $mac 2>/dev/null ;; meraki,mr33) - mac_lan=$(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66) + mac_lan=$(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 102) [ -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 } diff --git a/target/linux/ipq40xx/image/Makefile b/target/linux/ipq40xx/image/Makefile index 1537400d7..54d0ee147 100644 --- a/target/linux/ipq40xx/image/Makefile +++ b/target/linux/ipq40xx/image/Makefile @@ -165,19 +165,6 @@ 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 @@ -273,8 +260,22 @@ 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) @@ -304,19 +305,6 @@ 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) @@ -330,6 +318,19 @@ 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 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 index 6013bb100..e05f2b2c7 100644 --- 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 @@ -1,8 +1,78 @@ #!/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/caldata.sh +. /lib/functions.sh +. /lib/functions/system.sh board=$(board_name) @@ -10,68 +80,68 @@ case "$FIRMWARE" in "ath10k/pre-cal-pci-0000:01:00.0.bin") case $board in buffalo,wxr-2533dhp) - caldata_extract "ART" 0x1000 0x2f20 - ath10k_patch_mac $(mtd_get_mac_binary ART 0x1e) + ath10kcal_extract "ART" 4096 12064 + ath10kcal_patch_mac_crc $(mtd_get_mac_binary ART 30) ;; linksys,ea8500) - caldata_extract "art" 0x1000 0x2f20 - ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) +1) + ath10kcal_extract "art" 4096 12064 + ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) +1) ;; nec,wg2600hp) - caldata_extract "ART" 0x1000 0x2f20 - ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary PRODUCTDATA 0xc) +1) + ath10kcal_extract "ART" 4096 12064 + ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary PRODUCTDATA 12) +1) ;; netgear,d7800 |\ netgear,r7500v2 |\ netgear,r7800) - caldata_extract "art" 0x1000 0x2f20 - ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x6) +1) + ath10kcal_extract "art" 4096 12064 + ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary art 6) +1) ;; tplink,c2600) - caldata_extract "radio" 0x1000 0x2f20 - ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary default-mac 0x8) -1) + ath10kcal_extract "radio" 4096 12064 + ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary default-mac 8) -1) ;; tplink,vr2600v) - caldata_extract "ART" 0x1000 0x2f20 - ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary default-mac 0x0) -1) + ath10kcal_extract "ART" 4096 12064 + ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary default-mac 0) -1) ;; zyxel,nbg6817) - caldata_extract "0:ART" 0x1000 0x2f20 - ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii 0:APPSBLENV ethaddr) +1) + ath10kcal_extract "0:ART" 4096 12064 + ath10kcal_patch_mac_crc $(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) - caldata_extract "ART" 0x5000 0x2f20 - ath10k_patch_mac $(mtd_get_mac_binary ART 0x18) + ath10kcal_extract "ART" 20480 12064 + ath10kcal_patch_mac_crc $(mtd_get_mac_binary ART 24) ;; linksys,ea8500) - caldata_extract "art" 0x5000 0x2f20 - ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) +2) + ath10kcal_extract "art" 20480 12064 + ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) +2) ;; nec,wg2600hp) - caldata_extract "ART" 0x5000 0x2f20 - ath10k_patch_mac $(mtd_get_mac_binary PRODUCTDATA 0xc) + ath10kcal_extract "ART" 20480 12064 + ath10kcal_patch_mac_crc $(mtd_get_mac_binary PRODUCTDATA 12) ;; netgear,d7800 |\ netgear,r7500v2 |\ netgear,r7800) - caldata_extract "art" 0x5000 0x2f20 - ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x6) +2) + ath10kcal_extract "art" 20480 12064 + ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary art 6) +2) ;; tplink,c2600) - caldata_extract "radio" 0x5000 0x2f20 - ath10k_patch_mac $(mtd_get_mac_binary default-mac 0x8) + ath10kcal_extract "radio" 20480 12064 + ath10kcal_patch_mac_crc $(mtd_get_mac_binary default-mac 8) ;; tplink,vr2600v) - caldata_extract "ART" 0x5000 0x2f20 - ath10k_patch_mac $(mtd_get_mac_binary default-mac 0x0) + ath10kcal_extract "ART" 20480 12064 + ath10kcal_patch_mac_crc $(mtd_get_mac_binary default-mac 0) ;; zyxel,nbg6817) - caldata_extract "0:ART" 0x5000 0x2f20 - ath10k_patch_mac $(mtd_get_mac_ascii 0:APPSBLENV ethaddr) + ath10kcal_extract "0:ART" 20480 12064 + ath10kcal_patch_mac_crc $(mtd_get_mac_ascii 0:APPSBLENV ethaddr) ;; esac ;; diff --git a/target/linux/ixp4xx/base-files/lib/preinit/05_set_ether_mac_ixp4xx b/target/linux/ixp4xx/base-files/lib/preinit/05_set_ether_mac_ixp4xx index da7dd9d75..adda197b5 100644 --- a/target/linux/ixp4xx/base-files/lib/preinit/05_set_ether_mac_ixp4xx +++ b/target/linux/ixp4xx/base-files/lib/preinit/05_set_ether_mac_ixp4xx @@ -29,3 +29,4 @@ set_ether_mac() { } boot_hook_add preinit_main set_ether_mac + diff --git a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index 0b48b77d4..6b4d09dd3 100644 --- a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -3,18 +3,47 @@ [ -e /lib/firmware/$FIRMWARE ] && exit 0 -. /lib/functions/caldata.sh +. /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 +} case "$FIRMWARE" in "ath10k/cal-pci-0000:02:00.0.bin") board=$(board_name) case $board in bt,homehub-v5a) - caldata_extract_ubi "caldata" 0x5000 0x844 - ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary_ubi caldata 0x110c) +3) + ath10k_caldata_extract_ubi "caldata" 20480 2116 + ath10k_caldata_set_macaddr $(macaddr_add $(mtd_get_mac_binary_ubi caldata 4364) +3) ;; *) - caldata_die "board $board is not supported yet" + ath10k_caldata_die "board $board is not supported yet" ;; esac ;; diff --git a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom index 5a6e8d360..6ae5e3cfe 100644 --- a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom +++ b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom @@ -1,23 +1,130 @@ #!/bin/sh +# Based on ar71xx 10-ath9k-eeprom [ -e /lib/firmware/$FIRMWARE ] && exit 0 -. /lib/functions/caldata.sh +. /lib/functions.sh +. /lib/functions/system.sh +. /lib/upgrade/nand.sh -caldata_extract_swap() { +# 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() { 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" ] || caldata_die "no mtd device found for partition $part" + [ -n "$mtd" ] || \ + ath9k_eeprom_die "no mtd device found for partition $part" - offset=$(($offset / 2)) - count=$(($count / 2)) + ath9k_eeprom_extract_raw $mtd $offset $swap +} - 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" +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) + + 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 } case "$FIRMWARE" in @@ -28,43 +135,43 @@ case "$FIRMWARE" in case "$board" in arcadyan,arv7518pw) - caldata_extract_swap "boardconfig" 0x400 0x1000 + ath9k_eeprom_extract "boardconfig" 1024 1 ;; arcadyan,arv8539pw22) - caldata_extract_swap "art" 0x400 0x1000 + ath9k_eeprom_extract "art" 1024 1 ;; bt,homehub-v2b) - caldata_extract_swap "art" 0x0 0x1000 - ath9k_patch_mac_crc "00:00:00:00:00:00" 0x20c + ath9k_eeprom_extract "art" 0 1 + ath9k_patch_fw_mac_crc "00:00:00:00:00:00" 524 ;; bt,homehub-v3a) - caldata_extract_swap "art-copy" 0x0 0x1000 - ath9k_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii uboot_env ethaddr) +2) 0x10c + ath9k_eeprom_extract "art-copy" 0 1 + ath9k_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_ascii uboot_env ethaddr) +2) 268 ;; bt,homehub-v5a) - caldata_extract_ubi "caldata" 0x1000 0x1000 - ath9k_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary_ubi caldata 0x110c) +2) 0x10c + ath9k_ubi_eeprom_extract "caldata" 4096 0 + ath9k_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_binary_ubi caldata 4364) +2) 268 ;; netgear,dgn3500|netgear,dgn3500b) - caldata_extract "calibration" 0xf000 0x1000 - ath9k_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii uboot-env ethaddr) +2) 0x20c + ath9k_eeprom_extract "calibration" 61440 0 + ath9k_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_ascii uboot-env ethaddr) +2) 524 ;; avm,fritz3370-rev2-hynix|\ avm,fritz3370-rev2-micron|\ avm,fritz7362sl) - caldata_extract_reverse "urlader" 0x1541 0x440 + ath9k_eeprom_extract_reverse "urlader" 5441 1088 ;; avm,fritz7312|avm,fritz7320|avm,fritz7360sl) - caldata_extract "urlader" 0x985 0x1000 + ath9k_eeprom_extract "urlader" 2437 0 ;; 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) - caldata_extract "boardconfig" 0x21000 0x1000 + ath9k_eeprom_extract "boardconfig" 135168 0 ;; *) - caldata_die "board $board is not supported yet" + ath9k_eeprom_die "board $board is not supported yet" ;; esac ;; diff --git a/target/linux/lantiq/base-files/etc/uci-defaults/01_led_migration b/target/linux/lantiq/base-files/etc/uci-defaults/01_led_migration index b1e7be6bd..dc594e35e 100644 --- a/target/linux/lantiq/base-files/etc/uci-defaults/01_led_migration +++ b/target/linux/lantiq/base-files/etc/uci-defaults/01_led_migration @@ -3,7 +3,37 @@ # Copyright (C) 2013 OpenWrt.org # -. /lib/functions/migrations.sh +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; +} do_internet_led_rename() { @@ -15,29 +45,38 @@ 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|\ -arcadyan,vg3503j|\ -avm,fritz7360sl|\ +alphanetworks,asl56026|\ bt,homehub-v2b|\ bt,homehub-v3a|\ -bt,homehub-v5a) +bt,homehub-v5a|\ +avm,fritz7360sl|\ +arcadyan,vg3503j) do_internet_led_rename ;; netgear,dgn3500|\ netgear,dgn3500b) migrate_leds "dgn3500:blue:wireless=dgn3500:green:wireless" ;; +*) + ;; esac -migrations_apply system +[ "$LED_OPTIONS_CHANGED" = "1" ] && uci commit system exit 0 diff --git a/target/linux/lantiq/base-files/etc/uci-defaults/02_migrate_xdsl_iface b/target/linux/lantiq/base-files/etc/uci-defaults/02_migrate_xdsl_iface index dd57ca6d3..3b0313d1a 100644 --- a/target/linux/lantiq/base-files/etc/uci-defaults/02_migrate_xdsl_iface +++ b/target/linux/lantiq/base-files/etc/uci-defaults/02_migrate_xdsl_iface @@ -1,6 +1,7 @@ #!/bin/sh . /lib/functions.sh +. /lib/functions/lantiq.sh IFNAME_CHANGED=0 diff --git a/target/linux/lantiq/base-files/lib/preinit/05_set_preinit_iface_lantiq b/target/linux/lantiq/base-files/lib/preinit/05_set_preinit_iface_lantiq index 0539b82d3..7ed0fabcf 100644 --- a/target/linux/lantiq/base-files/lib/preinit/05_set_preinit_iface_lantiq +++ b/target/linux/lantiq/base-files/lib/preinit/05_set_preinit_iface_lantiq @@ -1,7 +1,10 @@ #!/bin/sh +. /lib/functions/lantiq.sh + set_preinit_iface() { ifname=eth0 } boot_hook_add preinit_main set_preinit_iface + diff --git a/target/linux/mpc85xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/mpc85xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom index be6ee4038..3e6488b4c 100644 --- a/target/linux/mpc85xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom +++ b/target/linux/mpc85xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom @@ -1,8 +1,41 @@ #!/bin/sh -[ -e /lib/firmware/$FIRMWARE ] && exit 0 +FW_FILE="/lib/firmware/$FIRMWARE" -. /lib/functions/caldata.sh +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 board=$(board_name) @@ -10,11 +43,11 @@ case "$FIRMWARE" in "pci_wmac0.eeprom") case $board in tplink,tl-wdr4900-v1) - caldata_extract "caldata" 0x1000 0x800 - ath9k_patch_mac $(mtd_get_mac_binary u-boot 0x4fc00) + ath9k_eeprom_extract "caldata" 4096 2048 + tpl_set_wireless_mac 0 ;; *) - caldata_die "board $board is not supported yet" + ath9k_eeprom_die "board $board is not supported yet" ;; esac ;; @@ -22,11 +55,11 @@ case "$FIRMWARE" in "pci_wmac1.eeprom") case $board in tplink,tl-wdr4900-v1) - caldata_extract "caldata" 0x5000 0x800 - ath9k_patch_mac $(macaddr_add $(mtd_get_mac_binary u-boot 0x4fc00) -1) + ath9k_eeprom_extract "caldata" 20480 2048 + tpl_set_wireless_mac -1 ;; *) - caldata_die "board $board is not supported yet" + ath9k_eeprom_die "board $board is not supported yet" ;; esac ;; diff --git a/target/linux/ramips/base-files/lib/preinit/07_set_preinit_iface_ramips b/target/linux/ramips/base-files/lib/preinit/07_set_preinit_iface_ramips index 68c1285eb..003a4dda7 100644 --- a/target/linux/ramips/base-files/lib/preinit/07_set_preinit_iface_ramips +++ b/target/linux/ramips/base-files/lib/preinit/07_set_preinit_iface_ramips @@ -3,54 +3,27 @@ # 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() { - local switchdev=$(ramips_switchdev_from_board) - [ -n "$switchdev" ] || switchdev=$(ramips_switchdev_from_soc) + RT3X5X=$(grep -E "(RT3.5|RT5350|MT7628|MT7688|MT7620|MT7621)" /proc/cpuinfo) - if [ -n "$switchdev" ]; then - swconfig dev $switchdev set reset 1 - swconfig dev $switchdev set enable_vlan 0 - swconfig dev $switchdev set apply 1 + 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 fi ifname=eth0