From 2289184a623c4da882a376abb649969dee73654f Mon Sep 17 00:00:00 2001 From: AmadeusGhost <42570690+AmadeusGhost@users.noreply.github.com> Date: Sat, 1 Feb 2020 16:50:37 +0800 Subject: [PATCH] files: sync from openwrt v19.07 (#2690) --- 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 | 1179 +---------------- .../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 | 67 +- 58 files changed, 796 insertions(+), 1947 deletions(-) create mode 100755 package/base-files/files/etc/rc.button/reboot create mode 100644 package/base-files/files/lib/functions/caldata.sh create mode 100644 package/base-files/files/lib/functions/migrations.sh mode change 100644 => 100755 scripts/json_add_image_info.py diff --git a/config/Config-devel.in b/config/Config-devel.in index fd7c3ead1..70ec0ce9a 100644 --- a/config/Config-devel.in +++ b/config/Config-devel.in @@ -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 diff --git a/config/Config-images.in b/config/Config-images.in index 2bfa6bc53..d93f9c2e5 100644 --- a/config/Config-images.in +++ b/config/Config-images.in @@ -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" diff --git a/config/Config-kernel.in b/config/Config-kernel.in index 9a82b9ecc..4aa7e2bdb 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 + 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. diff --git a/include/cmake.mk b/include/cmake.mk index b66665d20..a5ba7d31b 100644 --- a/include/cmake.mk +++ b/include/cmake.mk @@ -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) \ ) diff --git a/include/debug.mk b/include/debug.mk index 59a99c0f7..0cedb9cec 100644 --- a/include/debug.mk +++ b/include/debug.mk @@ -48,4 +48,3 @@ debug_eval:= warn_eval = $(4) endif - diff --git a/include/download.mk b/include/download.mk index 33141910f..a020273e8 100644 --- a/include/download.mk +++ b/include/download.mk @@ -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))) diff --git a/include/hardening.mk b/include/hardening.mk index 4e49e6b1b..3a065aeea 100644 --- a/include/hardening.mk +++ b/include/hardening.mk @@ -61,4 +61,3 @@ ifdef CONFIG_PKG_RELRO_FULL TARGET_LDFLAGS += -znow -zrelro endif endif - diff --git a/include/image-commands.mk b/include/image-commands.mk index 5dfd6a2c2..4cf129372 100644 --- a/include/image-commands.mk +++ b/include/image-commands.mk @@ -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 +# 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 8592c19b9..26da4d681 100644 --- a/include/image.mk +++ b/include/image.mk @@ -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 \ diff --git a/include/kernel-defaults.mk b/include/kernel-defaults.mk index cc1e2361b..6ae68d918 100644 --- a/include/kernel-defaults.mk +++ b/include/kernel-defaults.mk @@ -160,5 +160,3 @@ 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 19ecf4fa9..deaac7e88 100644 --- a/include/kernel.mk +++ b/include/kernel.mk @@ -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)) - diff --git a/include/toolchain-build.mk b/include/toolchain-build.mk index 883d74d25..35d8c9380 100644 --- a/include/toolchain-build.mk +++ b/include/toolchain-build.mk @@ -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 diff --git a/include/u-boot.mk b/include/u-boot.mk index babb76497..9ba9c5096 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 = \ - http://sources.lede-project.org \ + https://sources.openwrt.org \ ftp://ftp.denx.de/pub/u-boot endif diff --git a/include/version.mk b/include/version.mk index 8ef0a7e65..32483c101 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),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' - diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate index df221cc26..1c0334475 100755 --- a/package/base-files/files/bin/config_generate +++ b/package/base-files/files/bin/config_generate @@ -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 diff --git a/package/base-files/files/etc/group b/package/base-files/files/etc/group index e8e2adf4a..5b06dc6db 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 31f245ffc..44311c9e2 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=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 diff --git a/package/base-files/files/etc/init.d/umount b/package/base-files/files/etc/init.d/umount index 349b2b326..b764ae158 100755 --- a/package/base-files/files/etc/init.d/umount +++ b/package/base-files/files/etc/init.d/umount @@ -1,7 +1,12 @@ #!/bin/sh /etc/rc.common # Copyright (C) 2006 OpenWrt.org -STOP=99 +STOP=90 + +restart() { + : +} + 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 new file mode 100755 index 000000000..cd547e332 --- /dev/null +++ b/package/base-files/files/etc/rc.button/reboot @@ -0,0 +1,12 @@ +#!/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 46d079b36..bc8c57969 100644 --- a/package/base-files/files/etc/sysctl.d/10-default.conf +++ b/package/base-files/files/etc/sysctl.d/10-default.conf @@ -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 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 a354844fe..481444f35 100644 --- a/package/base-files/files/etc/uci-defaults/10_migrate-shadow +++ b/package/base-files/files/etc/uci-defaults/10_migrate-shadow @@ -1,5 +1,3 @@ -#!/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 8871427c6..e780365ab 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,5 +1,3 @@ -#!/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 - 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 e6dae2419..bf9febdfe 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,5 +1,3 @@ -#!/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 50a7b4086..e965cfc40 100755 --- a/package/base-files/files/lib/functions.sh +++ b/package/base-files/files/lib/functions.sh @@ -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 diff --git a/package/base-files/files/lib/functions/caldata.sh b/package/base-files/files/lib/functions/caldata.sh new file mode 100644 index 000000000..3bdb1e4dd --- /dev/null +++ b/package/base-files/files/lib/functions/caldata.sh @@ -0,0 +1,128 @@ +# 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 new file mode 100644 index 000000000..b180a0242 --- /dev/null +++ b/package/base-files/files/lib/functions/migrations.sh @@ -0,0 +1,39 @@ +#!/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 4fdcb6630..6b946b9f8 100644 --- a/package/base-files/files/lib/functions/network.sh +++ b/package/base-files/files/lib/functions/network.sh @@ -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 diff --git a/package/base-files/files/lib/functions/system.sh b/package/base-files/files/lib/functions/system.sh index 7ed62804a..c9f8eb0c3 100644 --- a/package/base-files/files/lib/functions/system.sh +++ b/package/base-files/files/lib/functions/system.sh @@ -1,10 +1,12 @@ # 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 diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh index 315df7b70..c2c6dc3fd 100755 --- a/package/base-files/files/lib/functions/uci-defaults.sh +++ b/package/base-files/files/lib/functions/uci-defaults.sh @@ -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" diff --git a/package/base-files/files/lib/preinit/30_failsafe_wait b/package/base-files/files/lib/preinit/30_failsafe_wait index dd9c7e2b5..85dca398f 100644 --- a/package/base-files/files/lib/preinit/30_failsafe_wait +++ b/package/base-files/files/lib/preinit/30_failsafe_wait @@ -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 diff --git a/package/base-files/files/sbin/hotplug-call b/package/base-files/files/sbin/hotplug-call index 829fdbd75..f595b9e75 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 \ No newline at end of file +fi diff --git a/package/base-files/files/sbin/wifi b/package/base-files/files/sbin/wifi index 261d2fb50..a8b4451c6 100755 --- a/package/base-files/files/sbin/wifi +++ b/package/base-files/files/sbin/wifi @@ -6,7 +6,7 @@ usage() { cat < - - - - - - - - - - +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) - - - openwrt/json_add_image_info.py at master · openwrt/openwrt · GitHub - - - - + if not titles: + titles.append({"title": e("DEVICE_TITLE")}) - - + return titles - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- 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. -
- - - - - - - - - - - - - - -
- - - +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=" ") 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 6d2d18658..ee58901d1 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,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 ;; 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 1a27930d2..11955dd5a 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 102) + mac_lan=$(mtd_get_mac_binary_ubi board-config 0x66) [ -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 b83f79333..4da3a5482 100755 --- a/target/linux/ar71xx/base-files/etc/board.d/02_network +++ b/target/linux/ar71xx/base-files/etc/board.d/02_network @@ -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 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 52c9f29c0..d23a307f2 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" 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" 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 af6c976d3..dc805a7f4 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,21 +1,5 @@ #!/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 ;; 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 a9cb69e7d..f97f5ac72 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 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 - 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 c41d4b08f..bd1abb968 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,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 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 de45a817e..6fba60777 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 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 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 da794ae03..fb18db950 100755 --- a/target/linux/ipq40xx/base-files/etc/board.d/01_leds +++ b/target/linux/ipq40xx/base-files/etc/board.d/01_leds @@ -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" 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 f51be5a8f..8518f2032 100755 --- a/target/linux/ipq40xx/base-files/etc/board.d/02_network +++ b/target/linux/ipq40xx/base-files/etc/board.d/02_network @@ -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 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 64b5a1477..142c3b82b 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,126 +1,38 @@ #!/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 ;; 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 44dc510a0..4ca7cbff5 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,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 } diff --git a/target/linux/ipq40xx/image/Makefile b/target/linux/ipq40xx/image/Makefile index 54d0ee147..1537400d7 100644 --- a/target/linux/ipq40xx/image/Makefile +++ b/target/linux/ipq40xx/image/Makefile @@ -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 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 e05f2b2c7..6013bb100 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,78 +1,8 @@ #!/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 ;; 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 adda197b5..da7dd9d75 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,4 +29,3 @@ 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 6b4d09dd3..0b48b77d4 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,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 ;; 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 6ae5e3cfe..5a6e8d360 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,130 +1,23 @@ #!/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" + [ -n "$mtd" ] || caldata_die "no mtd device found for partition $part" - ath9k_eeprom_extract_raw $mtd $offset $swap -} + offset=$(($offset / 2)) + count=$(($count / 2)) -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 + 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 ;; 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 dc594e35e..b1e7be6bd 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,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 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 3b0313d1a..dd57ca6d3 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,7 +1,6 @@ #!/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 7ed0fabcf..0539b82d3 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,10 +1,7 @@ #!/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 3e6488b4c..be6ee4038 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,41 +1,8 @@ #!/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 ;; 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 003a4dda7..68c1285eb 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,27 +3,54 @@ # Copyright (C) 2013 OpenWrt.org # -ramips_set_preinit_iface() { - RT3X5X=$(grep -E "(RT3.5|RT5350|MT7628|MT7688|MT7620|MT7621)" /proc/cpuinfo) +. /lib/functions.sh - 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 +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) + + 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