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

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

上级 9b593a88
......@@ -105,6 +105,13 @@ menuconfig DEVEL
help
If enabled, log files will be written to the ./log directory.
config BUILD_LOG_DIR
string "Log folder" if DEVEL
default ""
help
Store build logs in this directory.
If not set, uses './logs'
config SRC_TREE_OVERRIDE
bool "Enable package source tree override" if DEVEL
help
......
......@@ -14,11 +14,12 @@ menu "Target Images"
choice
prompt "Compression"
default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_ar71xx
default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_ramips
default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_apm821xx
default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_mpc85xx
default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_ar71xx
default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_ipq40xx
default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_lantiq
default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_mpc85xx
default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_ramips
default TARGET_INITRAMFS_COMPRESSION_NONE
depends on TARGET_ROOTFS_INITRAMFS
help
......@@ -194,7 +195,7 @@ menu "Target Images"
depends on TARGET_ROOTFS_EXT4FS || TARGET_ROOTFS_ISO || TARGET_ROOTFS_JFFS2 || TARGET_ROOTFS_SQUASHFS
select PACKAGE_grub2
default y
config EFI_IMAGES
bool "Build EFI GRUB images (Linux x86 or x86_64 host only)"
depends on TARGET_x86
......@@ -254,6 +255,7 @@ menu "Target Images"
select GRUB_IMAGES
select TARGET_IMAGES_PAD
select PACKAGE_kmod-e1000
default n
config VMDK_IMAGES
bool "Build VMware image files (VMDK)"
......@@ -262,22 +264,22 @@ menu "Target Images"
select TARGET_IMAGES_PAD
select PACKAGE_kmod-e1000
default y
config VHD_IMAGES
bool "Build Hyper-V image files (VHD)"
depends on TARGET_x86 || TARGET_x86_64
default n
depends on GRUB_IMAGES || EFI_IMAGES
select TARGET_IMAGES_PAD
select PACKAGE_kmod-tulip
select PACKAGE_kmod-tulip
default n
config QCOW2_IMAGES
bool "Build PVE/KVM image files (QCOW2)"
depends on TARGET_x86 || TARGET_x86_64
default n
depends on GRUB_IMAGES || EFI_IMAGES
select TARGET_IMAGES_PAD
select PACKAGE_kmod-e1000
select PACKAGE_kmod-e1000
default n
config TARGET_IMAGES_PAD
bool "Pad images to filesystem size (for JFFS2)"
......@@ -286,7 +288,7 @@ menu "Target Images"
config TARGET_IMAGES_GZIP
bool "GZip images"
depends on TARGET_IMAGES_PAD || TARGET_ROOTFS_EXT4FS || TARGET_x86
depends on TARGET_ROOTFS_EXT4FS || TARGET_x86 || TARGET_armvirt || TARGET_malta
default n
comment "Image Options"
......
......@@ -46,7 +46,7 @@ config KERNEL_DEBUG_FS
config KERNEL_MIPS_FPU_EMULATOR
bool "Compile the kernel with MIPS FPU Emulator"
default y
default y if TARGET_pistachio
depends on (mips || mipsel || mips64 || mips64el)
config KERNEL_ARM_PMU
......@@ -596,7 +596,7 @@ endif
config KERNEL_NAMESPACES
bool "Enable kernel namespaces"
default n
default y if !SMALL_FLASH
if KERNEL_NAMESPACES
......@@ -665,13 +665,13 @@ config KERNEL_POSIX_MQUEUE
config KERNEL_SECCOMP_FILTER
bool
default n
default y if !SMALL_FLASH
config KERNEL_SECCOMP
bool "Enable seccomp support"
depends on !(TARGET_uml)
select KERNEL_SECCOMP_FILTER
default n
default y if !SMALL_FLASH
help
Build kernel with support for seccomp.
......
......@@ -103,6 +103,7 @@ define Host/Configure/Default
-DCMAKE_INSTALL_PREFIX=$(HOST_BUILD_PREFIX) \
-DCMAKE_PREFIX_PATH=$(HOST_BUILD_PREFIX) \
-DCMAKE_SKIP_RPATH=TRUE \
-DCMAKE_INSTALL_LIBDIR=lib \
$(CMAKE_HOST_OPTIONS) \
$(HOST_CMAKE_SOURCE_DIR) \
)
......
......@@ -48,4 +48,3 @@ debug_eval:=
warn_eval = $(4)
endif
......@@ -288,6 +288,7 @@ endef
define Download/default
FILE:=$(PKG_SOURCE)
URL:=$(PKG_SOURCE_URL)
URL_FILE:=$(PKG_SOURCE_URL_FILE)
SUBDIR:=$(PKG_SOURCE_SUBDIR)
PROTO:=$(PKG_SOURCE_PROTO)
$(if $(PKG_SOURCE_MIRROR),MIRROR:=$(filter 1,$(PKG_MIRROR)))
......
......@@ -61,4 +61,3 @@ ifdef CONFIG_PKG_RELRO_FULL
TARGET_LDFLAGS += -znow -zrelro
endif
endif
......@@ -3,6 +3,10 @@
IMAGE_KERNEL = $(word 1,$^)
IMAGE_ROOTFS = $(word 2,$^)
define rootfs_align
$(patsubst %-256k,0x40000,$(patsubst %-128k,0x20000,$(patsubst %-64k,0x10000,$(patsubst squashfs%,0x4,$(patsubst root.%,%,$(1))))))
endef
define Build/uImage
mkimage -A $(LINUX_KARCH) \
-O linux -T kernel \
......@@ -271,6 +275,13 @@ define Build/check-size
}
endef
define Build/check-kernel-size
@[ $$(($(subst k,* 1024,$(subst m, * 1024k,$(1))))) -ge "$$(stat -c%s $(IMAGE_KERNEL))" ] || { \
echo "WARNING: Kernel for $@ is too big > $(1)" >&2; \
rm -f $@; \
}
endef
define Build/combined-image
-sh $(TOPDIR)/scripts/combined-image.sh \
"$(IMAGE_KERNEL)" \
......@@ -308,7 +319,7 @@ endef
define Build/qsdk-ipq-factory-nor
$(TOPDIR)/scripts/mkits-qsdk-ipq-image.sh \
$@.its hlos $(IMAGE_KERNEL) rootfs $(IMAGE_ROOTFS)
$@.its kernel $(IMAGE_KERNEL) rootfs $(IMAGE_ROOTFS)
PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $@.its $@.new
@mv $@.new $@
endef
......@@ -335,6 +346,24 @@ define Build/tplink-v1-header
@mv $@.new $@
endef
# combine kernel and rootfs into one image
# mktplinkfw <type> <optional extra arguments to mktplinkfw binary>
# <type> is "sysupgrade" or "factory"
#
# -a align the rootfs start on an <align> bytes boundary
# -j add jffs2 end-of-filesystem markers
# -s strip padding from end of the image
# -X reserve <size> bytes in the firmware image (hexval prefixed with 0x)
define Build/tplink-v1-image
-$(STAGING_DIR_HOST)/bin/mktplinkfw \
-H $(TPLINK_HWID) -W $(TPLINK_HWREV) -F $(TPLINK_FLASHLAYOUT) \
-N "$(VERSION_DIST)" -V $(REVISION) -m $(TPLINK_HEADER_VERSION) \
-k $(IMAGE_KERNEL) -r $(IMAGE_ROOTFS) -o $@.new -j -X 0x40000 \
-a $(call rootfs_align,$(FILESYSTEM)) \
$(wordlist 2,$(words $(1)),$(1)) \
$(if $(findstring sysupgrade,$(word 1,$(1))),-s) && mv $@.new $@ || rm -f $@
endef
define Build/tplink-v2-header
$(STAGING_DIR_HOST)/bin/mktplinkfw2 \
-c -H $(TPLINK_HWID) -W $(TPLINK_HWREV) -L $(KERNEL_LOADADDR) \
......
......@@ -420,6 +420,7 @@ define Device/Init
DEVICE_DTS :=
DEVICE_DTS_CONFIG :=
DEVICE_DTS_DIR :=
SOC :=
BOARD_NAME :=
UIMAGE_NAME :=
......@@ -437,7 +438,7 @@ DEFAULT_DEVICE_VARS := \
DEVICE_NAME KERNEL KERNEL_INITRAMFS KERNEL_INITRAMFS_IMAGE KERNEL_SIZE \
CMDLINE UBOOTENV_IN_UBI KERNEL_IN_UBI BLOCKSIZE PAGESIZE SUBPAGESIZE \
VID_HDR_OFFSET UBINIZE_OPTS UBINIZE_PARTS MKUBIFS_OPTS DEVICE_DTS \
DEVICE_DTS_CONFIG DEVICE_DTS_DIR BOARD_NAME UIMAGE_NAME SUPPORTED_DEVICES \
DEVICE_DTS_CONFIG DEVICE_DTS_DIR SOC BOARD_NAME UIMAGE_NAME SUPPORTED_DEVICES \
IMAGE_METADATA KERNEL_ENTRY KERNEL_LOADADDR UBOOT_PATH DEVICE_VENDOR \
DEVICE_MODEL DEVICE_VARIANT \
DEVICE_ALT0_VENDOR DEVICE_ALT0_MODEL DEVICE_ALT0_VARIANT \
......
......@@ -160,5 +160,3 @@ define Kernel/Clean/Default
rm -f $(LINUX_KERNEL)
$(_SINGLE)$(MAKE) -C $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) clean
endef
......@@ -104,6 +104,7 @@ endif
KERNEL_MAKE = $(MAKE) $(KERNEL_MAKEOPTS)
KERNEL_MAKE_FLAGS = \
KCFLAGS="$(call iremap,$(BUILD_DIR),$(notdir $(BUILD_DIR)))" \
HOSTCFLAGS="$(HOST_CFLAGS) -Wall -Wmissing-prototypes -Wstrict-prototypes" \
CROSS_COMPILE="$(KERNEL_CROSS)" \
ARCH="$(LINUX_KARCH)" \
......@@ -113,6 +114,7 @@ KERNEL_MAKE_FLAGS = \
KBUILD_BUILD_TIMESTAMP="$(KBUILD_BUILD_TIMESTAMP)" \
KBUILD_BUILD_VERSION="0" \
HOST_LOADLIBES="-L$(STAGING_DIR_HOST)/lib" \
KBUILD_HOSTLDLIBS="-L$(STAGING_DIR_HOST)/lib" \
CONFIG_SHELL="$(BASH)" \
$(if $(findstring c,$(OPENWRT_VERBOSE)),V=1,V='') \
$(if $(PKG_BUILD_ID),LDFLAGS_MODULE=--build-id=0x$(PKG_BUILD_ID)) \
......@@ -129,6 +131,11 @@ ifdef CONFIG_USE_SPARSE
KERNEL_MAKEOPTS += C=1 CHECK=$(STAGING_DIR_HOST)/bin/sparse
endif
ifneq ($(HOST_OS),Linux)
KERNEL_MAKEOPTS += CONFIG_STACK_VALIDATION=
export SKIP_STACK_VALIDATION:=1
endif
PKG_EXTMOD_SUBDIRS ?= .
define populate_module_symvers
......@@ -294,4 +301,3 @@ kernel_patchver_ge=$(call kernel_version_cmp,-ge,$(KERNEL_PATCHVER),$(1))
kernel_patchver_eq=$(call kernel_version_cmp,-eq,$(KERNEL_PATCHVER),$(1))
kernel_patchver_le=$(call kernel_version_cmp,-le,$(KERNEL_PATCHVER),$(1))
kernel_patchver_lt=$(call kernel_version_cmp,-lt,$(KERNEL_PATCHVER),$(1))
......@@ -12,6 +12,7 @@ HOST_BUILD_PREFIX:=$(TOOLCHAIN_DIR)
BUILD_DIR_HOST:=$(BUILD_DIR_TOOLCHAIN)
include $(INCLUDE_DIR)/host-build.mk
include $(INCLUDE_DIR)/hardening.mk
HOST_STAMP_PREPARED=$(HOST_BUILD_DIR)/.prepared
......
......@@ -3,7 +3,7 @@ PKG_NAME ?= u-boot
ifndef PKG_SOURCE_PROTO
PKG_SOURCE = $(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL = \
http://sources.lede-project.org \
https://sources.openwrt.org \
ftp://ftp.denx.de/pub/u-boot
endif
......
......@@ -42,16 +42,16 @@ VERSION_MANUFACTURER:=$(call qstrip,$(CONFIG_VERSION_MANUFACTURER))
VERSION_MANUFACTURER:=$(if $(VERSION_MANUFACTURER),$(VERSION_MANUFACTURER),OpenWrt)
VERSION_MANUFACTURER_URL:=$(call qstrip,$(CONFIG_VERSION_MANUFACTURER_URL))
VERSION_MANUFACTURER_URL:=$(if $(VERSION_MANUFACTURER_URL),$(VERSION_MANUFACTURER_URL),http://openwrt.org/)
VERSION_MANUFACTURER_URL:=$(if $(VERSION_MANUFACTURER_URL),$(VERSION_MANUFACTURER_URL),https://openwrt.org/)
VERSION_BUG_URL:=$(call qstrip,$(CONFIG_VERSION_BUG_URL))
VERSION_BUG_URL:=$(if $(VERSION_BUG_URL),$(VERSION_BUG_URL),http://bugs.openwrt.org/)
VERSION_BUG_URL:=$(if $(VERSION_BUG_URL),$(VERSION_BUG_URL),https://bugs.openwrt.org/)
VERSION_HOME_URL:=$(call qstrip,$(CONFIG_VERSION_HOME_URL))
VERSION_HOME_URL:=$(if $(VERSION_HOME_URL),$(VERSION_HOME_URL),http://openwrt.org/)
VERSION_HOME_URL:=$(if $(VERSION_HOME_URL),$(VERSION_HOME_URL),https://openwrt.org/)
VERSION_SUPPORT_URL:=$(call qstrip,$(CONFIG_VERSION_SUPPORT_URL))
VERSION_SUPPORT_URL:=$(if $(VERSION_SUPPORT_URL),$(VERSION_SUPPORT_URL),http://forum.lede-project.org/)
VERSION_SUPPORT_URL:=$(if $(VERSION_SUPPORT_URL),$(VERSION_SUPPORT_URL),https://forum.openwrt.org/)
VERSION_PRODUCT:=$(call qstrip,$(CONFIG_VERSION_PRODUCT))
VERSION_PRODUCT:=$(if $(VERSION_PRODUCT),$(VERSION_PRODUCT),Generic)
......@@ -108,4 +108,3 @@ VERSION_SED_SCRIPT:=$(SED) 's,%U,$(call sed_escape,$(VERSION_REPO)),g' \
-e 's,%s,$(call sed_escape,$(VERSION_SUPPORT_URL)),g' \
-e 's,%P,$(call sed_escape,$(VERSION_PRODUCT)),g' \
-e 's,%h,$(call sed_escape,$(VERSION_HWREV)),g'
......@@ -85,12 +85,16 @@ generate_network() {
set network.$1.proto='none'
EOF
[ -n "$macaddr" ] && uci -q batch <<-EOF
delete network.$1_dev
set network.$1_dev='device'
set network.$1_dev.name='$ifname'
set network.$1_dev.macaddr='$macaddr'
EOF
if [ -n "$macaddr" ]; then
for name in $ifname; do
uci -q batch <<-EOF
delete network.$1_${name/./_}_dev
set network.$1_${name/./_}_dev='device'
set network.$1_${name/./_}_dev.name='$name'
set network.$1_${name/./_}_dev.macaddr='$macaddr'
EOF
done
fi
case "$protocol" in
static)
......@@ -213,7 +217,8 @@ generate_switch() {
json_select switch
json_select "$key"
json_get_vars enable reset blinkrate cpu_port
json_get_vars enable reset blinkrate cpu_port \
ar8xxx_mib_type ar8xxx_mib_poll_interval
uci -q batch <<-EOF
add network switch
......@@ -221,6 +226,8 @@ generate_switch() {
set network.@switch[-1].reset='$reset'
set network.@switch[-1].enable_vlan='$enable'
set network.@switch[-1].blinkrate='$blinkrate'
set network.@switch[-1].ar8xxx_mib_type='$ar8xxx_mib_type'
set network.@switch[-1].ar8xxx_mib_poll_interval='$ar8xxx_mib_poll_interval'
EOF
generate_switch_vlans_ports "$1"
......@@ -244,10 +251,10 @@ generate_static_system() {
set system.ntp='timeserver'
set system.ntp.enabled='1'
set system.ntp.enable_server='0'
add_list system.ntp.server='0.openwrt.pool.ntp.org'
add_list system.ntp.server='1.openwrt.pool.ntp.org'
add_list system.ntp.server='2.openwrt.pool.ntp.org'
add_list system.ntp.server='3.openwrt.pool.ntp.org'
add_list system.ntp.server='ntp1.aliyun.com'
add_list system.ntp.server='time1.cloud.tencent.com'
add_list system.ntp.server='time.ustc.edu.cn'
add_list system.ntp.server='pool.ntp.org'
EOF
if json_is_a system object; then
......
root:x:0:
daemon:x:1:
adm:x:4:
tty:x:5:
mail:x:8:
dialout:x:20:
audio:x:29:
www-data:x:33:
ftp:x:55:
......
......@@ -2,7 +2,7 @@
# Copyright (C) 2006-2011 OpenWrt.org
START=10
STOP=98
STOP=90
uci_apply_defaults() {
. /lib/functions/system.sh
......@@ -31,8 +31,9 @@ boot() {
chmod 0700 /tmp/.uci
touch /var/log/wtmp
touch /var/log/lastlog
touch /tmp/resolv.conf.auto
ln -sf /tmp/resolv.conf.auto /tmp/resolv.conf
mkdir -p /tmp/resolv.conf.d
touch /tmp/resolv.conf.d/resolv.conf.auto
ln -sf /tmp/resolv.conf.d/resolv.conf.auto /tmp/resolv.conf
grep -q debugfs /proc/filesystems && /bin/mount -o noatime -t debugfs debugfs /sys/kernel/debug
[ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe
......
#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org
STOP=99
STOP=90
restart() {
:
}
stop() {
sync
/bin/umount -a -d -r
......
#!/bin/sh
[ "${ACTION}" = "released" ] || exit 0
if [ "$SEEN" -ge 5 ]
then
echo "REBOOT" > /dev/console
sync
reboot
fi
return 0
......@@ -8,6 +8,8 @@ fs.suid_dumpable=2
fs.protected_hardlinks=1
fs.protected_symlinks=1
net.core.bpf_jit_enable=1
net.ipv4.conf.default.arp_ignore=1
net.ipv4.conf.all.arp_ignore=1
net.ipv4.ip_forward=1
......
#!/bin/sh
ppwd="$(sed -ne '/^root:/s/^root:\([^:]*\):.*$/\1/p' /etc/passwd)"
spwd="$(sed -ne '/^root:/s/^root:\([^:]*\):.*$/\1/p' /etc/shadow)"
......
#!/bin/sh
[ "$(uci -q get network.globals.ula_prefix)" != "auto" ] && exit 0
r1=$(dd if=/dev/urandom bs=1 count=1 |hexdump -e '1/1 "%02x"')
......@@ -12,4 +10,3 @@ uci -q batch <<-EOF >/dev/null
EOF
exit 0
#!/bin/sh
. /lib/functions.sh
for file in `grep -sl Require-User /usr/lib/opkg/info/*.control`; do
......
......@@ -17,6 +17,22 @@ NO_EXPORT=1
LOAD_STATE=1
LIST_SEP=" "
# xor multiple hex values of the same length
xor() {
local val
local ret="0x$1"
local retlen=${#1}
shift
while [ -n "$1" ]; do
val="0x$1"
ret=$((ret ^ val))
shift
done
printf "%0${retlen}x" "$ret"
}
append() {
local var="$1"
local value="$2"
......@@ -213,6 +229,7 @@ add_group_and_user() {
default_postinst() {
local root="${IPKG_INSTROOT}"
local pkgname="$(basename ${1%.*})"
local filelist="/usr/lib/opkg/info/${pkgname}.list"
local ret=0
add_group_and_user "${pkgname}"
......@@ -227,14 +244,14 @@ default_postinst() {
rm -fR $root/rootfs-overlay/
fi
if [ -z "$root" ] && grep -q -s "^/etc/modules.d/" "/usr/lib/opkg/info/${pkgname}.list"; then
if [ -z "$root" ] && grep -q -s "^/etc/modules.d/" "$filelist"; then
kmodloader
fi
if [ -z "$root" ] && grep -q -s "^/etc/uci-defaults/" "/usr/lib/opkg/info/${pkgname}.list"; then
if [ -z "$root" ] && grep -q -s "^/etc/uci-defaults/" "$filelist"; then
. /lib/functions/system.sh
[ -d /tmp/.uci ] || mkdir -p /tmp/.uci
for i in $(grep -s "^/etc/uci-defaults/" "/usr/lib/opkg/info/${pkgname}.list"); do
for i in $(grep -s "^/etc/uci-defaults/" "$filelist"); do
( [ -f "$i" ] && cd "$(dirname $i)" && . "$i" ) && rm -f "$i"
done
uci commit
......@@ -243,7 +260,7 @@ default_postinst() {
[ -n "$root" ] || rm -f /tmp/luci-indexcache 2>/dev/null
local shell="$(which bash)"
for i in $(grep -s "^/etc/init.d/" "$root/usr/lib/opkg/info/${pkgname}.list"); do
for i in $(grep -s "^/etc/init.d/" "$root$filelist"); do
if [ -n "$root" ]; then
${shell:-/bin/sh} "$root/etc/rc.common" "$root$i" enable
else
......
# Copyright (C) 2019 OpenWrt.org
. /lib/functions.sh
. /lib/functions/system.sh
caldata_die() {
echo "caldata: " "$*"
exit 1
}
caldata_extract() {
local part=$1
local offset=$(($2))
local count=$(($3))
local mtd
mtd=$(find_mtd_chardev $part)
[ -n "$mtd" ] || caldata_die "no mtd device found for partition $part"
dd if=$mtd of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \
caldata_die "failed to extract calibration data from $mtd"
}
caldata_extract_ubi() {
local part=$1
local offset=$(($2))
local count=$(($3))
local ubidev
local ubi
. /lib/upgrade/nand.sh
ubidev=$(nand_find_ubi $CI_UBIPART)
ubi=$(nand_find_volume $ubidev $part)
[ -n "$ubi" ] || caldata_die "no UBI volume found for $part"
dd if=/dev/$ubi of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \
caldata_die "failed to extract calibration data from $ubi"
}
caldata_extract_reverse() {
local part=$1
local offset=$2
local count=$(($3))
local mtd
local reversed
local caldata
mtd=$(find_mtd_chardev "$part")
reversed=$(hexdump -v -s $offset -n $count -e '/1 "%02x "' $mtd)
for byte in $reversed; do
caldata="\x${byte}${caldata}"
done
printf "%b" "$caldata" > /lib/firmware/$FIRMWARE
}
caldata_from_file() {
local source=$1
local offset=$(($2))
local count=$(($3))
dd if=$source of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \
caldata_die "failed to extract calibration data from $source"
}
caldata_valid() {
local expected="$1"
magic=$(hexdump -v -n 2 -e '1/1 "%02x"' /lib/firmware/$FIRMWARE)
[ "$magic" = "$expected" ]
return $?
}
caldata_patch_chksum() {
local mac=$1
local mac_offset=$(($2))
local chksum_offset=$(($3))
local xor_mac
local xor_fw_mac
local xor_fw_chksum
xor_mac=${mac//:/}
xor_mac="${xor_mac:0:4} ${xor_mac:4:4} ${xor_mac:8:4}"
xor_fw_mac=$(hexdump -v -n 6 -s $mac_offset -e '/1 "%02x"' /lib/firmware/$FIRMWARE)
xor_fw_mac="${xor_fw_mac:0:4} ${xor_fw_mac:4:4} ${xor_fw_mac:8:4}"
xor_fw_chksum=$(hexdump -v -n 2 -s $chksum_offset -e '/1 "%02x"' /lib/firmware/$FIRMWARE)
xor_fw_chksum=$(xor $xor_fw_chksum $xor_fw_mac $xor_mac)
printf "%b" "\x${xor_fw_chksum:0:2}\x${xor_fw_chksum:2:2}" | \
dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$chksum_offset count=2
}
caldata_patch_mac() {
local mac=$1
local mac_offset=$(($2))
local chksum_offset=$3
[ -z "$mac" -o -z "$mac_offset" ] && return
[ -n "$chksum_offset" ] && caldata_patch_chksum "$mac" "$mac_offset" "$chksum_offset"
macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc oflag=seek_bytes bs=6 seek=$mac_offset count=1 || \
caldata_die "failed to write MAC address to eeprom file"
}
ath9k_patch_mac() {
local mac=$1
caldata_patch_mac "$mac" 0x2
}
ath9k_patch_mac_crc() {
local mac=$1
local mac_offset=$2
local chksum_offset=$((mac_offset - 10))
caldata_patch_mac "$mac" "$mac_offset" "$chksum_offset"
}
ath10k_patch_mac() {
local mac=$1
caldata_patch_mac "$mac" 0x6 0x2
}
#!/bin/sh
. /lib/functions.sh
migrate_led_sysfs() {
local cfg="$1"; shift
local tuples="$@"
local sysfs
local name
config_get sysfs ${cfg} sysfs
config_get name ${cfg} name
[ -z "${sysfs}" ] && return
for tuple in ${tuples}; do
local old=${tuple%=*}
local new=${tuple#*=}
local new_sysfs
new_sysfs=$(echo ${sysfs} | sed "s/${old}/${new}/")
[ "${new_sysfs}" = "${sysfs}" ] && continue
uci set system.${cfg}.sysfs="${new_sysfs}"
logger -t led-migration "sysfs option of LED \"${name}\" updated to ${new_sysfs}"
done;
}
migrate_leds() {
config_load system
config_foreach migrate_led_sysfs led "$@"
}
migrations_apply() {
local realm="$1"
[ -n "$(uci changes ${realm})" ] && uci -q commit ${realm}
}
......@@ -271,6 +271,11 @@ network_is_up()
# 2: interface
network_get_protocol() { __network_ifstatus "$1" "$2" ".proto"; }
# determine the uptime of the given logical interface
# 1: destination variable
# 2: interface
network_get_uptime() { __network_ifstatus "$1" "$2" ".uptime"; }
# determine the metric of the given logical interface
# 1: destination variable
# 2: interface
......
# Copyright (C) 2006-2013 OpenWrt.org
. /usr/share/libubox/jshn.sh
get_mac_binary() {
local path="$1"
local offset="$2"
if [ -z "$path" ]; then
if ! [ -e "$path" ]; then
echo "get_mac_binary: file $path not found!" >&2
return
fi
......@@ -12,6 +14,44 @@ get_mac_binary() {
hexdump -v -n 6 -s $offset -e '5/1 "%02x:" 1/1 "%02x"' $path 2>/dev/null
}
get_mac_label_dt() {
local basepath="/proc/device-tree"
local macdevice="$(cat "$basepath/aliases/label-mac-device" 2>/dev/null)"
local macaddr
[ -n "$macdevice" ] || return
macaddr=$(get_mac_binary "$basepath/$macdevice/mac-address" 0 2>/dev/null)
[ -n "$macaddr" ] || macaddr=$(get_mac_binary "$basepath/$macdevice/local-mac-address" 0 2>/dev/null)
echo $macaddr
}
get_mac_label_json() {
local cfg="/etc/board.json"
local macaddr
[ -s "$cfg" ] || return
json_init
json_load "$(cat $cfg)"
if json_is_a system object; then
json_select system
json_get_var macaddr label_macaddr
json_select ..
fi
echo $macaddr
}
get_mac_label() {
local macaddr=$(get_mac_label_dt)
[ -n "$macaddr" ] || macaddr=$(get_mac_label_json)
echo $macaddr
}
find_mtd_chardev() {
local INDEX=$(find_mtd_index "$1")
local PREFIX=/dev/mtd
......@@ -40,7 +80,7 @@ mtd_get_mac_ascii() {
mtd_get_mac_text() {
local mtdname=$1
local offset=$2
local offset=$(($2))
local part
local mac_dirty
......@@ -79,12 +119,7 @@ mtd_get_mac_binary_ubi() {
local ubidev=$(nand_find_ubi $CI_UBIPART)
local part=$(nand_find_volume $ubidev $1)
if [ -z "$part" ]; then
echo "mtd_get_mac_binary: ubi volume $mtdname not found!" >&2
return
fi
hexdump -v -n 6 -s $offset -e '5/1 "%02x:" 1/1 "%02x"' /dev/$part 2>/dev/null
get_mac_binary "/dev/$part" "$offset"
}
mtd_get_part_size() {
......@@ -105,10 +140,17 @@ macaddr_add() {
local oui=${mac%:*:*:*}
local nic=${mac#*:*:*:}
nic=$(printf "%06x" $((0x${nic//:/} + $val & 0xffffff)) | sed 's/^\(.\{2\}\)\(.\{2\}\)\(.\{2\}\)/\1:\2:\3/')
nic=$(printf "%06x" $((0x${nic//:/} + val & 0xffffff)) | sed 's/^\(.\{2\}\)\(.\{2\}\)\(.\{2\}\)/\1:\2:\3/')
echo $oui:$nic
}
macaddr_geteui() {
local mac=$1
local sep=$2
echo ${mac:9:2}$sep${mac:12:2}$sep${mac:15:2}
}
macaddr_setbit_la() {
local mac=$1
......
......@@ -182,6 +182,19 @@ _ucidef_finish_switch_roles() {
done
}
ucidef_set_ar8xxx_switch_mib() {
local name="$1"
local type="$2"
local interval="$3"
json_select_object switch
json_select_object "$name"
json_add_int ar8xxx_mib_type $type
json_add_int ar8xxx_mib_poll_interval $interval
json_select ..
json_select ..
}
ucidef_add_switch() {
local name="$1"; shift
local port num role device index need_tag prev_role
......@@ -294,6 +307,14 @@ ucidef_set_interface_macaddr() {
ucidef_set_interface "$network" macaddr "$macaddr"
}
ucidef_set_label_macaddr() {
local macaddr="$1"
json_select_object system
json_add_string label_macaddr "$macaddr"
json_select ..
}
ucidef_add_atm_bridge() {
local vpi="$1"
local vci="$2"
......@@ -463,6 +484,7 @@ _ucidef_set_led_timer() {
_ucidef_set_led_common "$1" "$2" "$3"
json_add_string type "$trigger_name"
json_add_string trigger "$trigger_name"
json_add_int delayon "$delayon"
json_add_int delayoff "$delayoff"
......
......@@ -31,6 +31,8 @@ fs_wait_for_key () {
lock $keypress_wait
{
while [ $timer -gt 0 ]; do
pi_failsafe_net_message=true \
preinit_net_echo "Please press button now to enter failsafe"
echo "$timer" >$keypress_sec
timer=$(($timer - 1))
sleep 1
......@@ -88,9 +90,6 @@ failsafe_wait() {
}
grep -q 'failsafe=' /proc/cmdline && FAILSAFE=true && export FAILSAFE
if [ "$FAILSAFE" != "true" ]; then
pi_failsafe_net_message=true
preinit_net_echo "Please press button now to enter failsafe"
pi_failsafe_net_message=false
fs_wait_for_key f 'to enter failsafe mode' $fs_failsafe_wait_timeout && FAILSAFE=true
[ -f "/tmp/failsafe_button" ] && FAILSAFE=true && echo "- failsafe button "`cat /tmp/failsafe_button`" was pressed -"
[ "$FAILSAFE" = "true" ] && export FAILSAFE && touch /tmp/failsafe
......
......@@ -15,4 +15,4 @@ if [ \! -z "$1" -a -d /etc/hotplug.d/$1 ]; then
for script in $(ls /etc/hotplug.d/$1/* 2>&-); do (
[ -f $script ] && . $script
); done
fi
\ No newline at end of file
fi
......@@ -6,7 +6,7 @@
usage() {
cat <<EOF
Usage: $0 [config|up|down|reload|status]
Usage: $0 [config|up|down|reconf|reload|status]
enables (default), disables or configures devices not yet configured.
EOF
exit 1
......
......@@ -8,11 +8,11 @@ HOME_URL="%u"
BUG_URL="%b"
SUPPORT_URL="%s"
BUILD_ID="%R"
LEDE_BOARD="%S"
LEDE_ARCH="%A"
LEDE_TAINTS="%t"
LEDE_DEVICE_MANUFACTURER="%M"
LEDE_DEVICE_MANUFACTURER_URL="%m"
LEDE_DEVICE_PRODUCT="%P"
LEDE_DEVICE_REVISION="%h"
LEDE_RELEASE="%D %V %C"
OPENWRT_BOARD="%S"
OPENWRT_ARCH="%A"
OPENWRT_TAINTS="%t"
OPENWRT_DEVICE_MANUFACTURER="%M"
OPENWRT_DEVICE_MANUFACTURER_URL="%m"
OPENWRT_DEVICE_PRODUCT="%P"
OPENWRT_DEVICE_REVISION="%h"
OPENWRT_RELEASE="%D %V %C"
......@@ -183,7 +183,7 @@ if VERSIONOPT
config VERSION_REPO
string
prompt "Release repository"
default "http://downloads.lede-project.org/snapshots"
default "http://downloads.openwrt.org/snapshots"
help
This is the repository address embedded in the image, it defaults
to the trunk snapshot repo; the url may contain the following placeholders:
......
......@@ -194,9 +194,11 @@ foreach my $mirror (@ARGV) {
push @mirrors, "https://downloads.sourceforge.net/$1";
}
} elsif ($mirror =~ /^\@APACHE\/(.+)$/) {
push @mirrors, "https://mirrors.ustc.edu.cn/apache/$1";
push @mirrors, "https://mirror.netcologne.de/apache.org/$1";
push @mirrors, "https://mirror.aarnet.edu.au/pub/apache/$1";
push @mirrors, "https://mirror.csclub.uwaterloo.ca/apache/$1";
push @mirrors, "https://archive.apache.org/dist/$1";
push @mirrors, "http://mirror.cogentco.com/pub/apache/$1";
push @mirrors, "http://mirror.navercorp.com/apache/$1";
push @mirrors, "http://ftp.jaist.ac.jp/pub/apache/$1";
......@@ -212,6 +214,7 @@ foreach my $mirror (@ARGV) {
push @mirrors, "https://raw.githubusercontent.com/$dir";
}
} elsif ($mirror =~ /^\@GNU\/(.+)$/) {
push @mirrors, "https://mirrors.ustc.edu.cn/gnu/$1";
push @mirrors, "https://mirror.csclub.uwaterloo.ca/gnu/$1";
push @mirrors, "https://mirror.netcologne.de/gnu/$1";
push @mirrors, "http://ftp.kddilabs.jp/GNU/gnu/$1";
......@@ -235,19 +238,20 @@ foreach my $mirror (@ARGV) {
push @extra, "$extra[0]/testing";
} elsif ($filename =~ /linux-(\d+\.\d+(?:\.\d+)?)/) {
push @extra, "$extra[0]/longterm/v$1";
}
}
foreach my $dir (@extra) {
push @mirrors, "http://mirrors.ustc.edu.cn/kernel.org/$dir";
push @mirrors, "https://mirrors.ustc.edu.cn/kernel.org/$dir";
push @mirrors, "https://cdn.kernel.org/pub/$dir";
push @mirrors, "https://mirror.rackspace.com/kernel.org/$dir";
push @mirrors, "http://download.xs4all.nl/ftp.kernel.org/pub/$dir";
push @mirrors, "http://mirrors.mit.edu/kernel/$dir";
push @mirrors, "https://mirror.rackspace.com/kernel.org/pub/$dir";
push @mirrors, "https://download.xs4all.nl/ftp.kernel.org/pub/$dir";
push @mirrors, "https://mirrors.mit.edu/kernel/$dir";
push @mirrors, "http://ftp.nara.wide.ad.jp/pub/kernel.org/$dir";
push @mirrors, "http://www.ring.gr.jp/archives/linux/kernel.org/$dir";
push @mirrors, "ftp://ftp.riken.jp/Linux/kernel.org/$dir";
push @mirrors, "ftp://www.mirrorservice.org/sites/ftp.kernel.org/pub/$dir";
}
} elsif ($mirror =~ /^\@GNOME\/(.+)$/) {
push @mirrors, "https://mirrors.ustc.edu.cn/gnome/sources/$1";
push @mirrors, "https://mirror.csclub.uwaterloo.ca/gnome/sources/$1";
push @mirrors, "http://ftp.acc.umu.se/pub/GNOME/sources/$1";
push @mirrors, "http://ftp.kaist.ac.kr/gnome/sources/$1";
......@@ -263,9 +267,8 @@ foreach my $mirror (@ARGV) {
}
#push @mirrors, 'https://mirror1.openwrt.org';
push @mirrors, 'https://sources.lede-project.org';
push @mirrors, 'https://sources.openwrt.org';
push @mirrors, 'https://mirror2.openwrt.org/sources';
push @mirrors, 'https://downloads.openwrt.org/sources';
while (!-f "$target/$filename") {
my $mirror = shift @mirrors;
......@@ -275,4 +278,3 @@ while (!-f "$target/$filename") {
}
$SIG{INT} = \&cleanup;
#!/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"))
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="dns-prefetch" href="https://github.githubassets.com">
<link rel="dns-prefetch" href="https://avatars0.githubusercontent.com">
<link rel="dns-prefetch" href="https://avatars1.githubusercontent.com">
<link rel="dns-prefetch" href="https://avatars2.githubusercontent.com">
<link rel="dns-prefetch" href="https://avatars3.githubusercontent.com">
<link rel="dns-prefetch" href="https://github-cloud.s3.amazonaws.com">
<link rel="dns-prefetch" href="https://user-images.githubusercontent.com/">
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()))
<link crossorigin="anonymous" media="all" integrity="sha512-4bmhxCob3U2WoK8HVl7UacoDdNejo+50BlGN9SdGtjXbsCQwp7uLtntLkL9a9CmgLPZ8L9lsOZL0ieINT9yHeA==" rel="stylesheet" href="https://github.githubassets.com/assets/frameworks-2fd1891c9e6292401a1a3de8bc3f747f.css" />
<link crossorigin="anonymous" media="all" integrity="sha512-1N4+QlbmRp6tyqxbm0KgsAq2CEnAm9g3BY5xUsD38O+IUdydhO7ltbRnpR2Vn4g5SXipGWiiwQO1HUYLDV136Q==" rel="stylesheet" href="https://github.githubassets.com/assets/site-09367dd1ae1784b858e71c8471ca0949.css" />
<link crossorigin="anonymous" media="all" integrity="sha512-oF4BPgLoJ4I8H6vdTzR4cGdwAF4bC/bdeI7zsQ/xzUbUWc+JU6xeSbOxIgOyelZP+1ESc5qfwDKzYQfdDNlX5Q==" rel="stylesheet" href="https://github.githubassets.com/assets/github-5238587550334d8b43fd71226c6de55c.css" />
if title:
titles.append(title)
<meta name="viewport" content="width=device-width">
<title>openwrt/json_add_image_info.py at master · openwrt/openwrt · GitHub</title>
<meta name="description" content="This repository is a mirror of https://git.openwrt.org/openwrt/openwrt.git It is for reference only and is not active for check-ins or for reporting issues. We will continue to accept Pull Requests here. They will be merged via staging trees then into openwrt.git. All issues should be reported at: https://bugs.openwrt.org - openwrt/openwrt">
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="GitHub">
<link rel="fluid-icon" href="https://github.com/fluidicon.png" title="GitHub">
<meta property="fb:app_id" content="1401488693436528">
if not titles:
titles.append({"title": e("DEVICE_TITLE")})
<meta name="twitter:image:src" content="https://avatars2.githubusercontent.com/u/2528830?s=400&amp;v=4" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary" /><meta name="twitter:title" content="openwrt/openwrt" /><meta name="twitter:description" content="This repository is a mirror of https://git.openwrt.org/openwrt/openwrt.git It is for reference only and is not active for check-ins or for reporting issues. We will continue to accept Pull Request..." />
<meta property="og:image" content="https://avatars2.githubusercontent.com/u/2528830?s=400&amp;v=4" /><meta property="og:site_name" content="GitHub" /><meta property="og:type" content="object" /><meta property="og:title" content="openwrt/openwrt" /><meta property="og:url" content="https://github.com/openwrt/openwrt" /><meta property="og:description" content="This repository is a mirror of https://git.openwrt.org/openwrt/openwrt.git It is for reference only and is not active for check-ins or for reporting issues. We will continue to accept Pull Request..." />
return titles
<link rel="assets" href="https://github.githubassets.com/">
<meta name="request-id" content="CE8B:322B:EBD1C4:156E56F:5DAC4D0A" data-pjax-transient>
<meta name="selected-link" value="repo_source" data-pjax-transient>
<meta name="google-site-verification" content="KT5gs8h0wvaagLKAVWq8bbeNwnZZK1r1XQysX3xurLU">
<meta name="google-site-verification" content="ZzhVyEFwb7w3e0-uOTltm8Jsck2F5StVihD0exw2fsA">
<meta name="google-site-verification" content="GXs5KoUUkNCoaAZn7wPN-t01Pywp9M3sEjnt_3_ZWPc">
<meta name="octolytics-host" content="collector.githubapp.com" /><meta name="octolytics-app-id" content="github" /><meta name="octolytics-event-url" content="https://collector.githubapp.com/github-external/browser_event" /><meta name="octolytics-dimension-request_id" content="CE8B:322B:EBD1C4:156E56F:5DAC4D0A" /><meta name="octolytics-dimension-region_edge" content="ap-northeast-1" /><meta name="octolytics-dimension-region_render" content="iad" /><meta name="octolytics-dimension-ga_id" content="" class="js-octo-ga-id" /><meta name="octolytics-dimension-visitor_id" content="2470552824743480586" />
<meta name="analytics-location" content="/&lt;user-name&gt;/&lt;repo-name&gt;/blob/show" data-pjax-transient="true" />
<meta name="google-analytics" content="UA-3769691-2">
<meta class="js-ga-set" name="dimension1" content="Logged Out">
<meta name="hostname" content="github.com">
<meta name="user-login" content="">
<meta name="expected-hostname" content="github.com">
<meta name="js-proxy-site-detection-payload" content="NDc4NjdlMjE2MTBjNGRjYzNjNjVlOWNkOGE0YWEyZDQ3ZTBmNTBhMzM1OWRkYmJjNDAzNTA4Y2RhMjU3ODRjZnx7InJlbW90ZV9hZGRyZXNzIjoiMjEzLjEzOS4yMzIuMzMiLCJyZXF1ZXN0X2lkIjoiQ0U4QjozMjJCOkVCRDFDNDoxNTZFNTZGOjVEQUM0RDBBIiwidGltZXN0YW1wIjoxNTcxNTczMDAyLCJob3N0IjoiZ2l0aHViLmNvbSJ9">
<meta name="enabled-features" content="ACTIONS_V2_ON_MARKETPLACE,MARKETPLACE_FEATURED_BLOG_POSTS,MARKETPLACE_INVOICED_BILLING,MARKETPLACE_SOCIAL_PROOF_CUSTOMERS,MARKETPLACE_TRENDING_SOCIAL_PROOF,MARKETPLACE_RECOMMENDATIONS,MARKETPLACE_PENDING_INSTALLATIONS">
<meta name="html-safe-nonce" content="f6807a1146487cca179485d3b1d2f760ac8dca40">
<meta http-equiv="x-pjax-version" content="1cf606da5c0eb0678f3df7841bd6b83a">
<link href="https://github.com/openwrt/openwrt/commits/master.atom" rel="alternate" title="Recent Commits to openwrt:master" type="application/atom+xml">
<meta name="go-import" content="github.com/openwrt/openwrt git https://github.com/openwrt/openwrt.git">
<meta name="octolytics-dimension-user_id" content="2528830" /><meta name="octolytics-dimension-user_login" content="openwrt" /><meta name="octolytics-dimension-repository_id" content="45821540" /><meta name="octolytics-dimension-repository_nwo" content="openwrt/openwrt" /><meta name="octolytics-dimension-repository_public" content="true" /><meta name="octolytics-dimension-repository_is_fork" content="false" /><meta name="octolytics-dimension-repository_network_root_id" content="45821540" /><meta name="octolytics-dimension-repository_network_root_nwo" content="openwrt/openwrt" /><meta name="octolytics-dimension-repository_explore_github_marketplace_ci_cta_shown" content="false" />
<link rel="canonical" href="https://github.com/openwrt/openwrt/blob/master/scripts/json_add_image_info.py" data-pjax-transient>
<meta name="browser-stats-url" content="https://api.github.com/_private/browser/stats">
<meta name="browser-errors-url" content="https://api.github.com/_private/browser/errors">
<link rel="mask-icon" href="https://github.githubassets.com/pinned-octocat.svg" color="#000000">
<link rel="icon" type="image/x-icon" class="js-site-favicon" href="https://github.githubassets.com/favicon.ico">
<meta name="theme-color" content="#1e2327">
<link rel="manifest" href="/manifest.json" crossOrigin="use-credentials">
</head>
<body class="logged-out env-production page-responsive page-blob">
<div class="position-relative js-header-wrapper ">
<a href="#start-of-content" tabindex="1" class="px-2 py-4 bg-blue text-white show-on-focus js-skip-to-content">Skip to content</a>
<span class="Progress progress-pjax-loader position-fixed width-full js-pjax-loader-bar">
<span class="progress-pjax-loader-bar top-0 left-0" style="width: 0%;"></span>
</span>
<header class="Header-old header-logged-out js-details-container Details position-relative f4 py-2" role="banner">
<div class="container-lg d-lg-flex flex-items-center p-responsive">
<div class="d-flex flex-justify-between flex-items-center">
<a class="mr-4" href="https://github.com/" aria-label="Homepage" data-ga-click="(Logged out) Header, go to homepage, icon:logo-wordmark">
<svg height="32" class="octicon octicon-mark-github text-white" viewBox="0 0 16 16" version="1.1" width="32" aria-hidden="true"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"/></svg>
</a>
<div class="d-lg-none css-truncate css-truncate-target width-fit p-2">
<svg class="octicon octicon-repo" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M4 9H3V8h1v1zm0-3H3v1h1V6zm0-2H3v1h1V4zm0-2H3v1h1V2zm8-1v12c0 .55-.45 1-1 1H6v2l-1.5-1.5L3 16v-2H1c-.55 0-1-.45-1-1V1c0-.55.45-1 1-1h10c.55 0 1 .45 1 1zm-1 10H1v2h2v-1h3v1h5v-2zm0-10H2v9h9V1z"/></svg>
<a class="Header-link" href="/openwrt">openwrt</a>
/
<a class="Header-link" href="/openwrt/openwrt">openwrt</a>
</div>
<div class="d-flex flex-items-center">
<a href="/join?source=header-repo"
class="d-inline-block d-lg-none f5 text-white no-underline border border-gray-dark rounded-2 px-2 py-1 mr-3 mr-sm-5"
data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;site header&quot;,&quot;repository_id&quot;:null,&quot;auth_type&quot;:&quot;SIGN_UP&quot;,&quot;client_id&quot;:null,&quot;originating_request_id&quot;:&quot;CE8B:322B:EBD1C4:156E56F:5DAC4D0A&quot;,&quot;originating_url&quot;:&quot;https://github.com/openwrt/openwrt/blob/master/scripts/json_add_image_info.py&quot;,&quot;referrer&quot;:null,&quot;user_id&quot;:null}}" data-hydro-click-hmac="a47a83e14320f2bba56224800bfbc0bad8d3aa7a1e4976ce3ca329953788062e"
data-ga-click="(Logged out) Header, clicked Sign up, text:sign-up">
Sign&nbsp;up
</a>
<button class="btn-link d-lg-none mt-1 js-details-target" type="button" aria-label="Toggle navigation" aria-expanded="false">
<svg height="24" class="octicon octicon-three-bars text-white" viewBox="0 0 12 16" version="1.1" width="18" aria-hidden="true"><path fill-rule="evenodd" d="M11.41 9H.59C0 9 0 8.59 0 8c0-.59 0-1 .59-1H11.4c.59 0 .59.41.59 1 0 .59 0 1-.59 1h.01zm0-4H.59C0 5 0 4.59 0 4c0-.59 0-1 .59-1H11.4c.59 0 .59.41.59 1 0 .59 0 1-.59 1h.01zM.59 11H11.4c.59 0 .59.41.59 1 0 .59 0 1-.59 1H.59C0 13 0 12.59 0 12c0-.59 0-1 .59-1z"/></svg>
</button>
</div>
</div>
<div class="HeaderMenu HeaderMenu--logged-out position-fixed top-0 right-0 bottom-0 height-fit position-lg-relative d-lg-flex flex-justify-between flex-items-center flex-auto">
<div class="d-flex d-lg-none flex-justify-end border-bottom bg-gray-light p-3">
<button class="btn-link js-details-target" type="button" aria-label="Toggle navigation" aria-expanded="false">
<svg height="24" class="octicon octicon-x text-gray" viewBox="0 0 12 16" version="1.1" width="18" aria-hidden="true"><path fill-rule="evenodd" d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48L7.48 8z"/></svg>
</button>
</div>
<nav class="mt-0 px-3 px-lg-0 mb-5 mb-lg-0" aria-label="Global">
<ul class="d-lg-flex list-style-none">
<li class="d-block d-lg-flex flex-lg-nowrap flex-lg-items-center border-bottom border-lg-bottom-0 mr-0 mr-lg-3 edge-item-fix position-relative flex-wrap flex-justify-between d-flex flex-items-center ">
<details class="HeaderMenu-details details-overlay details-reset width-full">
<summary class="HeaderMenu-summary HeaderMenu-link px-0 py-3 border-0 no-wrap d-block d-lg-inline-block">
Why GitHub?
<svg x="0px" y="0px" viewBox="0 0 14 8" xml:space="preserve" fill="none" class="icon-chevon-down-mktg position-absolute position-lg-relative">
<path d="M1,1l6.2,6L13,1"></path>
</svg>
</summary>
<div class="dropdown-menu flex-auto rounded-1 bg-white px-0 mt-0 pb-4 p-lg-4 position-relative position-lg-absolute left-0 left-lg-n4">
<a href="/features" class="py-2 lh-condensed-ultra d-block link-gray-dark no-underline h5 Bump-link--hover" data-ga-click="(Logged out) Header, go to Features">Features <span class="Bump-link-symbol float-right text-normal text-gray-light">&rarr;</span></a>
<ul class="list-style-none f5 pb-3">
<li class="edge-item-fix"><a href="/features/code-review/" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Code review">Code review</a></li>
<li class="edge-item-fix"><a href="/features/project-management/" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Project management">Project management</a></li>
<li class="edge-item-fix"><a href="/features/integrations" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Integrations">Integrations</a></li>
<li class="edge-item-fix"><a href="/features/actions" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Actions">Actions</a>
<li class="edge-item-fix"><a href="/features/package-registry" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Package Registry">Package registry</a>
<li class="edge-item-fix"><a href="/features/security" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Security">Security</a>
<li class="edge-item-fix"><a href="/features#team-management" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Team management">Team management</a></li>
<li class="edge-item-fix"><a href="/features#social-coding" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Social coding">Social coding</a></li>
<li class="edge-item-fix"><a href="/features#documentation" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Documentation">Documentation</a></li>
<li class="edge-item-fix"><a href="/features#code-hosting" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Code hosting">Code hosting</a></li>
</ul>
<ul class="list-style-none mb-0 border-lg-top pt-lg-3">
<li class="edge-item-fix"><a href="/customer-stories" class="py-2 lh-condensed-ultra d-block no-underline link-gray-dark no-underline h5 Bump-link--hover" data-ga-click="(Logged out) Header, go to Customer stories">Customer stories <span class="Bump-link-symbol float-right text-normal text-gray-light">&rarr;</span></a></li>
<li class="edge-item-fix"><a href="/security" class="py-2 lh-condensed-ultra d-block no-underline link-gray-dark no-underline h5 Bump-link--hover" data-ga-click="(Logged out) Header, go to Security">Security <span class="Bump-link-symbol float-right text-normal text-gray-light">&rarr;</span></a></li>
</ul>
</div>
</details>
</li>
<li class="border-bottom border-lg-bottom-0 mr-0 mr-lg-3">
<a href="/enterprise" class="HeaderMenu-link no-underline py-3 d-block d-lg-inline-block" data-ga-click="(Logged out) Header, go to Enterprise">Enterprise</a>
</li>
<li class="d-block d-lg-flex flex-lg-nowrap flex-lg-items-center border-bottom border-lg-bottom-0 mr-0 mr-lg-3 edge-item-fix position-relative flex-wrap flex-justify-between d-flex flex-items-center ">
<details class="HeaderMenu-details details-overlay details-reset width-full">
<summary class="HeaderMenu-summary HeaderMenu-link px-0 py-3 border-0 no-wrap d-block d-lg-inline-block">
Explore
<svg x="0px" y="0px" viewBox="0 0 14 8" xml:space="preserve" fill="none" class="icon-chevon-down-mktg position-absolute position-lg-relative">
<path d="M1,1l6.2,6L13,1"></path>
</svg>
</summary>
<div class="dropdown-menu flex-auto rounded-1 bg-white px-0 pt-2 pb-0 mt-0 pb-4 p-lg-4 position-relative position-lg-absolute left-0 left-lg-n4">
<ul class="list-style-none mb-3">
<li class="edge-item-fix"><a href="/explore" class="py-2 lh-condensed-ultra d-block link-gray-dark no-underline h5 Bump-link--hover" data-ga-click="(Logged out) Header, go to Explore">Explore GitHub <span class="Bump-link-symbol float-right text-normal text-gray-light">&rarr;</span></a></li>
</ul>
<h4 class="text-gray-light text-normal text-mono f5 mb-2 border-lg-top pt-lg-3">Learn &amp; contribute</h4>
<ul class="list-style-none mb-3">
<li class="edge-item-fix"><a href="/topics" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Topics">Topics</a></li>
<li class="edge-item-fix"><a href="/collections" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Collections">Collections</a></li>
<li class="edge-item-fix"><a href="/trending" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Trending">Trending</a></li>
<li class="edge-item-fix"><a href="https://lab.github.com/" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Learning lab">Learning Lab</a></li>
<li class="edge-item-fix"><a href="https://opensource.guide" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Open source guides">Open source guides</a></li>
</ul>
<h4 class="text-gray-light text-normal text-mono f5 mb-2 border-lg-top pt-lg-3">Connect with others</h4>
<ul class="list-style-none mb-0">
<li class="edge-item-fix"><a href="https://github.com/events" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Events">Events</a></li>
<li class="edge-item-fix"><a href="https://github.community" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Community forum">Community forum</a></li>
<li class="edge-item-fix"><a href="https://education.github.com" class="py-2 pb-0 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to GitHub Education">GitHub Education</a></li>
</ul>
</div>
</details>
</li>
<li class="border-bottom border-lg-bottom-0 mr-0 mr-lg-3">
<a href="/marketplace" class="HeaderMenu-link no-underline py-3 d-block d-lg-inline-block" data-ga-click="(Logged out) Header, go to Marketplace">Marketplace</a>
</li>
<li class="d-block d-lg-flex flex-lg-nowrap flex-lg-items-center border-bottom border-lg-bottom-0 mr-0 mr-lg-3 edge-item-fix position-relative flex-wrap flex-justify-between d-flex flex-items-center ">
<details class="HeaderMenu-details details-overlay details-reset width-full">
<summary class="HeaderMenu-summary HeaderMenu-link px-0 py-3 border-0 no-wrap d-block d-lg-inline-block">
Pricing
<svg x="0px" y="0px" viewBox="0 0 14 8" xml:space="preserve" fill="none" class="icon-chevon-down-mktg position-absolute position-lg-relative">
<path d="M1,1l6.2,6L13,1"></path>
</svg>
</summary>
<div class="dropdown-menu flex-auto rounded-1 bg-white px-0 pt-2 pb-4 mt-0 p-lg-4 position-relative position-lg-absolute left-0 left-lg-n4">
<a href="/pricing" class="pb-2 lh-condensed-ultra d-block link-gray-dark no-underline h5 Bump-link--hover" data-ga-click="(Logged out) Header, go to Pricing">Plans <span class="Bump-link-symbol float-right text-normal text-gray-light">&rarr;</span></a>
<ul class="list-style-none mb-3">
<li class="edge-item-fix"><a href="/pricing#feature-comparison" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Compare plans">Compare plans</a></li>
<li class="edge-item-fix"><a href="https://enterprise.github.com/contact" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Contact Sales">Contact Sales</a></li>
</ul>
<ul class="list-style-none mb-0 border-lg-top pt-lg-3">
<li class="edge-item-fix"><a href="/nonprofit" class="py-2 lh-condensed-ultra d-block no-underline link-gray-dark no-underline h5 Bump-link--hover" data-ga-click="(Logged out) Header, go to Nonprofits">Nonprofit <span class="Bump-link-symbol float-right text-normal text-gray-light">&rarr;</span></a></li>
<li class="edge-item-fix"><a href="https://education.github.com" class="py-2 pb-0 lh-condensed-ultra d-block no-underline link-gray-dark no-underline h5 Bump-link--hover" data-ga-click="(Logged out) Header, go to Education">Education <span class="Bump-link-symbol float-right text-normal text-gray-light">&rarr;</span></a></li>
</ul>
</div>
</details>
</li>
</ul>
</nav>
<div class="d-lg-flex flex-items-center px-3 px-lg-0 text-center text-lg-left">
<div class="d-lg-flex mb-3 mb-lg-0">
<div class="header-search flex-self-stretch flex-lg-self-auto mr-0 mr-lg-3 mb-3 mb-lg-0 scoped-search site-scoped-search js-site-search position-relative js-jump-to"
role="combobox"
aria-owns="jump-to-results"
aria-label="Search or jump to"
aria-haspopup="listbox"
aria-expanded="false"
>
<div class="position-relative">
<!-- '"` --><!-- </textarea></xmp> --></option></form><form class="js-site-search-form" role="search" aria-label="Site" data-scope-type="Repository" data-scope-id="45821540" data-scoped-search-url="/openwrt/openwrt/search" data-unscoped-search-url="/search" action="/openwrt/openwrt/search" accept-charset="UTF-8" method="get"><input name="utf8" type="hidden" value="&#x2713;" />
<label class="form-control input-sm header-search-wrapper p-0 header-search-wrapper-jump-to position-relative d-flex flex-justify-between flex-items-center js-chromeless-input-container">
<input type="text"
class="form-control input-sm header-search-input jump-to-field js-jump-to-field js-site-search-focus js-site-search-field is-clearable"
data-hotkey="s,/"
name="q"
value=""
placeholder="Search"
data-unscoped-placeholder="Search GitHub"
data-scoped-placeholder="Search"
autocapitalize="off"
aria-autocomplete="list"
aria-controls="jump-to-results"
aria-label="Search"
data-jump-to-suggestions-path="/_graphql/GetSuggestedNavigationDestinations#csrf-token=xR7n7HnDSwt+XFilcsVwfyKKj+D3i8DaaBNt6/OIwRAVh5SGdtCvTzCoIPi1aIiLQB00NAgiaF67REQ1/qF/fA=="
spellcheck="false"
autocomplete="off"
>
<input type="hidden" class="js-site-search-type-field" name="type" >
<img src="https://github.githubassets.com/images/search-key-slash.svg" alt="" class="mr-2 header-search-key-slash">
<div class="Box position-absolute overflow-hidden d-none jump-to-suggestions js-jump-to-suggestions-container">
<ul class="d-none js-jump-to-suggestions-template-container">
<li class="d-flex flex-justify-start flex-items-center p-0 f5 navigation-item js-navigation-item js-jump-to-suggestion" role="option">
<a tabindex="-1" class="no-underline d-flex flex-auto flex-items-center jump-to-suggestions-path js-jump-to-suggestion-path js-navigation-open p-2" href="">
<div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none">
<svg height="16" width="16" class="octicon octicon-repo flex-shrink-0 js-jump-to-octicon-repo d-none" title="Repository" aria-label="Repository" viewBox="0 0 12 16" version="1.1" role="img"><path fill-rule="evenodd" d="M4 9H3V8h1v1zm0-3H3v1h1V6zm0-2H3v1h1V4zm0-2H3v1h1V2zm8-1v12c0 .55-.45 1-1 1H6v2l-1.5-1.5L3 16v-2H1c-.55 0-1-.45-1-1V1c0-.55.45-1 1-1h10c.55 0 1 .45 1 1zm-1 10H1v2h2v-1h3v1h5v-2zm0-10H2v9h9V1z"/></svg>
<svg height="16" width="16" class="octicon octicon-project flex-shrink-0 js-jump-to-octicon-project d-none" title="Project" aria-label="Project" viewBox="0 0 15 16" version="1.1" role="img"><path fill-rule="evenodd" d="M10 12h3V2h-3v10zm-4-2h3V2H6v8zm-4 4h3V2H2v12zm-1 1h13V1H1v14zM14 0H1a1 1 0 00-1 1v14a1 1 0 001 1h13a1 1 0 001-1V1a1 1 0 00-1-1z"/></svg>
<svg height="16" width="16" class="octicon octicon-search flex-shrink-0 js-jump-to-octicon-search d-none" title="Search" aria-label="Search" viewBox="0 0 16 16" version="1.1" role="img"><path fill-rule="evenodd" d="M15.7 13.3l-3.81-3.83A5.93 5.93 0 0013 6c0-3.31-2.69-6-6-6S1 2.69 1 6s2.69 6 6 6c1.3 0 2.48-.41 3.47-1.11l3.83 3.81c.19.2.45.3.7.3.25 0 .52-.09.7-.3a.996.996 0 000-1.41v.01zM7 10.7c-2.59 0-4.7-2.11-4.7-4.7 0-2.59 2.11-4.7 4.7-4.7 2.59 0 4.7 2.11 4.7 4.7 0 2.59-2.11 4.7-4.7 4.7z"/></svg>
</div>
<img class="avatar mr-2 flex-shrink-0 js-jump-to-suggestion-avatar d-none" alt="" aria-label="Team" src="" width="28" height="28">
<div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target">
</div>
<div class="border rounded-1 flex-shrink-0 bg-gray px-1 text-gray-light ml-1 f6 d-none js-jump-to-badge-search">
<span class="js-jump-to-badge-search-text-default d-none" aria-label="in this repository">
In this repository
</span>
<span class="js-jump-to-badge-search-text-global d-none" aria-label="in all of GitHub">
All GitHub
</span>
<span aria-hidden="true" class="d-inline-block ml-1 v-align-middle">↵</span>
</div>
<div aria-hidden="true" class="border rounded-1 flex-shrink-0 bg-gray px-1 text-gray-light ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump">
Jump to
<span class="d-inline-block ml-1 v-align-middle">↵</span>
</div>
</a>
</li>
</ul>
<ul class="d-none js-jump-to-no-results-template-container">
<li class="d-flex flex-justify-center flex-items-center f5 d-none js-jump-to-suggestion p-2">
<span class="text-gray">No suggested jump to results</span>
</li>
</ul>
<ul id="jump-to-results" role="listbox" class="p-0 m-0 js-navigation-container jump-to-suggestions-results-container js-jump-to-suggestions-results-container">
<li class="d-flex flex-justify-start flex-items-center p-0 f5 navigation-item js-navigation-item js-jump-to-scoped-search d-none" role="option">
<a tabindex="-1" class="no-underline d-flex flex-auto flex-items-center jump-to-suggestions-path js-jump-to-suggestion-path js-navigation-open p-2" href="">
<div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none">
<svg height="16" width="16" class="octicon octicon-repo flex-shrink-0 js-jump-to-octicon-repo d-none" title="Repository" aria-label="Repository" viewBox="0 0 12 16" version="1.1" role="img"><path fill-rule="evenodd" d="M4 9H3V8h1v1zm0-3H3v1h1V6zm0-2H3v1h1V4zm0-2H3v1h1V2zm8-1v12c0 .55-.45 1-1 1H6v2l-1.5-1.5L3 16v-2H1c-.55 0-1-.45-1-1V1c0-.55.45-1 1-1h10c.55 0 1 .45 1 1zm-1 10H1v2h2v-1h3v1h5v-2zm0-10H2v9h9V1z"/></svg>
<svg height="16" width="16" class="octicon octicon-project flex-shrink-0 js-jump-to-octicon-project d-none" title="Project" aria-label="Project" viewBox="0 0 15 16" version="1.1" role="img"><path fill-rule="evenodd" d="M10 12h3V2h-3v10zm-4-2h3V2H6v8zm-4 4h3V2H2v12zm-1 1h13V1H1v14zM14 0H1a1 1 0 00-1 1v14a1 1 0 001 1h13a1 1 0 001-1V1a1 1 0 00-1-1z"/></svg>
<svg height="16" width="16" class="octicon octicon-search flex-shrink-0 js-jump-to-octicon-search d-none" title="Search" aria-label="Search" viewBox="0 0 16 16" version="1.1" role="img"><path fill-rule="evenodd" d="M15.7 13.3l-3.81-3.83A5.93 5.93 0 0013 6c0-3.31-2.69-6-6-6S1 2.69 1 6s2.69 6 6 6c1.3 0 2.48-.41 3.47-1.11l3.83 3.81c.19.2.45.3.7.3.25 0 .52-.09.7-.3a.996.996 0 000-1.41v.01zM7 10.7c-2.59 0-4.7-2.11-4.7-4.7 0-2.59 2.11-4.7 4.7-4.7 2.59 0 4.7 2.11 4.7 4.7 0 2.59-2.11 4.7-4.7 4.7z"/></svg>
</div>
<img class="avatar mr-2 flex-shrink-0 js-jump-to-suggestion-avatar d-none" alt="" aria-label="Team" src="" width="28" height="28">
<div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target">
</div>
<div class="border rounded-1 flex-shrink-0 bg-gray px-1 text-gray-light ml-1 f6 d-none js-jump-to-badge-search">
<span class="js-jump-to-badge-search-text-default d-none" aria-label="in this repository">
In this repository
</span>
<span class="js-jump-to-badge-search-text-global d-none" aria-label="in all of GitHub">
All GitHub
</span>
<span aria-hidden="true" class="d-inline-block ml-1 v-align-middle">↵</span>
</div>
<div aria-hidden="true" class="border rounded-1 flex-shrink-0 bg-gray px-1 text-gray-light ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump">
Jump to
<span class="d-inline-block ml-1 v-align-middle">↵</span>
</div>
</a>
</li>
<li class="d-flex flex-justify-start flex-items-center p-0 f5 navigation-item js-navigation-item js-jump-to-global-search d-none" role="option">
<a tabindex="-1" class="no-underline d-flex flex-auto flex-items-center jump-to-suggestions-path js-jump-to-suggestion-path js-navigation-open p-2" href="">
<div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none">
<svg height="16" width="16" class="octicon octicon-repo flex-shrink-0 js-jump-to-octicon-repo d-none" title="Repository" aria-label="Repository" viewBox="0 0 12 16" version="1.1" role="img"><path fill-rule="evenodd" d="M4 9H3V8h1v1zm0-3H3v1h1V6zm0-2H3v1h1V4zm0-2H3v1h1V2zm8-1v12c0 .55-.45 1-1 1H6v2l-1.5-1.5L3 16v-2H1c-.55 0-1-.45-1-1V1c0-.55.45-1 1-1h10c.55 0 1 .45 1 1zm-1 10H1v2h2v-1h3v1h5v-2zm0-10H2v9h9V1z"/></svg>
<svg height="16" width="16" class="octicon octicon-project flex-shrink-0 js-jump-to-octicon-project d-none" title="Project" aria-label="Project" viewBox="0 0 15 16" version="1.1" role="img"><path fill-rule="evenodd" d="M10 12h3V2h-3v10zm-4-2h3V2H6v8zm-4 4h3V2H2v12zm-1 1h13V1H1v14zM14 0H1a1 1 0 00-1 1v14a1 1 0 001 1h13a1 1 0 001-1V1a1 1 0 00-1-1z"/></svg>
<svg height="16" width="16" class="octicon octicon-search flex-shrink-0 js-jump-to-octicon-search d-none" title="Search" aria-label="Search" viewBox="0 0 16 16" version="1.1" role="img"><path fill-rule="evenodd" d="M15.7 13.3l-3.81-3.83A5.93 5.93 0 0013 6c0-3.31-2.69-6-6-6S1 2.69 1 6s2.69 6 6 6c1.3 0 2.48-.41 3.47-1.11l3.83 3.81c.19.2.45.3.7.3.25 0 .52-.09.7-.3a.996.996 0 000-1.41v.01zM7 10.7c-2.59 0-4.7-2.11-4.7-4.7 0-2.59 2.11-4.7 4.7-4.7 2.59 0 4.7 2.11 4.7 4.7 0 2.59-2.11 4.7-4.7 4.7z"/></svg>
</div>
<img class="avatar mr-2 flex-shrink-0 js-jump-to-suggestion-avatar d-none" alt="" aria-label="Team" src="" width="28" height="28">
<div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target">
</div>
<div class="border rounded-1 flex-shrink-0 bg-gray px-1 text-gray-light ml-1 f6 d-none js-jump-to-badge-search">
<span class="js-jump-to-badge-search-text-default d-none" aria-label="in this repository">
In this repository
</span>
<span class="js-jump-to-badge-search-text-global d-none" aria-label="in all of GitHub">
All GitHub
</span>
<span aria-hidden="true" class="d-inline-block ml-1 v-align-middle">↵</span>
</div>
<div aria-hidden="true" class="border rounded-1 flex-shrink-0 bg-gray px-1 text-gray-light ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump">
Jump to
<span class="d-inline-block ml-1 v-align-middle">↵</span>
</div>
</a>
</li>
</ul>
</div>
</label>
</form> </div>
</div>
</div>
<a href="/login?return_to=%2Fopenwrt%2Fopenwrt%2Fblob%2Fmaster%2Fscripts%2Fjson_add_image_info.py"
class="HeaderMenu-link no-underline mr-3"
data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;site header menu&quot;,&quot;repository_id&quot;:null,&quot;auth_type&quot;:&quot;SIGN_UP&quot;,&quot;client_id&quot;:null,&quot;originating_request_id&quot;:&quot;CE8B:322B:EBD1C4:156E56F:5DAC4D0A&quot;,&quot;originating_url&quot;:&quot;https://github.com/openwrt/openwrt/blob/master/scripts/json_add_image_info.py&quot;,&quot;referrer&quot;:null,&quot;user_id&quot;:null}}" data-hydro-click-hmac="360baf2ff288cc760d0d8226c04f0e38800e6bf2a94cf089ef5cb6d5cc247ef5"
data-ga-click="(Logged out) Header, clicked Sign in, text:sign-in">
Sign&nbsp;in
</a>
<a href="/join?source=header-repo&amp;source_repo=openwrt%2Fopenwrt"
class="HeaderMenu-link d-inline-block no-underline border border-gray-dark rounded-1 px-2 py-1"
data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;site header menu&quot;,&quot;repository_id&quot;:null,&quot;auth_type&quot;:&quot;SIGN_UP&quot;,&quot;client_id&quot;:null,&quot;originating_request_id&quot;:&quot;CE8B:322B:EBD1C4:156E56F:5DAC4D0A&quot;,&quot;originating_url&quot;:&quot;https://github.com/openwrt/openwrt/blob/master/scripts/json_add_image_info.py&quot;,&quot;referrer&quot;:null,&quot;user_id&quot;:null}}" data-hydro-click-hmac="360baf2ff288cc760d0d8226c04f0e38800e6bf2a94cf089ef5cb6d5cc247ef5"
data-ga-click="(Logged out) Header, clicked Sign up, text:sign-up">
Sign&nbsp;up
</a>
</div>
</div>
</div>
</header>
</div>
<div id="start-of-content" class="show-on-focus"></div>
<div id="js-flash-container">
</div>
<div class="application-main " data-commit-hovercards-enabled>
<div itemscope itemtype="http://schema.org/SoftwareSourceCode" class="">
<main >
<div class="pagehead repohead instapaper_ignore readability-menu experiment-repo-nav pt-0 pt-lg-4 ">
<div class="repohead-details-container clearfix container-lg p-responsive d-none d-lg-block">
<ul class="pagehead-actions">
<li>
<a class="tooltipped tooltipped-s btn btn-sm btn-with-count" aria-label="You must be signed in to watch a repository" rel="nofollow" data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;notification subscription menu watch&quot;,&quot;repository_id&quot;:null,&quot;auth_type&quot;:&quot;LOG_IN&quot;,&quot;client_id&quot;:null,&quot;originating_request_id&quot;:&quot;CE8B:322B:EBD1C4:156E56F:5DAC4D0A&quot;,&quot;originating_url&quot;:&quot;https://github.com/openwrt/openwrt/blob/master/scripts/json_add_image_info.py&quot;,&quot;referrer&quot;:null,&quot;user_id&quot;:null}}" data-hydro-click-hmac="c1a08521d5cebb22bd1ec2fc7aece3244650ae7a7166236a65a4dc14e099c567" href="/login?return_to=%2Fopenwrt%2Fopenwrt">
<svg class="octicon octicon-eye v-align-text-bottom" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M8.06 2C3 2 0 8 0 8s3 6 8.06 6C13 14 16 8 16 8s-3-6-7.94-6zM8 12c-2.2 0-4-1.78-4-4 0-2.2 1.8-4 4-4 2.22 0 4 1.8 4 4 0 2.22-1.78 4-4 4zm2-4c0 1.11-.89 2-2 2-1.11 0-2-.89-2-2 0-1.11.89-2 2-2 1.11 0 2 .89 2 2z"/></svg>
Watch
</a> <a class="social-count" href="/openwrt/openwrt/watchers"
aria-label="419 users are watching this repository">
419
</a>
</li>
<li>
<a class="btn btn-sm btn-with-count tooltipped tooltipped-s" aria-label="You must be signed in to star a repository" rel="nofollow" data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;star button&quot;,&quot;repository_id&quot;:45821540,&quot;auth_type&quot;:&quot;LOG_IN&quot;,&quot;client_id&quot;:null,&quot;originating_request_id&quot;:&quot;CE8B:322B:EBD1C4:156E56F:5DAC4D0A&quot;,&quot;originating_url&quot;:&quot;https://github.com/openwrt/openwrt/blob/master/scripts/json_add_image_info.py&quot;,&quot;referrer&quot;:null,&quot;user_id&quot;:null}}" data-hydro-click-hmac="11f8c4fdca8681d67f9b2899ace6256908b143720eeb8164c338eb4065b96865" href="/login?return_to=%2Fopenwrt%2Fopenwrt">
<svg class="octicon octicon-star v-align-text-bottom" viewBox="0 0 14 16" version="1.1" width="14" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M14 6l-4.9-.64L7 1 4.9 5.36 0 6l3.6 3.26L2.67 14 7 11.67 11.33 14l-.93-4.74L14 6z"/></svg>
Star
</a>
<a class="social-count js-social-count" href="/openwrt/openwrt/stargazers"
aria-label="4700 users starred this repository">
4,700
</a>
</li>
<li>
<a class="btn btn-sm btn-with-count tooltipped tooltipped-s" aria-label="You must be signed in to fork a repository" rel="nofollow" data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;repo details fork button&quot;,&quot;repository_id&quot;:45821540,&quot;auth_type&quot;:&quot;LOG_IN&quot;,&quot;client_id&quot;:null,&quot;originating_request_id&quot;:&quot;CE8B:322B:EBD1C4:156E56F:5DAC4D0A&quot;,&quot;originating_url&quot;:&quot;https://github.com/openwrt/openwrt/blob/master/scripts/json_add_image_info.py&quot;,&quot;referrer&quot;:null,&quot;user_id&quot;:null}}" data-hydro-click-hmac="0bb3cf7f66afbc4d98df595aa6f1d5643cb828d28ff3dc9b324ba50dd2cd85fd" href="/login?return_to=%2Fopenwrt%2Fopenwrt">
<svg class="octicon octicon-repo-forked v-align-text-bottom" viewBox="0 0 10 16" version="1.1" width="10" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M8 1a1.993 1.993 0 00-1 3.72V6L5 8 3 6V4.72A1.993 1.993 0 002 1a1.993 1.993 0 00-1 3.72V6.5l3 3v1.78A1.993 1.993 0 005 15a1.993 1.993 0 001-3.72V9.5l3-3V4.72A1.993 1.993 0 008 1zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3 10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3-10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"/></svg>
Fork
</a>
<a href="/openwrt/openwrt/network/members" class="social-count"
aria-label="2842 users forked this repository">
2,842
</a>
</li>
</ul>
<h1 class="public ">
<svg class="octicon octicon-repo" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M4 9H3V8h1v1zm0-3H3v1h1V6zm0-2H3v1h1V4zm0-2H3v1h1V2zm8-1v12c0 .55-.45 1-1 1H6v2l-1.5-1.5L3 16v-2H1c-.55 0-1-.45-1-1V1c0-.55.45-1 1-1h10c.55 0 1 .45 1 1zm-1 10H1v2h2v-1h3v1h5v-2zm0-10H2v9h9V1z"/></svg>
<span class="author" itemprop="author"><a class="url fn" rel="author" data-hovercard-type="organization" data-hovercard-url="/orgs/openwrt/hovercard" href="/openwrt">openwrt</a></span><!--
--><span class="path-divider">/</span><!--
--><strong itemprop="name"><a data-pjax="#js-repo-pjax-container" href="/openwrt/openwrt">openwrt</a></strong>
</h1>
</div>
<nav class="hx_reponav reponav js-repo-nav js-sidenav-container-pjax container-lg p-responsive d-none d-lg-block"
itemscope
itemtype="http://schema.org/BreadcrumbList"
aria-label="Repository"
data-pjax="#js-repo-pjax-container">
<span itemscope itemtype="http://schema.org/ListItem" itemprop="itemListElement">
<a class="js-selected-navigation-item selected reponav-item" itemprop="url" data-hotkey="g c" aria-current="page" data-selected-links="repo_source repo_downloads repo_commits repo_releases repo_tags repo_branches repo_packages /openwrt/openwrt" href="/openwrt/openwrt">
<svg class="octicon octicon-code" viewBox="0 0 14 16" version="1.1" width="14" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M9.5 3L8 4.5 11.5 8 8 11.5 9.5 13 14 8 9.5 3zm-5 0L0 8l4.5 5L6 11.5 2.5 8 6 4.5 4.5 3z"/></svg>
<span itemprop="name">Code</span>
<meta itemprop="position" content="1">
</a> </span>
<span itemscope itemtype="http://schema.org/ListItem" itemprop="itemListElement">
<a data-hotkey="g p" itemprop="url" class="js-selected-navigation-item reponav-item" data-selected-links="repo_pulls checks /openwrt/openwrt/pulls" href="/openwrt/openwrt/pulls">
<svg class="octicon octicon-git-pull-request" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M11 11.28V5c-.03-.78-.34-1.47-.94-2.06C9.46 2.35 8.78 2.03 8 2H7V0L4 3l3 3V4h1c.27.02.48.11.69.31.21.2.3.42.31.69v6.28A1.993 1.993 0 0010 15a1.993 1.993 0 001-3.72zm-1 2.92c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zM4 3c0-1.11-.89-2-2-2a1.993 1.993 0 00-1 3.72v6.56A1.993 1.993 0 002 15a1.993 1.993 0 001-3.72V4.72c.59-.34 1-.98 1-1.72zm-.8 10c0 .66-.55 1.2-1.2 1.2-.65 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"/></svg>
<span itemprop="name">Pull requests</span>
<span class="Counter">163</span>
<meta itemprop="position" content="3">
</a> </span>
<a data-hotkey="g b" class="js-selected-navigation-item reponav-item" data-selected-links="repo_projects new_repo_project repo_project /openwrt/openwrt/projects" href="/openwrt/openwrt/projects">
<svg class="octicon octicon-project" viewBox="0 0 15 16" version="1.1" width="15" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M10 12h3V2h-3v10zm-4-2h3V2H6v8zm-4 4h3V2H2v12zm-1 1h13V1H1v14zM14 0H1a1 1 0 00-1 1v14a1 1 0 001 1h13a1 1 0 001-1V1a1 1 0 00-1-1z"/></svg>
Projects
<span class="Counter" >0</span>
</a>
<a data-skip-pjax="true" class="js-selected-navigation-item reponav-item" data-selected-links="security alerts policy code_scanning /openwrt/openwrt/security/advisories" href="/openwrt/openwrt/security/advisories">
<svg class="octicon octicon-shield" viewBox="0 0 14 16" version="1.1" width="14" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M0 2l7-2 7 2v6.02C14 12.69 8.69 16 7 16c-1.69 0-7-3.31-7-7.98V2zm1 .75L7 1l6 1.75v5.268C13 12.104 8.449 15 7 15c-1.449 0-6-2.896-6-6.982V2.75zm1 .75L7 2v12c-1.207 0-5-2.482-5-5.985V3.5z"/></svg>
Security
</a>
<a class="js-selected-navigation-item reponav-item" data-selected-links="repo_graphs repo_contributors dependency_graph pulse people /openwrt/openwrt/pulse" href="/openwrt/openwrt/pulse">
<svg class="octicon octicon-graph" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M16 14v1H0V0h1v14h15zM5 13H3V8h2v5zm4 0H7V3h2v10zm4 0h-2V6h2v7z"/></svg>
Insights
</a>
</nav>
<div class="reponav-wrapper reponav-small d-lg-none">
<nav class="reponav js-reponav text-center no-wrap"
itemscope
itemtype="http://schema.org/BreadcrumbList">
<span itemscope itemtype="http://schema.org/ListItem" itemprop="itemListElement">
<a class="js-selected-navigation-item selected reponav-item" itemprop="url" aria-current="page" data-selected-links="repo_source repo_downloads repo_commits repo_releases repo_tags repo_branches repo_packages /openwrt/openwrt" href="/openwrt/openwrt">
<span itemprop="name">Code</span>
<meta itemprop="position" content="1">
</a> </span>
<span itemscope itemtype="http://schema.org/ListItem" itemprop="itemListElement">
<a itemprop="url" class="js-selected-navigation-item reponav-item" data-selected-links="repo_pulls checks /openwrt/openwrt/pulls" href="/openwrt/openwrt/pulls">
<span itemprop="name">Pull requests</span>
<span class="Counter">163</span>
<meta itemprop="position" content="3">
</a> </span>
<span itemscope itemtype="http://schema.org/ListItem" itemprop="itemListElement">
<a itemprop="url" class="js-selected-navigation-item reponav-item" data-selected-links="repo_projects new_repo_project repo_project /openwrt/openwrt/projects" href="/openwrt/openwrt/projects">
<span itemprop="name">Projects</span>
<span class="Counter">0</span>
<meta itemprop="position" content="4">
</a> </span>
<a itemprop="url" class="js-selected-navigation-item reponav-item" data-selected-links="security alerts policy code_scanning /openwrt/openwrt/security/advisories" href="/openwrt/openwrt/security/advisories">
<span itemprop="name">Security</span>
<meta itemprop="position" content="6">
</a>
<a class="js-selected-navigation-item reponav-item" data-selected-links="pulse /openwrt/openwrt/pulse" href="/openwrt/openwrt/pulse">
Pulse
</a>
</nav>
</div>
</div>
<div class="container-lg clearfix new-discussion-timeline experiment-repo-nav p-responsive">
<div class="repository-content ">
<a class="d-none js-permalink-shortcut" data-hotkey="y" href="/openwrt/openwrt/blob/9ba5cd86b89f5f51cbad536c051dca61a9bfe8e5/scripts/json_add_image_info.py">Permalink</a>
<!-- blob contrib key: blob_contributors:v21:309c18fa25578125cb7791a9984dda11 -->
<div class="signup-prompt-bg rounded-1">
<div class="signup-prompt p-4 text-center mb-4 rounded-1">
<div class="position-relative">
<!-- '"` --><!-- </textarea></xmp> --></option></form><form action="/prompt_dismissals/signup" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" /><input type="hidden" name="_method" value="put" /><input type="hidden" name="authenticity_token" value="OQEyv+7WF0lgRXUvJH0TG2DL7PrEbreDBkEfCCGZxBUcw4PdqYnL3MLb6SOA2PbfULW6o0yu7XnUY2xfFhGRyg==" />
<button type="submit" class="position-absolute top-0 right-0 btn-link link-gray" data-ga-click="(Logged out) Sign up prompt, clicked Dismiss, text:dismiss">
Dismiss
</button>
</form> <h3 class="pt-2">Join GitHub today</h3>
<p class="col-6 mx-auto">GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.</p>
<a class="btn btn-primary" data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;files signup prompt&quot;,&quot;repository_id&quot;:null,&quot;auth_type&quot;:&quot;SIGN_UP&quot;,&quot;client_id&quot;:null,&quot;originating_request_id&quot;:&quot;CE8B:322B:EBD1C4:156E56F:5DAC4D0A&quot;,&quot;originating_url&quot;:&quot;https://github.com/openwrt/openwrt/blob/master/scripts/json_add_image_info.py&quot;,&quot;referrer&quot;:null,&quot;user_id&quot;:null}}" data-hydro-click-hmac="80412c40d76806b42ece49ba5f7a0d6c3fc7654e5731360e66d2e5c33e2fb122" data-ga-click="(Logged out) Sign up prompt, clicked Sign up, text:sign-up" href="/join?source=prompt-blob-show&amp;source_repo=openwrt%2Fopenwrt">Sign up</a>
</div>
</div>
</div>
<div class="d-flex flex-items-start flex-shrink-0 pb-3 flex-column flex-md-row">
<span class="d-flex flex-justify-between width-full width-md-auto">
<details class="details-reset details-overlay select-menu branch-select-menu hx_rsm" id="branch-select-menu">
<summary class="btn btn-sm select-menu-button css-truncate"
data-hotkey="w"
title="Switch branches or tags">
<i>Branch:</i>
<span class="css-truncate-target" data-menu-button>master</span>
</summary>
<details-menu class="select-menu-modal hx_rsm-modal position-absolute" style="z-index: 99;" src="/openwrt/openwrt/ref-list/master/scripts/json_add_image_info.py?source_action=show&amp;source_controller=blob" preload>
<include-fragment class="select-menu-loading-overlay anim-pulse">
<svg height="32" class="octicon octicon-octoface" viewBox="0 0 16 16" version="1.1" width="32" aria-hidden="true"><path fill-rule="evenodd" d="M14.7 5.34c.13-.32.55-1.59-.13-3.31 0 0-1.05-.33-3.44 1.3-1-.28-2.07-.32-3.13-.32s-2.13.04-3.13.32c-2.39-1.64-3.44-1.3-3.44-1.3-.68 1.72-.26 2.99-.13 3.31C.49 6.21 0 7.33 0 8.69 0 13.84 3.33 15 7.98 15S16 13.84 16 8.69c0-1.36-.49-2.48-1.3-3.35zM8 14.02c-3.3 0-5.98-.15-5.98-3.35 0-.76.38-1.48 1.02-2.07 1.07-.98 2.9-.46 4.96-.46 2.07 0 3.88-.52 4.96.46.65.59 1.02 1.3 1.02 2.07 0 3.19-2.68 3.35-5.98 3.35zM5.49 9.01c-.66 0-1.2.8-1.2 1.78s.54 1.79 1.2 1.79c.66 0 1.2-.8 1.2-1.79s-.54-1.78-1.2-1.78zm5.02 0c-.66 0-1.2.79-1.2 1.78s.54 1.79 1.2 1.79c.66 0 1.2-.8 1.2-1.79s-.53-1.78-1.2-1.78z"/></svg>
</include-fragment>
</details-menu>
</details>
<div class="BtnGroup flex-shrink-0 d-md-none">
<a href="/openwrt/openwrt/find/master"
class="js-pjax-capture-input btn btn-sm BtnGroup-item"
data-pjax
data-hotkey="t">
Find file
</a>
<clipboard-copy value="scripts/json_add_image_info.py" class="btn btn-sm BtnGroup-item">
Copy path
</clipboard-copy>
</div>
</span>
<h2 id="blob-path" class="breadcrumb flex-auto min-width-0 text-normal flex-md-self-center ml-md-2 mr-md-3 my-2 my-md-0">
<span class="js-repo-root text-bold"><span class="js-path-segment"><a data-pjax="true" href="/openwrt/openwrt"><span>openwrt</span></a></span></span><span class="separator">/</span><span class="js-path-segment"><a data-pjax="true" href="/openwrt/openwrt/tree/master/scripts"><span>scripts</span></a></span><span class="separator">/</span><strong class="final-path">json_add_image_info.py</strong>
</h2>
<div class="BtnGroup flex-shrink-0 d-none d-md-inline-block">
<a href="/openwrt/openwrt/find/master"
class="js-pjax-capture-input btn btn-sm BtnGroup-item"
data-pjax
data-hotkey="t">
Find file
</a>
<clipboard-copy value="scripts/json_add_image_info.py" class="btn btn-sm BtnGroup-item">
Copy path
</clipboard-copy>
</div>
</div>
<div class="Box Box--condensed d-flex flex-column flex-shrink-0">
<div class="Box-body d-flex flex-justify-between bg-blue-light flex-column flex-md-row flex-items-start flex-md-items-center">
<span class="pr-md-4 f6">
<a rel="contributor" data-skip-pjax="true" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=16000931" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="/aparcar"><img class="avatar" src="https://avatars0.githubusercontent.com/u/16000931?s=40&amp;v=4" width="20" height="20" alt="@aparcar" /></a>
<a class="text-bold link-gray-dark lh-default v-align-middle" rel="contributor" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=16000931" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="/aparcar">aparcar</a>
<span class="lh-default v-align-middle">
<a data-pjax="true" title="build: create JSON files containing image info
The JSON info files contain details about the created firmware images
per device and are stored next to the created images.
The JSON files are stored as &quot;$(IMAGE_PREFIX).json&quot; and contain some
device/image meta data as well as a list of created firmware images.
An example of openwrt-ramips-rt305x-aztech_hw550-3g.json
{
&quot;id&quot;: &quot;aztech_hw550-3g&quot;,
&quot;image_prefix&quot;: &quot;openwrt-ramips-rt305x-aztech_hw550-3g&quot;,
&quot;images&quot;: [
{
&quot;name&quot;: &quot;openwrt-ramips-rt305x-aztech_hw550-3g-squashfs-sysupgrade.bin&quot;,
&quot;sha256&quot;: &quot;db2b34b0ec4a83d9bf612cf66fab0dc3722b191cb9bedf111e5627a4298baf20&quot;,
&quot;type&quot;: &quot;sysupgrade&quot;
}
],
&quot;metadata_version&quot;: 1,
&quot;supported_devices&quot;: [
&quot;aztech,hw550-3g&quot;,
&quot;hw550-3g&quot;
],
&quot;target&quot;: &quot;ramips/rt305x&quot;,
&quot;titles&quot;: [
{
&quot;model&quot;: &quot;HW550-3G&quot;,
&quot;vendor&quot;: &quot;Aztech&quot;
},
{
&quot;model&quot;: &quot;ALL0239-3G&quot;,
&quot;vendor&quot;: &quot;Allnet&quot;
}
],
&quot;version_commit&quot;: &quot;r10920+123-0cc87b3bac&quot;,
&quot;version_number&quot;: &quot;SNAPSHOT&quot;
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)
Signed-off-by: Paul Spooren &lt;mail@aparcar.org&gt;" class="link-gray" href="/openwrt/openwrt/commit/881ed09ee6e23f6c224184bb7493253c4624fb9f">build: create JSON files containing image info</a>
</span>
</span>
<span class="d-inline-block flex-shrink-0 v-align-bottom f6 mt-2 mt-md-0">
<a class="pr-2 text-mono link-gray" href="/openwrt/openwrt/commit/881ed09ee6e23f6c224184bb7493253c4624fb9f" data-pjax>881ed09</a>
<relative-time datetime="2019-09-29T11:51:28Z" class="no-wrap">Sep 29, 2019</relative-time>
</span>
</div>
<div class="Box-body d-flex flex-items-center flex-auto f6 border-bottom-0 flex-wrap" >
<details class="details-reset details-overlay details-overlay-dark lh-default text-gray-dark float-left mr-2" id="blob_contributors_box">
<summary class="btn-link">
<span><strong>1</strong> contributor</span>
</summary>
<details-dialog
class="Box Box--overlay d-flex flex-column anim-fade-in fast"
aria-label="Users who have contributed to this file"
src="/openwrt/openwrt/contributors/master/scripts/json_add_image_info.py/list" preload>
<div class="Box-header">
<button class="Box-btn-octicon btn-octicon float-right" type="button" aria-label="Close dialog" data-close-dialog>
<svg class="octicon octicon-x" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48L7.48 8z"/></svg>
</button>
<h3 class="Box-title">
Users who have contributed to this file
</h3>
</div>
<include-fragment class="octocat-spinner my-3" aria-label="Loading..."></include-fragment>
</details-dialog>
</details>
</div>
</div>
<div class="Box mt-3 position-relative">
<div class="Box-header py-2 d-flex flex-column flex-shrink-0 flex-md-row flex-md-items-center">
<div class="text-mono f6 flex-auto pr-3 flex-order-2 flex-md-order-1 mt-2 mt-md-0">
<span class="file-mode" title="File mode">executable file</span>
<span class="file-info-divider"></span>
56 lines (40 sloc)
<span class="file-info-divider"></span>
1.53 KB
</div>
<div class="d-flex py-1 py-md-0 flex-auto flex-order-1 flex-md-order-2 flex-sm-grow-0 flex-justify-between">
<div class="BtnGroup">
<a id="raw-url" class="btn btn-sm BtnGroup-item" href="/openwrt/openwrt/raw/master/scripts/json_add_image_info.py">Raw</a>
<a class="btn btn-sm js-update-url-with-hash BtnGroup-item" data-hotkey="b" href="/openwrt/openwrt/blame/master/scripts/json_add_image_info.py">Blame</a>
<a rel="nofollow" class="btn btn-sm BtnGroup-item" href="/openwrt/openwrt/commits/master/scripts/json_add_image_info.py">History</a>
</div>
<div>
<button type="button" class="btn-octicon disabled tooltipped tooltipped-nw"
aria-label="You must be signed in to make or propose changes">
<svg class="octicon octicon-pencil" viewBox="0 0 14 16" version="1.1" width="14" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M0 12v3h3l8-8-3-3-8 8zm3 2H1v-2h1v1h1v1zm10.3-9.3L12 6 9 3l1.3-1.3a.996.996 0 011.41 0l1.59 1.59c.39.39.39 1.02 0 1.41z"/></svg>
</button>
<button type="button" class="btn-octicon btn-octicon-danger disabled tooltipped tooltipped-nw"
aria-label="You must be signed in to make or propose changes">
<svg class="octicon octicon-trashcan" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M11 2H9c0-.55-.45-1-1-1H5c-.55 0-1 .45-1 1H2c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1v9c0 .55.45 1 1 1h7c.55 0 1-.45 1-1V5c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm-1 12H3V5h1v8h1V5h1v8h1V5h1v8h1V5h1v9zm1-10H2V3h9v1z"/></svg>
</button>
</div>
</div>
</div>
<div itemprop="text" class="Box-body p-0 blob-wrapper data type-python ">
<table class="highlight tab-size js-file-line-container" data-tab-size="8">
<tr>
<td id="L1" class="blob-num js-line-number" data-line-number="1"></td>
<td id="LC1" class="blob-code blob-code-inner js-file-line"><span class="pl-c"><span class="pl-c">#</span>!/usr/bin/env python3</span></td>
</tr>
<tr>
<td id="L2" class="blob-num js-line-number" data-line-number="2"></td>
<td id="LC2" class="blob-code blob-code-inner js-file-line">
</td>
</tr>
<tr>
<td id="L3" class="blob-num js-line-number" data-line-number="3"></td>
<td id="LC3" class="blob-code blob-code-inner js-file-line"><span class="pl-k">import</span> json</td>
</tr>
<tr>
<td id="L4" class="blob-num js-line-number" data-line-number="4"></td>
<td id="LC4" class="blob-code blob-code-inner js-file-line"><span class="pl-k">import</span> os</td>
</tr>
<tr>
<td id="L5" class="blob-num js-line-number" data-line-number="5"></td>
<td id="LC5" class="blob-code blob-code-inner js-file-line"><span class="pl-k">import</span> hashlib</td>
</tr>
<tr>
<td id="L6" class="blob-num js-line-number" data-line-number="6"></td>
<td id="LC6" class="blob-code blob-code-inner js-file-line">
</td>
</tr>
<tr>
<td id="L7" class="blob-num js-line-number" data-line-number="7"></td>
<td id="LC7" class="blob-code blob-code-inner js-file-line">
</td>
</tr>
<tr>
<td id="L8" class="blob-num js-line-number" data-line-number="8"></td>
<td id="LC8" class="blob-code blob-code-inner js-file-line"><span class="pl-k">def</span> <span class="pl-en">e</span>(<span class="pl-smi">variable</span>, <span class="pl-smi">default</span><span class="pl-k">=</span><span class="pl-c1">None</span>):</td>
</tr>
<tr>
<td id="L9" class="blob-num js-line-number" data-line-number="9"></td>
<td id="LC9" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">return</span> os.environ.get(variable, default)</td>
</tr>
<tr>
<td id="L10" class="blob-num js-line-number" data-line-number="10"></td>
<td id="LC10" class="blob-code blob-code-inner js-file-line">
</td>
</tr>
<tr>
<td id="L11" class="blob-num js-line-number" data-line-number="11"></td>
<td id="LC11" class="blob-code blob-code-inner js-file-line">
</td>
</tr>
<tr>
<td id="L12" class="blob-num js-line-number" data-line-number="12"></td>
<td id="LC12" class="blob-code blob-code-inner js-file-line">json_path <span class="pl-k">=</span> <span class="pl-s"><span class="pl-pds">&quot;</span><span class="pl-c1">{}{}{}</span>.json<span class="pl-pds">&quot;</span></span>.format(e(<span class="pl-s"><span class="pl-pds">&quot;</span>BIN_DIR<span class="pl-pds">&quot;</span></span>), os.sep, e(<span class="pl-s"><span class="pl-pds">&quot;</span>IMAGE_PREFIX<span class="pl-pds">&quot;</span></span>))</td>
</tr>
<tr>
<td id="L13" class="blob-num js-line-number" data-line-number="13"></td>
<td id="LC13" class="blob-code blob-code-inner js-file-line">
</td>
</tr>
<tr>
<td id="L14" class="blob-num js-line-number" data-line-number="14"></td>
<td id="LC14" class="blob-code blob-code-inner js-file-line"><span class="pl-k">with</span> <span class="pl-c1">open</span>(os.path.join(e(<span class="pl-s"><span class="pl-pds">&quot;</span>BIN_DIR<span class="pl-pds">&quot;</span></span>), e(<span class="pl-s"><span class="pl-pds">&quot;</span>IMAGE_NAME<span class="pl-pds">&quot;</span></span>)), <span class="pl-s"><span class="pl-pds">&quot;</span>rb<span class="pl-pds">&quot;</span></span>) <span class="pl-k">as</span> image_file:</td>
</tr>
<tr>
<td id="L15" class="blob-num js-line-number" data-line-number="15"></td>
<td id="LC15" class="blob-code blob-code-inner js-file-line"> image_hash <span class="pl-k">=</span> hashlib.sha256(image_file.read()).hexdigest()</td>
</tr>
<tr>
<td id="L16" class="blob-num js-line-number" data-line-number="16"></td>
<td id="LC16" class="blob-code blob-code-inner js-file-line">
</td>
</tr>
<tr>
<td id="L17" class="blob-num js-line-number" data-line-number="17"></td>
<td id="LC17" class="blob-code blob-code-inner js-file-line">
</td>
</tr>
<tr>
<td id="L18" class="blob-num js-line-number" data-line-number="18"></td>
<td id="LC18" class="blob-code blob-code-inner js-file-line"><span class="pl-k">def</span> <span class="pl-en">get_titles</span>():</td>
</tr>
<tr>
<td id="L19" class="blob-num js-line-number" data-line-number="19"></td>
<td id="LC19" class="blob-code blob-code-inner js-file-line"> titles <span class="pl-k">=</span> []</td>
</tr>
<tr>
<td id="L20" class="blob-num js-line-number" data-line-number="20"></td>
<td id="LC20" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">for</span> prefix <span class="pl-k">in</span> [<span class="pl-s"><span class="pl-pds">&quot;</span><span class="pl-pds">&quot;</span></span>, <span class="pl-s"><span class="pl-pds">&quot;</span>ALT0_<span class="pl-pds">&quot;</span></span>, <span class="pl-s"><span class="pl-pds">&quot;</span>ALT1_<span class="pl-pds">&quot;</span></span>, <span class="pl-s"><span class="pl-pds">&quot;</span>ALT2_<span class="pl-pds">&quot;</span></span>]:</td>
</tr>
<tr>
<td id="L21" class="blob-num js-line-number" data-line-number="21"></td>
<td id="LC21" class="blob-code blob-code-inner js-file-line"> title <span class="pl-k">=</span> {}</td>
</tr>
<tr>
<td id="L22" class="blob-num js-line-number" data-line-number="22"></td>
<td id="LC22" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">for</span> var <span class="pl-k">in</span> [<span class="pl-s"><span class="pl-pds">&quot;</span>vendor<span class="pl-pds">&quot;</span></span>, <span class="pl-s"><span class="pl-pds">&quot;</span>model<span class="pl-pds">&quot;</span></span>, <span class="pl-s"><span class="pl-pds">&quot;</span>variant<span class="pl-pds">&quot;</span></span>]:</td>
</tr>
<tr>
<td id="L23" class="blob-num js-line-number" data-line-number="23"></td>
<td id="LC23" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">if</span> e(<span class="pl-s"><span class="pl-pds">&quot;</span>DEVICE_<span class="pl-c1">{}{}</span><span class="pl-pds">&quot;</span></span>.format(prefix, var.upper())):</td>
</tr>
<tr>
<td id="L24" class="blob-num js-line-number" data-line-number="24"></td>
<td id="LC24" class="blob-code blob-code-inner js-file-line"> title[var] <span class="pl-k">=</span> e(<span class="pl-s"><span class="pl-pds">&quot;</span>DEVICE_<span class="pl-c1">{}{}</span><span class="pl-pds">&quot;</span></span>.format(prefix, var.upper()))</td>
</tr>
<tr>
<td id="L25" class="blob-num js-line-number" data-line-number="25"></td>
<td id="LC25" class="blob-code blob-code-inner js-file-line">
</td>
</tr>
<tr>
<td id="L26" class="blob-num js-line-number" data-line-number="26"></td>
<td id="LC26" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">if</span> title:</td>
</tr>
<tr>
<td id="L27" class="blob-num js-line-number" data-line-number="27"></td>
<td id="LC27" class="blob-code blob-code-inner js-file-line"> titles.append(title)</td>
</tr>
<tr>
<td id="L28" class="blob-num js-line-number" data-line-number="28"></td>
<td id="LC28" class="blob-code blob-code-inner js-file-line">
</td>
</tr>
<tr>
<td id="L29" class="blob-num js-line-number" data-line-number="29"></td>
<td id="LC29" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">if</span> <span class="pl-k">not</span> titles:</td>
</tr>
<tr>
<td id="L30" class="blob-num js-line-number" data-line-number="30"></td>
<td id="LC30" class="blob-code blob-code-inner js-file-line"> titles.append({<span class="pl-s"><span class="pl-pds">&quot;</span>title<span class="pl-pds">&quot;</span></span>: e(<span class="pl-s"><span class="pl-pds">&quot;</span>DEVICE_TITLE<span class="pl-pds">&quot;</span></span>)})</td>
</tr>
<tr>
<td id="L31" class="blob-num js-line-number" data-line-number="31"></td>
<td id="LC31" class="blob-code blob-code-inner js-file-line">
</td>
</tr>
<tr>
<td id="L32" class="blob-num js-line-number" data-line-number="32"></td>
<td id="LC32" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">return</span> titles</td>
</tr>
<tr>
<td id="L33" class="blob-num js-line-number" data-line-number="33"></td>
<td id="LC33" class="blob-code blob-code-inner js-file-line">
</td>
</tr>
<tr>
<td id="L34" class="blob-num js-line-number" data-line-number="34"></td>
<td id="LC34" class="blob-code blob-code-inner js-file-line">
</td>
</tr>
<tr>
<td id="L35" class="blob-num js-line-number" data-line-number="35"></td>
<td id="LC35" class="blob-code blob-code-inner js-file-line"><span class="pl-k">if</span> <span class="pl-k">not</span> os.path.exists(json_path):</td>
</tr>
<tr>
<td id="L36" class="blob-num js-line-number" data-line-number="36"></td>
<td id="LC36" class="blob-code blob-code-inner js-file-line"> device_info <span class="pl-k">=</span> {</td>
</tr>
<tr>
<td id="L37" class="blob-num js-line-number" data-line-number="37"></td>
<td id="LC37" class="blob-code blob-code-inner js-file-line"> <span class="pl-s"><span class="pl-pds">&quot;</span>id<span class="pl-pds">&quot;</span></span>: e(<span class="pl-s"><span class="pl-pds">&quot;</span>DEVICE_ID<span class="pl-pds">&quot;</span></span>),</td>
</tr>
<tr>
<td id="L38" class="blob-num js-line-number" data-line-number="38"></td>
<td id="LC38" class="blob-code blob-code-inner js-file-line"> <span class="pl-s"><span class="pl-pds">&quot;</span>image_prefix<span class="pl-pds">&quot;</span></span>: e(<span class="pl-s"><span class="pl-pds">&quot;</span>IMAGE_PREFIX<span class="pl-pds">&quot;</span></span>),</td>
</tr>
<tr>
<td id="L39" class="blob-num js-line-number" data-line-number="39"></td>
<td id="LC39" class="blob-code blob-code-inner js-file-line"> <span class="pl-s"><span class="pl-pds">&quot;</span>images<span class="pl-pds">&quot;</span></span>: [],</td>
</tr>
<tr>
<td id="L40" class="blob-num js-line-number" data-line-number="40"></td>
<td id="LC40" class="blob-code blob-code-inner js-file-line"> <span class="pl-s"><span class="pl-pds">&quot;</span>metadata_version<span class="pl-pds">&quot;</span></span>: <span class="pl-c1">1</span>,</td>
</tr>
<tr>
<td id="L41" class="blob-num js-line-number" data-line-number="41"></td>
<td id="LC41" class="blob-code blob-code-inner js-file-line"> <span class="pl-s"><span class="pl-pds">&quot;</span>supported_devices<span class="pl-pds">&quot;</span></span>: e(<span class="pl-s"><span class="pl-pds">&quot;</span>SUPPORTED_DEVICES<span class="pl-pds">&quot;</span></span>).split(),</td>
</tr>
<tr>
<td id="L42" class="blob-num js-line-number" data-line-number="42"></td>
<td id="LC42" class="blob-code blob-code-inner js-file-line"> <span class="pl-s"><span class="pl-pds">&quot;</span>target<span class="pl-pds">&quot;</span></span>: <span class="pl-s"><span class="pl-pds">&quot;</span><span class="pl-c1">{}</span>/<span class="pl-c1">{}</span><span class="pl-pds">&quot;</span></span>.format(e(<span class="pl-s"><span class="pl-pds">&quot;</span>TARGET<span class="pl-pds">&quot;</span></span>), e(<span class="pl-s"><span class="pl-pds">&quot;</span>SUBTARGET<span class="pl-pds">&quot;</span></span>, <span class="pl-s"><span class="pl-pds">&quot;</span>generic<span class="pl-pds">&quot;</span></span>)),</td>
</tr>
<tr>
<td id="L43" class="blob-num js-line-number" data-line-number="43"></td>
<td id="LC43" class="blob-code blob-code-inner js-file-line"> <span class="pl-s"><span class="pl-pds">&quot;</span>titles<span class="pl-pds">&quot;</span></span>: get_titles(),</td>
</tr>
<tr>
<td id="L44" class="blob-num js-line-number" data-line-number="44"></td>
<td id="LC44" class="blob-code blob-code-inner js-file-line"> <span class="pl-s"><span class="pl-pds">&quot;</span>version_commit<span class="pl-pds">&quot;</span></span>: e(<span class="pl-s"><span class="pl-pds">&quot;</span>VERSION_CODE<span class="pl-pds">&quot;</span></span>),</td>
</tr>
<tr>
<td id="L45" class="blob-num js-line-number" data-line-number="45"></td>
<td id="LC45" class="blob-code blob-code-inner js-file-line"> <span class="pl-s"><span class="pl-pds">&quot;</span>version_number<span class="pl-pds">&quot;</span></span>: e(<span class="pl-s"><span class="pl-pds">&quot;</span>VERSION_NUMBER<span class="pl-pds">&quot;</span></span>),</td>
</tr>
<tr>
<td id="L46" class="blob-num js-line-number" data-line-number="46"></td>
<td id="LC46" class="blob-code blob-code-inner js-file-line"> }</td>
</tr>
<tr>
<td id="L47" class="blob-num js-line-number" data-line-number="47"></td>
<td id="LC47" class="blob-code blob-code-inner js-file-line"><span class="pl-k">else</span>:</td>
</tr>
<tr>
<td id="L48" class="blob-num js-line-number" data-line-number="48"></td>
<td id="LC48" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">with</span> <span class="pl-c1">open</span>(json_path, <span class="pl-s"><span class="pl-pds">&quot;</span>r<span class="pl-pds">&quot;</span></span>) <span class="pl-k">as</span> json_file:</td>
</tr>
<tr>
<td id="L49" class="blob-num js-line-number" data-line-number="49"></td>
<td id="LC49" class="blob-code blob-code-inner js-file-line"> device_info <span class="pl-k">=</span> json.load(json_file)</td>
</tr>
<tr>
<td id="L50" class="blob-num js-line-number" data-line-number="50"></td>
<td id="LC50" class="blob-code blob-code-inner js-file-line">
</td>
</tr>
<tr>
<td id="L51" class="blob-num js-line-number" data-line-number="51"></td>
<td id="LC51" class="blob-code blob-code-inner js-file-line">image_info <span class="pl-k">=</span> {<span class="pl-s"><span class="pl-pds">&quot;</span>type<span class="pl-pds">&quot;</span></span>: e(<span class="pl-s"><span class="pl-pds">&quot;</span>IMAGE_TYPE<span class="pl-pds">&quot;</span></span>), <span class="pl-s"><span class="pl-pds">&quot;</span>name<span class="pl-pds">&quot;</span></span>: e(<span class="pl-s"><span class="pl-pds">&quot;</span>IMAGE_NAME<span class="pl-pds">&quot;</span></span>), <span class="pl-s"><span class="pl-pds">&quot;</span>sha256<span class="pl-pds">&quot;</span></span>: image_hash}</td>
</tr>
<tr>
<td id="L52" class="blob-num js-line-number" data-line-number="52"></td>
<td id="LC52" class="blob-code blob-code-inner js-file-line">device_info[<span class="pl-s"><span class="pl-pds">&quot;</span>images<span class="pl-pds">&quot;</span></span>].append(image_info)</td>
</tr>
<tr>
<td id="L53" class="blob-num js-line-number" data-line-number="53"></td>
<td id="LC53" class="blob-code blob-code-inner js-file-line">
</td>
</tr>
<tr>
<td id="L54" class="blob-num js-line-number" data-line-number="54"></td>
<td id="LC54" class="blob-code blob-code-inner js-file-line"><span class="pl-k">with</span> <span class="pl-c1">open</span>(json_path, <span class="pl-s"><span class="pl-pds">&quot;</span>w<span class="pl-pds">&quot;</span></span>) <span class="pl-k">as</span> json_file:</td>
</tr>
<tr>
<td id="L55" class="blob-num js-line-number" data-line-number="55"></td>
<td id="LC55" class="blob-code blob-code-inner js-file-line"> json.dump(device_info, json_file, <span class="pl-v">sort_keys</span><span class="pl-k">=</span><span class="pl-c1">True</span>, <span class="pl-v">indent</span><span class="pl-k">=</span><span class="pl-s"><span class="pl-pds">&quot;</span> <span class="pl-pds">&quot;</span></span>)</td>
</tr>
</table>
<details class="details-reset details-overlay BlobToolbar position-absolute js-file-line-actions dropdown d-none" aria-hidden="true">
<summary class="btn-octicon ml-0 px-2 p-0 bg-white border border-gray-dark rounded-1" aria-label="Inline file action toolbar">
<svg class="octicon octicon-kebab-horizontal" viewBox="0 0 13 16" version="1.1" width="13" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M1.5 9a1.5 1.5 0 100-3 1.5 1.5 0 000 3zm5 0a1.5 1.5 0 100-3 1.5 1.5 0 000 3zM13 7.5a1.5 1.5 0 11-3 0 1.5 1.5 0 013 0z"/></svg>
</summary>
<details-menu>
<ul class="BlobToolbar-dropdown dropdown-menu dropdown-menu-se mt-2" style="width:185px">
<li>
<clipboard-copy role="menuitem" class="dropdown-item" id="js-copy-lines" style="cursor:pointer;">
Copy lines
</clipboard-copy>
</li>
<li>
<clipboard-copy role="menuitem" class="dropdown-item" id="js-copy-permalink" style="cursor:pointer;">
Copy permalink
</clipboard-copy>
</li>
<li><a class="dropdown-item js-update-url-with-hash" id="js-view-git-blame" role="menuitem" href="/openwrt/openwrt/blame/9ba5cd86b89f5f51cbad536c051dca61a9bfe8e5/scripts/json_add_image_info.py">View git blame</a></li>
</ul>
</details-menu>
</details>
</div>
</div>
<details class="details-reset details-overlay details-overlay-dark">
<summary data-hotkey="l" aria-label="Jump to line"></summary>
<details-dialog class="Box Box--overlay d-flex flex-column anim-fade-in fast linejump" aria-label="Jump to line">
<!-- '"` --><!-- </textarea></xmp> --></option></form><form class="js-jump-to-line-form Box-body d-flex" action="" accept-charset="UTF-8" method="get"><input name="utf8" type="hidden" value="&#x2713;" />
<input class="form-control flex-auto mr-3 linejump-input js-jump-to-line-field" type="text" placeholder="Jump to line&hellip;" aria-label="Jump to line" autofocus>
<button type="submit" class="btn" data-close-dialog>Go</button>
</form> </details-dialog>
</details>
</div>
</div>
</main>
</div>
</div>
<div class="footer container-lg width-full p-responsive" role="contentinfo">
<div class="position-relative d-flex flex-row-reverse flex-lg-row flex-wrap flex-lg-nowrap flex-justify-center flex-lg-justify-between pt-6 pb-2 mt-6 f6 text-gray border-top border-gray-light ">
<ul class="list-style-none d-flex flex-wrap col-12 col-lg-5 flex-justify-center flex-lg-justify-between mb-2 mb-lg-0">
<li class="mr-3 mr-lg-0">&copy; 2019 <span title="0.21293s from unicorn-578f6685d5-l6ddq">GitHub</span>, Inc.</li>
<li class="mr-3 mr-lg-0"><a data-ga-click="Footer, go to terms, text:terms" href="https://github.com/site/terms">Terms</a></li>
<li class="mr-3 mr-lg-0"><a data-ga-click="Footer, go to privacy, text:privacy" href="https://github.com/site/privacy">Privacy</a></li>
<li class="mr-3 mr-lg-0"><a data-ga-click="Footer, go to security, text:security" href="https://github.com/security">Security</a></li>
<li class="mr-3 mr-lg-0"><a href="https://githubstatus.com/" data-ga-click="Footer, go to status, text:status">Status</a></li>
<li><a data-ga-click="Footer, go to help, text:help" href="https://help.github.com">Help</a></li>
</ul>
<a aria-label="Homepage" title="GitHub" class="footer-octicon d-none d-lg-block mx-lg-4" href="https://github.com">
<svg height="24" class="octicon octicon-mark-github" viewBox="0 0 16 16" version="1.1" width="24" aria-hidden="true"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"/></svg>
</a>
<ul class="list-style-none d-flex flex-wrap col-12 col-lg-5 flex-justify-center flex-lg-justify-between mb-2 mb-lg-0">
<li class="mr-3 mr-lg-0"><a data-ga-click="Footer, go to contact, text:contact" href="https://github.com/contact">Contact GitHub</a></li>
<li class="mr-3 mr-lg-0"><a href="https://github.com/pricing" data-ga-click="Footer, go to Pricing, text:Pricing">Pricing</a></li>
<li class="mr-3 mr-lg-0"><a href="https://developer.github.com" data-ga-click="Footer, go to api, text:api">API</a></li>
<li class="mr-3 mr-lg-0"><a href="https://training.github.com" data-ga-click="Footer, go to training, text:training">Training</a></li>
<li class="mr-3 mr-lg-0"><a href="https://github.blog" data-ga-click="Footer, go to blog, text:blog">Blog</a></li>
<li><a data-ga-click="Footer, go to about, text:about" href="https://github.com/about">About</a></li>
</ul>
</div>
<div class="d-flex flex-justify-center pb-6">
<span class="f6 text-gray-light"></span>
</div>
</div>
<div id="ajax-error-message" class="ajax-error-message flash flash-error">
<svg class="octicon octicon-alert" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 000 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 00.01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"/></svg>
<button type="button" class="flash-close js-ajax-error-dismiss" aria-label="Dismiss error">
<svg class="octicon octicon-x" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48L7.48 8z"/></svg>
</button>
You can’t perform that action at this time.
</div>
<script crossorigin="anonymous" integrity="sha512-TbfkaZYiU/5xEbirWto8uf216HR0LY6DbUyKGPkXyqtzi73Y7Fq22NVp6y9ED/q70aRfHcBF4M45Vi7tQK9yVQ==" type="application/javascript" src="https://github.githubassets.com/assets/compat-bootstrap-04d4095a.js"></script>
<script crossorigin="anonymous" integrity="sha512-P7QbxhTkfogU8wuMH3u9CEiNA9esk13jExiHBnpW+Kh9fKban2yNVEok9xzV2GqSuEU3ZbCKe0GooUfc6szm4g==" type="application/javascript" src="https://github.githubassets.com/assets/frameworks-e0eb4964.js"></script>
<script crossorigin="anonymous" async="async" integrity="sha512-UjV5G8yJkGcA9OW3TPPQx+Rk3uyOfOVmYEWLj7ADv81bEy8Jp9oDULYFdQxOxJq518DFlt0+dBqobwvarLrNgA==" type="application/javascript" src="https://github.githubassets.com/assets/github-bootstrap-35e32afb.js"></script>
<div class="js-stale-session-flash flash flash-warn flash-banner" hidden
>
<svg class="octicon octicon-alert" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 000 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 00.01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"/></svg>
<span class="js-stale-session-flash-signed-in" hidden>You signed in with another tab or window. <a href="">Reload</a> to refresh your session.</span>
<span class="js-stale-session-flash-signed-out" hidden>You signed out in another tab or window. <a href="">Reload</a> to refresh your session.</span>
</div>
<template id="site-details-dialog">
<details class="details-reset details-overlay details-overlay-dark lh-default text-gray-dark hx_rsm" open>
<summary role="button" aria-label="Close dialog"></summary>
<details-dialog class="Box Box--overlay d-flex flex-column anim-fade-in fast hx_rsm-dialog hx_rsm-modal">
<button class="Box-btn-octicon m-0 btn-octicon position-absolute right-0 top-0" type="button" aria-label="Close dialog" data-close-dialog>
<svg class="octicon octicon-x" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48L7.48 8z"/></svg>
</button>
<div class="octocat-spinner my-6 js-details-dialog-spinner"></div>
</details-dialog>
</details>
</template>
<div class="Popover js-hovercard-content position-absolute" style="display: none; outline: none;" tabindex="0">
<div class="Popover-message Popover-message--bottom-left Popover-message--large Box box-shadow-large" style="width:360px;">
</div>
</div>
<div aria-live="polite" class="js-global-screen-reader-notice sr-only"></div>
</body>
</html>
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=" ")
......@@ -2,50 +2,7 @@
[ -e /lib/firmware/$FIRMWARE ] && exit 0
. /lib/functions.sh
. /lib/functions/system.sh
ath9k_eeprom_die() {
echo "ath9k eeprom: " "$*"
exit 1
}
ath9k_eeprom_extract() {
local part=$1
local offset=$2
local count=$3
local mtd
mtd=$(find_mtd_chardev $part)
[ -n "$mtd" ] || \
ath9k_eeprom_die "no mtd device found for partition $part"
dd if=$mtd of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \
ath9k_eeprom_die "failed to extract from $mtd"
}
ath9k_ubi_eeprom_extract() {
local part=$1
local offset=$2
local count=$3
local ubidev=$(nand_find_ubi $CI_UBIPART)
local ubi
ubi=$(nand_find_volume $ubidev $part)
[ -n "$ubi" ] || \
ath9k_eeprom_die "no UBI volume found for $part"
dd if=/dev/$ubi of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \
ath9k_eeprom_die "failed to extract from $ubi"
}
ath9k_patch_firmware_mac() {
local mac=$1
[ -z "$mac" ] && return
macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=2 count=6
}
. /lib/functions/caldata.sh
board=$(board_name)
......@@ -56,14 +13,14 @@ case "$FIRMWARE" in
. /lib/upgrade/nand.sh
if [ -n "$(nand_find_volume ubi0 caldata)" ]; then
ath9k_ubi_eeprom_extract "caldata" 20480 4096
caldata_extract_ubi "caldata" 0x5000 0x1000
else
ath9k_eeprom_extract "wifi_data" 20480 4096
ath9k_patch_firmware_mac $(mtd_get_mac_binary wifi_data 12)
caldata_extract "wifi_data" 0x5000 0x1000
ath9k_patch_mac $(mtd_get_mac_binary wifi_data 0xc)
fi
;;
*)
ath9k_eeprom_die "board $board is not supported yet"
caldata_die "board $board is not supported yet"
;;
esac
;;
......@@ -74,14 +31,14 @@ case "$FIRMWARE" in
. /lib/upgrade/nand.sh
if [ -n "$(nand_find_volume ubi0 caldata)" ]; then
ath9k_ubi_eeprom_extract "caldata" 4096 4096
caldata_extract_ubi "caldata" 0x1000 0x1000
else
ath9k_eeprom_extract "wifi_data" 4096 4096
ath9k_patch_firmware_mac $(mtd_get_mac_binary wifi_data 0)
caldata_extract "wifi_data" 0x1000 0x1000
ath9k_patch_mac $(mtd_get_mac_binary wifi_data 0x0)
fi
;;
*)
ath9k_eeprom_die "board $board is not supported yet"
caldata_die "board $board is not supported yet"
;;
esac
;;
......
......@@ -6,7 +6,7 @@ preinit_set_mac_address() {
case $(board_name) in
meraki,mr24|\
meraki,mx60)
mac_lan=$(mtd_get_mac_binary_ubi board-config 102)
mac_lan=$(mtd_get_mac_binary_ubi board-config 0x66)
[ -n "$mac_lan" ] && ifconfig eth0 hw ether "$mac_lan"
;;
esac
......
......@@ -650,10 +650,58 @@ ar71xx_setup_macs()
[ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
}
ar71xx_setup_ar8xxx_switch()
{
local board="$1"
case $board in
ap147-010|\
archer-c25-v1|\
archer-c58-v1|\
archer-c59-v1|\
archer-c59-v2|\
archer-c60-v1|\
archer-c60-v2|\
archer-c7-v4|\
archer-c7-v5|\
cf-e375ac|\
cf-e385ac|\
cr3000|\
dhp-1565-a1|\
mynet-n600|\
rb-2011il|\
rb-2011ils|\
rb-2011l|\
rb-2011uas|\
rb-2011uas-2hnd|\
rb-2011uias|\
rb-2011uias-2hnd|\
rb-750|\
rb-750p-pbr2|\
rb-750-r2|\
rb-750up-r2|\
rb-951ui-2nd|\
rb-952ui-5ac2nd|\
rb-map-2nd|\
tl-wr1043nd-v4|\
tl-wr1043n-v5|\
wndr3700v4|\
wndr4300|\
wnr1000-v2|\
wnr2000-v3|\
wnr2200|\
wnr612-v2|\
wpn824n)
ucidef_set_ar8xxx_switch_mib "switch0" 0 500
;;
esac
}
board_config_update
board=$(board_name)
ar71xx_setup_interfaces $board
ar71xx_setup_macs $board
ar71xx_setup_ar8xxx_switch $board
board_config_flush
exit 0
......@@ -12,8 +12,8 @@ ath9k_eeprom_die() {
ath9k_eeprom_extract() {
local part=$1
local offset=$2
local count=$3
local offset=$(($2))
local count=$(($3))
local mtd
mtd=$(find_mtd_chardev $part)
......@@ -26,8 +26,8 @@ ath9k_eeprom_extract() {
ath9k_ubi_eeprom_extract() {
local part=$1
local offset=$2
local count=$3
local offset=$(($2))
local count=$(($3))
local ubidev=$(nand_find_ubi $CI_UBIPART)
local ubi
......@@ -42,7 +42,7 @@ ath9k_ubi_eeprom_extract() {
ath9k_eeprom_extract_reverse() {
local part=$1
local offset=$2
local count=$3
local count=$(($3))
local mtd
local reversed
local caldata
......@@ -72,53 +72,53 @@ case "$FIRMWARE" in
case $board in
c-55|\
c-60)
ath9k_eeprom_extract "art" 4096 2048
ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary art 0) +1)
ath9k_eeprom_extract "art" 0x1000 0x800
ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary art 0x0) +1)
;;
fritz4020|\
fritz450e)
ath9k_eeprom_extract_reverse "urlader" 5441 1088
ath9k_eeprom_extract_reverse "urlader" 0x1541 0x440
;;
k2t)
ath9k_eeprom_extract "art" 4096 2048
ath9k_eeprom_extract "art" 0x1000 0x800
ath9k_patch_firmware_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +3)
;;
sbr-ac1750)
ath9k_eeprom_extract "art" 4096 2048
ath9k_eeprom_extract "art" 0x1000 0x800
ath9k_patch_firmware_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +1)
;;
mr18)
. /lib/upgrade/nand.sh
if [ -n "$(nand_find_volume ubi0 caldata)" ]; then
ath9k_ubi_eeprom_extract "caldata" 4096 2048
ath9k_ubi_eeprom_extract "caldata" 0x1000 0x800
else
ath9k_eeprom_extract "odm-caldata" 4096 2048
ath9k_eeprom_extract "odm-caldata" 0x1000 0x800
fi
ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 102) +1)
ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 0x66) +1)
;;
r6100 | \
wndr3700v4 | \
wndr4300)
ath9k_eeprom_extract "caldata" 4096 2048
ath9k_patch_firmware_mac $(mtd_get_mac_binary caldata 0)
ath9k_eeprom_extract "caldata" 0x1000 0x800
ath9k_patch_firmware_mac $(mtd_get_mac_binary caldata 0x0)
;;
rambutan)
ath9k_eeprom_extract "art" 4096 2048
ath9k_eeprom_extract "art" 0x1000 0x800
;;
wlr8100)
ath9k_eeprom_extract "art" 4096 2048
ath9k_eeprom_extract "art" 0x1000 0x800
ath9k_patch_firmware_mac $(mtd_get_mac_ascii u-boot-env "ethaddr")
;;
z1)
. /lib/upgrade/nand.sh
if [ -n "$(nand_find_volume ubi0 caldata)" ]; then
ath9k_ubi_eeprom_extract "caldata" 4096 2048
ath9k_ubi_eeprom_extract "caldata" 0x1000 0x800
else
ath9k_eeprom_extract "origcaldata" 4096 2048
ath9k_eeprom_extract "origcaldata" 0x1000 0x800
fi
ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 102) +2)
ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 0x66) +2)
;;
*)
ath9k_eeprom_die "board $board is not supported yet"
......@@ -129,36 +129,36 @@ case "$FIRMWARE" in
"pci_wmac0.eeprom")
case $board in
c-55)
ath9k_eeprom_extract "art" 20480 2048
ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary art 0) +2)
ath9k_eeprom_extract "art" 0x5000 0x800
ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary art 0x0) +2)
;;
fritz300e)
ath9k_eeprom_extract_reverse "urloader" 5441 1088
ath9k_eeprom_extract_reverse "urloader" 0x1541 0x440
;;
mr18)
. /lib/upgrade/nand.sh
if [ -n "$(nand_find_volume ubi0 caldata)" ]; then
ath9k_ubi_eeprom_extract "caldata" 20480 2048
ath9k_ubi_eeprom_extract "caldata" 0x1541 0x440
else
ath9k_eeprom_extract "odm-caldata" 20480 2048
ath9k_eeprom_extract "odm-caldata" 0x5000 0x800
fi
ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 102) +2)
ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 0x66) +2)
;;
wndr3700v4 | \
wndr4300)
ath9k_eeprom_extract "caldata" 20480 2048
ath9k_patch_firmware_mac $(mtd_get_mac_binary caldata 12)
ath9k_eeprom_extract "caldata" 0x5000 0x800
ath9k_patch_firmware_mac $(mtd_get_mac_binary caldata 0xc)
;;
z1)
. /lib/upgrade/nand.sh
if [ -n "$(nand_find_volume ubi0 caldata)" ]; then
ath9k_ubi_eeprom_extract "caldata" 86016 4096
ath9k_ubi_eeprom_extract "caldata" 0x15000 0x1000
else
ath9k_eeprom_extract "origcaldata" 86016 4096
ath9k_eeprom_extract "origcaldata" 0x15000 0x1000
fi
ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 102) +3)
ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 0x66) +3)
;;
*)
ath9k_eeprom_die "board $board is not supported yet"
......@@ -172,11 +172,11 @@ case "$FIRMWARE" in
. /lib/upgrade/nand.sh
if [ -n "$(nand_find_volume ubi0 caldata)" ]; then
ath9k_ubi_eeprom_extract "caldata" 36864 2048
ath9k_ubi_eeprom_extract "caldata" 0x9000 0x800
else
ath9k_eeprom_extract "odm-caldata" 36864 2048
ath9k_eeprom_extract "odm-caldata" 0x9000 0x800
fi
ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 102) +3)
ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 0x66) +3)
;;
*)
ath9k_eeprom_die "board $board is not supported yet"
......
#!/bin/sh
# xor multiple hex values of the same length
xor() {
local val
local ret="0x$1"
local retlen=${#1}
shift
while [ -n "$1" ]; do
val="0x$1"
ret=$((ret ^ val))
shift
done
printf "%0${retlen}x" "$ret"
}
ath10kcal_die() {
echo "ath10cal: " "$*"
exit 1
......@@ -23,8 +7,8 @@ ath10kcal_die() {
ath10kcal_from_file() {
local source=$1
local offset=$2
local count=$3
local offset=$(($2))
local count=$(($3))
dd if=$source of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \
ath10kcal_die "failed to extract calibration data from $source"
......@@ -32,8 +16,8 @@ ath10kcal_from_file() {
ath10kcal_extract() {
local part=$1
local offset=$2
local count=$3
local offset=$(($2))
local count=$(($3))
local mtd cal_size
mtd=$(find_mtd_chardev $part)
......@@ -55,30 +39,7 @@ ath10kcal_patch_mac() {
[ -z "$mac" ] && return
macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=6 count=6
}
ath10kcal_patch_mac_crc() {
local mac=$1
local mac_offset=6
local chksum_offset=2
local xor_mac
local xor_fw_mac
local xor_fw_chksum
xor_fw_mac=$(hexdump -v -n 6 -s $mac_offset -e '/1 "%02x"' /lib/firmware/$FIRMWARE)
xor_fw_mac="${xor_fw_mac:0:4} ${xor_fw_mac:4:4} ${xor_fw_mac:8:4}"
ath10kcal_patch_mac "$mac" && {
xor_mac=${mac//:/}
xor_mac="${xor_mac:0:4} ${xor_mac:4:4} ${xor_mac:8:4}"
xor_fw_chksum=$(hexdump -v -n 2 -s $chksum_offset -e '/1 "%02x"' /lib/firmware/$FIRMWARE)
xor_fw_chksum=$(xor $xor_fw_chksum $xor_fw_mac $xor_mac)
printf "%b" "\x${xor_fw_chksum:0:2}\x${xor_fw_chksum:2:2}" | \
dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$chksum_offset count=2
}
macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc oflag=seek_bytes bs=6 seek=6 count=1
}
[ -e /lib/firmware/$FIRMWARE ] && exit 0
......@@ -96,17 +57,17 @@ case "$FIRMWARE" in
mr1750|\
mr1750v2|\
om5p-acv2)
ath10kcal_extract "ART" 20480 2116
ath10kcal_extract "ART" 0x5000 0x844
ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +16)
;;
archer-c25-v1|\
tl-wdr6500-v2)
ath10kcal_extract "art" 20480 2116
ath10kcal_extract "art" 0x5000 0x844
ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) -2)
;;
archer-c7-v4|\
archer-c7-v5)
ath10kcal_extract "art" 20480 2116
ath10kcal_extract "art" 0x5000 0x844
ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -1)
;;
cf-e355ac-v1|\
......@@ -119,64 +80,64 @@ case "$FIRMWARE" in
oolite-v5.2-dev|\
sr3200|\
xd3200)
ath10kcal_extract "art" 20480 2116
ath10kcal_extract "art" 0x5000 0x844
;;
dap-2695-a1)
ath10kcal_extract "radiocfg" 20480 2116
ath10kcal_extract "radiocfg" 0x5000 0x844
ath10kcal_patch_mac $(mtd_get_mac_ascii bdcfg wlanmac_a)
;;
dir-869-a1|\
qihoo-c301)
ath10kcal_extract "radiocfg" 20480 2116
ath10kcal_extract "radiocfg" 0x5000 0x844
ath10kcal_patch_mac $(mtd_get_mac_ascii devdata wlan5mac)
;;
dw33d)
ath10kcal_extract "art" 20480 2116
ath10kcal_patch_mac $(mtd_get_mac_binary art 18)
ath10kcal_extract "art" 0x5000 0x844
ath10kcal_patch_mac $(mtd_get_mac_binary art 0x12)
;;
sbr-ac1750)
ath10kcal_extract "art" 20480 2116
ath10kcal_patch_mac_crc $(macaddr_add $(cat /sys/class/net/eth1/address) +1)
ath10kcal_extract "art" 0x5000 0x844
ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) +1)
;;
epg5000|\
esr1750)
ath10kcal_extract "caldata" 20480 2116
ath10kcal_extract "caldata" 0x5000 0x844
ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +1)
;;
gl-ar750s|\
gl-ar750|\
tl-wpa8630)
ath10kcal_extract "art" 20480 2116
ath10kcal_extract "art" 0x5000 0x844
ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +1)
;;
koala)
ath10kcal_extract "art" 20480 2116
ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary art 12) +0)
ath10kcal_extract "art" 0x5000 0x844
ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0xc) +0)
;;
mc-mac1200r)
ath10kcal_extract "art" 20480 2116
ath10kcal_extract "art" 0x5000 0x844
ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) -1)
;;
r6100)
ath10kcal_extract "caldata" 20480 2116
ath10kcal_extract "caldata" 0x5000 0x844
ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) +2)
;;
rb-952ui-5ac2nd|\
rb-wapg-5hact2hnd)
ath10kcal_from_file "/sys/firmware/routerboot/ext_wlan_data" 20480 2116
ath10kcal_from_file "/sys/firmware/routerboot/ext_wlan_data" 0x5000 0x844
;;
re355|\
re450|\
tl-wr902ac-v1)
ath10kcal_extract "art" 20480 2116
ath10kcal_extract "art" 0x5000 0x844
ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -2)
;;
unifiac-lite|\
unifiac-pro)
ath10kcal_extract "EEPROM" 20480 2116
ath10kcal_extract "EEPROM" 0x5000 0x844
;;
wi2a-ac200i)
ath10kcal_extract "ART" 20480 2116
ath10kcal_extract "ART" 0x5000 0x844
;;
esac
;;
......@@ -184,25 +145,25 @@ case "$FIRMWARE" in
case $board in
archer-c5|\
archer-c7)
ath10kcal_extract "art" 20480 2116
ath10kcal_extract "art" 0x5000 0x844
ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) -2)
;;
nbg6616|\
nbg6716)
ath10kcal_extract "RFdata" 20480 2116
ath10kcal_extract "RFdata" 0x5000 0x844
ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) -2)
;;
om5p-ac)
ath10kcal_extract "ART" 20480 2116
ath10kcal_extract "ART" 0x5000 0x844
ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +16)
;;
rb-911g-5hpacd|\
rb-921gs-5hpacd-r2|\
rb-962uigs-5hact2hnt)
ath10kcal_from_file "/sys/firmware/routerboot/ext_wlan_data" 20480 2116
ath10kcal_from_file "/sys/firmware/routerboot/ext_wlan_data" 0x5000 0x844
;;
wlr8100)
ath10kcal_extract "art" 20480 2116
ath10kcal_extract "art" 0x5000 0x844
ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) +1)
;;
esac
......@@ -213,24 +174,29 @@ case "$FIRMWARE" in
archer-c59-v1|\
archer-c59-v2|\
archer-c60-v1|\
archer-c60-v2|\
cf-e355ac-v2|\
cf-e375ac)
ath10kcal_extract "art" 20480 12064
ath10kcal_extract "art" 0x5000 0x2f20
ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \
/lib/firmware/ath10k/QCA9888/hw2.0/board.bin
;;
archer-c60-v2)
ath10kcal_extract "art" 0x5000 0x2f20
ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \
/lib/firmware/ath10k/QCA9888/hw2.0/board.bin
ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -1)
;;
cf-e385ac)
ath10kcal_extract "art" 20480 12064
ath10kcal_extract "art" 0x5000 0x2f20
;;
k2t)
ath10kcal_extract "art" 20480 12064
ath10kcal_extract "art" 0x5000 0x2f20
ath10kcal_patch_mac_crc $(macaddr_add $(cat /sys/class/net/eth0/address) +2)
ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \
/lib/firmware/ath10k/QCA9888/hw2.0/board.bin
;;
tl-wdr6500-v6)
ath10kcal_extract "art" 8192 12064
tl-wdr6500-v6)
ath10kcal_extract "art" 0x2000 0x2f20
ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \
/lib/firmware/ath10k/QCA9888/hw2.0/board.bin
;;
......
......@@ -17,7 +17,7 @@ case "$board" in
archer-c59-v2|\
archer-c60-v1|\
archer-c60-v2)
echo $(macaddr_add $(mtd_get_mac_binary mac 8) $(($PHYNBR - 1)) ) > /sys${DEVPATH}/macaddress
echo $(macaddr_add $(mtd_get_mac_binary mac 0x8) $(($PHYNBR - 1)) ) > /sys${DEVPATH}/macaddress
;;
tl-wdr6500-v6)
echo $(macaddr_add $(mtd_get_mac_binary art 2061) $(($PHYNBR - 2)) ) > /sys${DEVPATH}/macaddress
......@@ -25,4 +25,3 @@ case "$board" in
*)
;;
esac
......@@ -12,6 +12,9 @@
devdir=$(dirname $DEVPATH)
devdir=$(dirname $devdir)
phydir=/sys$devdir/ieee80211
[ -d $phydir ] || exit 0
phyname=$(cat $phydir/phy*/name)
[ -z $phyname -o $ACTION != "add" ] && exit 0
......
......@@ -24,7 +24,7 @@ preinit_set_mac_address() {
case $(board_name) in
c-55|\
c-60)
mac_lan=$(mtd_get_mac_binary art 0)
mac_lan=$(mtd_get_mac_binary art 0x0)
[ -n "$mac_lan" ] && ifconfig eth0 hw ether "$mac_lan"
;;
dir-615-c1|\
......@@ -40,28 +40,28 @@ preinit_set_mac_address() {
;;
mr18|\
z1)
mac_lan=$(mtd_get_mac_binary_ubi board-config 102)
mac_lan=$(mtd_get_mac_binary_ubi board-config 0x66)
[ -n "$mac_lan" ] && ifconfig eth0 hw ether "$mac_lan"
;;
r6100)
mac_lan=$(mtd_get_mac_binary caldata 0)
mac_lan=$(mtd_get_mac_binary caldata 0x0)
[ -n "$mac_lan" ] && ifconfig eth1 hw ether "$mac_lan"
mac_wan=$(mtd_get_mac_binary caldata 6)
mac_wan=$(mtd_get_mac_binary caldata 0x6)
[ -n "$mac_wan" ] && ifconfig eth0 hw ether "$mac_wan"
;;
rambutan)
mac_lan=$(mtd_get_mac_binary art 0)
mac_lan=$(mtd_get_mac_binary art 0x0)
[ -n "$mac_lan" ] && ifconfig eth0 hw ether "$mac_lan"
mac_wan=$(mtd_get_mac_binary art 6)
mac_wan=$(mtd_get_mac_binary art 0x6)
[ -n "$mac_wan" ] && ifconfig eth1 hw ether "$mac_wan"
;;
wrt160nl)
fetch_mac_from_mtd nvram lan_hwaddr wan_hwaddr
;;
sbr-ac1750)
mac_lan=$(mtd_get_mac_binary ft 0)
mac_lan=$(mtd_get_mac_binary ft 0x0)
[ -n "$mac_lan" ] && ifconfig eth1 hw ether "$mac_lan"
mac_wan=$(mtd_get_mac_binary ft 18)
mac_wan=$(mtd_get_mac_binary ft 0x12)
[ -n "$mac_wan" ] && ifconfig eth0 hw ether "$mac_wan"
;;
esac
......
......@@ -11,11 +11,6 @@ board=$(board_name)
boardname="${board##*,}"
case "$board" in
p2w,r619ac |\
p2w,r619ac-128m)
ucidef_set_led_wlan "wlan2g" "WLAN2G" "r619ac:blue:wlan2g" "phy0tpt"
ucidef_set_led_wlan "wlan5g" "WLAN5G" "r619ac:blue:wlan5g" "phy1tpt"
;;
asus,rt-ac58u)
ucidef_set_led_wlan "wlan2g" "WLAN2G" "${boardname}:blue:wlan2G" "phy0tpt"
ucidef_set_led_wlan "wlan5g" "WLAN5G" "${boardname}:blue:wlan5G" "phy1tpt"
......@@ -46,15 +41,20 @@ engenius,eap1300)
glinet,gl-b1300)
ucidef_set_led_wlan "wlan" "WLAN" "${boardname}:green:wlan" "phy0tpt"
;;
hugo,ac1200)
ucidef_set_led_default "green" "GREEN" "${boardname}:green:ctrl1" "1"
ucidef_set_led_default "red" "RED" "${boardname}:red:ctrl2" "1"
ucidef_set_led_default "blue" "BLUE" "${boardname}:blue:ctrl3" "1"
;;
netgear,ex6100v2 |\
netgear,ex6150v2)
ucidef_set_led_wlan "wlan2g" "WLAN2G" "ex61x0v2:green:router" "phy0tpt"
ucidef_set_led_wlan "wlan5g" "WLAN5G" "ex61x0v2:green:client" "phy1tpt"
;;
hugo,ac1200)
ucidef_set_led_default "green" "GREEN" "${boardname}:green:ctrl1" "1"
ucidef_set_led_default "red" "RED" "${boardname}:red:ctrl2" "1"
ucidef_set_led_default "blue" "BLUE" "${boardname}:blue:ctrl3" "1"
p2w,r619ac |\
p2w,r619ac-128m)
ucidef_set_led_wlan "wlan2g" "WLAN2G" "r619ac:blue:wlan2g" "phy0tpt"
ucidef_set_led_wlan "wlan5g" "WLAN5G" "r619ac:blue:wlan5g" "phy1tpt"
;;
zyxel,nbg6617)
ucidef_set_led_wlan "wlan2g" "WLAN2G" "${boardname}:green:wlan2G" "phy0tpt"
......
......@@ -16,24 +16,20 @@ ipq40xx_setup_interfaces()
ucidef_add_switch "switch0" \
"0t@eth0" "4:lan" "5:wan"
;;
p2w,r619ac|\
p2w,r619ac-128m|\
zyxel,nbg6617)
ucidef_add_switch "switch0" \
"0t@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan:5"
;;
asus,map-ac2200|\
openmesh,a42|\
openmesh,a62)
ucidef_add_switch "switch0" \
"0t@eth0" "5:lan" "4:wan"
;;
hugo,ac1200)
asus,rt-ac58u|\
p2w,r619ac|\
p2w,r619ac-128m|\
zyxel,nbg6617)
ucidef_add_switch "switch0" \
"0t@eth0" "5:wan" "3:lan"
"0t@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
;;
asus,rt-acrh17|\
asus,rt-ac58u|\
avm,fritzbox-4040|\
linksys,ea6350v3)
ucidef_add_switch "switch0" \
......@@ -53,6 +49,10 @@ ipq40xx_setup_interfaces()
ucidef_add_switch "switch0" \
"0t@eth0" "3:lan" "4:lan" "5:wan"
;;
hugo,ac1200)
ucidef_add_switch "switch0" \
"0t@eth0" "5:wan" "3:lan"
;;
*)
echo "Unsupported hardware. Network interfaces not initialized"
;;
......@@ -62,6 +62,9 @@ ipq40xx_setup_interfaces()
ipq40xx_setup_macs()
{
local board="$1"
local lan_mac=""
local wan_mac=""
local label_mac=""
case "$board" in
asus,rt-acrh17|\
......@@ -81,8 +84,9 @@ ipq40xx_setup_macs()
;;
esac
[ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
[ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
[ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
[ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
[ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
}
board_config_update
......
#!/bin/sh
# xor multiple hex values of the same length
xor() {
local val
local ret="0x$1"
local retlen=${#1}
shift
while [ -n "$1" ]; do
val="0x$1"
ret=$((ret ^ val))
shift
done
printf "%0${retlen}x" "$ret"
}
ath10kcal_die() {
echo "ath10cal: " "$*"
exit 1
}
ath10kcal_extract() {
local part=$1
local offset=$2
local count=$3
local mtd
mtd=$(find_mtd_chardev $part)
[ -n "$mtd" ] || \
ath10kcal_die "no mtd device found for partition $part"
dd if=$mtd of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \
ath10kcal_die "failed to extract calibration data from $mtd"
}
ath10kcal_ubi_extract() {
local part=$1
local offset=$2
local count=$3
local ubidev
local ubi
. /lib/upgrade/nand.sh
ubidev=$(nand_find_ubi $CI_UBIPART)
ubi=$(nand_find_volume $ubidev $part)
[ -n "$ubi" ] || \
ath10kcal_die "no UBI volume found for $part"
dd if=/dev/$ubi of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \
ath10kcal_die "failed to extract from $ubi"
}
ath10kcal_patch_mac_crc() {
local mac=$1
local mac_offset=6
local chksum_offset=2
local xor_mac
local xor_fw_mac
local xor_fw_chksum
[ -z "$mac" ] && return
xor_fw_mac=$(hexdump -v -n 6 -s $mac_offset -e '/1 "%02x"' /lib/firmware/$FIRMWARE)
xor_fw_mac="${xor_fw_mac:0:4} ${xor_fw_mac:4:4} ${xor_fw_mac:8:4}"
macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=6 count=6
xor_mac=${mac//:/}
xor_mac="${xor_mac:0:4} ${xor_mac:4:4} ${xor_mac:8:4}"
xor_fw_chksum=$(hexdump -v -n 2 -s $chksum_offset -e '/1 "%02x"' /lib/firmware/$FIRMWARE)
xor_fw_chksum=$(xor $xor_fw_chksum $xor_fw_mac $xor_mac)
printf "%b" "\x${xor_fw_chksum:0:2}\x${xor_fw_chksum:2:2}" | \
dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$chksum_offset count=2
}
ath10kcal_is_caldata_valid() {
local expected="$1"
magic=$(hexdump -v -n 2 -e '1/1 "%02x"' /lib/firmware/$FIRMWARE)
[[ "$magic" == "$expected" ]]
return $?
}
[ -e /lib/firmware/$FIRMWARE ] && exit 0
. /lib/functions.sh
. /lib/functions/system.sh
. /lib/functions/caldata.sh
board=$(board_name)
case "$FIRMWARE" in
"ath10k/cal-pci-0000:01:00.0.bin")
case "$board" in
meraki,mr33)
ath10kcal_ubi_extract "ART" 36864 2116
ath10kcal_is_caldata_valid "4408" || ath10kcal_extract "ART" 36864 2116
ath10kcal_patch_mac_crc $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 102) +1)
caldata_extract_ubi "ART" 0x9000 0x844
caldata_valid "4408" || caldata_extract "ART" 0x9000 0x844
ath10k_patch_mac $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66) +1)
;;
esac
;;
"ath10k/pre-cal-pci-0000:01:00.0.bin")
case "$board" in
asus,map-ac2200)
ath10kcal_ubi_extract "Factory" 36864 12064
caldata_extract_ubi "Factory" 0x9000 0x2f20
ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \
/lib/firmware/ath10k/QCA9888/hw2.0/board.bin
;;
asus,rt-acrh17)
CI_UBIPART=UBI_DEV
ath10kcal_ubi_extract "Factory" 36864 12064
caldata_extract_ubi "Factory" 0x9000 0x2f20
;;
openmesh,a62)
ath10kcal_extract "0:ART" 36864 12064
caldata_extract "0:ART" 0x9000 0x2f20
;;
p2w,r619ac |\
p2w,r619ac-128m)
ath10kcal_extract "ART" 36864 12064
caldata_extract "ART" 0x9000 0x2f20
;;
esac
;;
......@@ -132,40 +44,40 @@ case "$FIRMWARE" in
p2w,r619ac |\
p2w,r619ac-128m |\
qcom,ap-dk01.1-c1)
ath10kcal_extract "ART" 4096 12064
caldata_extract "ART" 0x1000 0x2f20
;;
asus,map-ac2200)
ath10kcal_ubi_extract "Factory" 4096 12064
caldata_extract_ubi "Factory" 0x1000 0x2f20
;;
asus,rt-acrh17|\
asus,rt-ac58u)
CI_UBIPART=UBI_DEV
ath10kcal_ubi_extract "Factory" 4096 12064
caldata_extract_ubi "Factory" 0x1000 0x2f20
;;
avm,fritzbox-4040)
/usr/bin/fritz_cal_extract -i 1 -s 0x400 -e 0x207 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader_config")
;;
meraki,mr33)
ath10kcal_ubi_extract "ART" 4096 12064
ath10kcal_is_caldata_valid "202f" || ath10kcal_extract "ART" 4096 12064
ath10kcal_patch_mac_crc $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 102) +2)
;;
netgear,ex6100v2 |\
netgear,ex6150v2)
ath10kcal_extract "ART" 4096 12064
ath10kcal_patch_mac_crc $(mtd_get_mac_binary dnidata 0)
;;
compex,wpj428 |\
engenius,eap1300 |\
hugo,ac1200 |\
openmesh,a42 |\
openmesh,a62)
ath10kcal_extract "0:ART" 4096 12064
caldata_extract "0:ART" 0x1000 0x2f20
;;
meraki,mr33)
caldata_extract_ubi "ART" 0x1000 0x2f20
caldata_valid "202f" || caldata_extract 0x1000 0x2f20
ath10k_patch_mac $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66) +2)
;;
netgear,ex6100v2 |\
netgear,ex6150v2)
caldata_extract "ART" 0x1000 0x2f20
ath10k_patch_mac $(mtd_get_mac_binary dnidata 0x0)
;;
zyxel,nbg6617 |\
zyxel,wre6606)
ath10kcal_extract "ART" 4096 12064
ath10kcal_patch_mac_crc $(macaddr_add $(cat /sys/class/net/eth0/address) -2)
caldata_extract "ART" 0x1000 0x2f20
ath10k_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -2)
;;
esac
;;
......@@ -177,39 +89,39 @@ case "$FIRMWARE" in
p2w,r619ac |\
p2w,r619ac-128m |\
qcom,ap-dk01.1-c1)
ath10kcal_extract "ART" 20480 12064
caldata_extract "ART" 0x5000 0x2f20
;;
asus,map-ac2200)
ath10kcal_ubi_extract "Factory" 20480 12064
caldata_extract "Factory" 0x5000 0x2f20
;;
asus,rt-ac58u)
CI_UBIPART=UBI_DEV
ath10kcal_ubi_extract "Factory" 20480 12064
caldata_extract_ubi "Factory" 0x5000 0x2f20
;;
avm,fritzbox-4040)
/usr/bin/fritz_cal_extract -i 1 -s 0x400 -e 0x208 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader_config")
;;
meraki,mr33)
ath10kcal_ubi_extract "ART" 20480 12064
ath10kcal_is_caldata_valid "202f" || ath10kcal_extract "ART" 20480 12064
ath10kcal_patch_mac_crc $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 102) +3)
;;
netgear,ex6100v2 |\
netgear,ex6150v2)
ath10kcal_extract "ART" 20480 12064
ath10kcal_patch_mac_crc $(mtd_get_mac_binary dnidata 12)
;;
compex,wpj428 |\
engenius,eap1300 |\
hugo,ac1200 |\
openmesh,a42 |\
openmesh,a62)
ath10kcal_extract "0:ART" 20480 12064
caldata_extract "0:ART" 0x5000 0x2f20
;;
meraki,mr33)
caldata_extract_ubi "ART" 0x5000 0x2f20
caldata_valid "202f" || caldata_extract "ART" 0x5000 0x2f20
ath10k_patch_mac $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66) +3)
;;
netgear,ex6100v2 |\
netgear,ex6150v2)
caldata_extract "ART" 0x5000 0x2f20
ath10k_patch_mac $(mtd_get_mac_binary dnidata 0xc)
;;
zyxel,nbg6617 |\
zyxel,wre6606)
ath10kcal_extract "ART" 20480 12064
ath10kcal_patch_mac_crc $(macaddr_add $(cat /sys/class/net/eth0/address) -1)
caldata_extract "ART" 0x5000 0x2f20
ath10k_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -1)
;;
esac
;;
......
......@@ -5,23 +5,24 @@
preinit_set_mac_address() {
case $(board_name) in
asus,map-ac2200)
base_mac=$(mtd_get_mac_binary_ubi Factory 4102)
base_mac=$(mtd_get_mac_binary_ubi Factory 0x1006)
ip link set dev eth0 address $(macaddr_add "$base_mac" +1)
ip link set dev eth1 address $(macaddr_add "$base_mac" +3)
;;
asus,rt-acrh17|\
asus,rt-ac58u)
CI_UBIPART=UBI_DEV
mac=$(macaddr_add $(mtd_get_mac_binary_ubi Factory 4102) +1)
mac=$(macaddr_add $(mtd_get_mac_binary_ubi Factory 0x1006) +1)
ifconfig eth0 hw ether $mac 2>/dev/null
;;
meraki,mr33)
mac_lan=$(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 102)
mac_lan=$(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66)
[ -n "$mac_lan" ] && ip link set dev eth0 address "$mac_lan"
;;
zyxel,nbg6617)
base_mac=$(cat /sys/class/net/eth0/address)
ip link set dev eth0 address $(macaddr_add "$base_mac" +2)
ip link set dev eth1 address $(macaddr_add "$base_mac" +3)
;;
esac
}
......
......@@ -165,6 +165,19 @@ define Device/glinet_gl-b1300
endef
TARGET_DEVICES += glinet_gl-b1300
define Device/hugo_ac1200
$(call Device/FitImage)
DEVICE_TITLE := Hugo AC1200
BOARD_NAME := hugo_ac1200
DEVICE_DTS := qcom-ipq4019-hugo-ac1200
KERNEL_SIZE := 4096k
IMAGE_SIZE := 31232k
IMAGES := sysupgrade.bin
IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata
DEVICE_PACKAGES := ipq-wifi-hugo_ac1200
endef
TARGET_DEVICES += hugo_ac1200
define Device/linksys_ea6350v3
# The Linksys EA6350v3 has a uboot bootloader that does not
# support either booting lzma kernel images nor booting UBI
......@@ -260,22 +273,8 @@ define Device/openmesh_a62
IMAGE/sysupgrade.bin/squashfs := append-rootfs | pad-rootfs | sysupgrade-tar rootfs=$$$$@ | append-metadata
DEVICE_PACKAGES := ath10k-firmware-qca9888-ct uboot-envtools
endef
TARGET_DEVICES += openmesh_a62
define Device/qcom_ap-dk01.1-c1
DEVICE_TITLE := QCA AP-DK01.1-C1
BOARD_NAME := ap-dk01.1-c1
DEVICE_DTS := qcom-ipq4019-ap.dk01.1-c1
KERNEL_INSTALL := 1
KERNEL_SIZE := 4096k
IMAGE_SIZE := 26624k
$(call Device/FitImage)
IMAGES := sysupgrade.bin
IMAGE/sysupgrade.bin := append-kernel | pad-to $$$${KERNEL_SIZE} | append-rootfs | pad-rootfs | append-metadata
endef
TARGET_DEVICES += qcom_ap-dk01.1-c1
define Device/p2w_r619ac
$(call Device/FitzImage)
$(call Device/UbiFit)
......@@ -305,6 +304,19 @@ define Device/p2w_r619ac-128m
endef
TARGET_DEVICES += p2w_r619ac-128m
define Device/qcom_ap-dk01.1-c1
DEVICE_TITLE := QCA AP-DK01.1-C1
BOARD_NAME := ap-dk01.1-c1
DEVICE_DTS := qcom-ipq4019-ap.dk01.1-c1
KERNEL_INSTALL := 1
KERNEL_SIZE := 4096k
IMAGE_SIZE := 26624k
$(call Device/FitImage)
IMAGES := sysupgrade.bin
IMAGE/sysupgrade.bin := append-kernel | pad-to $$$${KERNEL_SIZE} | append-rootfs | pad-rootfs | append-metadata
endef
TARGET_DEVICES += qcom_ap-dk01.1-c1
define Device/qcom_ap-dk04.1-c1
$(call Device/FitImage)
$(call Device/UbiFit)
......@@ -318,19 +330,6 @@ define Device/qcom_ap-dk04.1-c1
endef
TARGET_DEVICES += qcom_ap-dk04.1-c1
define Device/hugo_ac1200
$(call Device/FitImage)
DEVICE_TITLE := Hugo AC1200
BOARD_NAME := hugo_ac1200
DEVICE_DTS := qcom-ipq4019-hugo-ac1200
KERNEL_SIZE := 4096k
IMAGE_SIZE := 31232k
IMAGES := sysupgrade.bin
IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata
DEVICE_PACKAGES := ipq-wifi-hugo_ac1200
endef
TARGET_DEVICES += hugo_ac1200
define Device/zyxel_nbg6617
$(call Device/FitImageLzma)
DEVICE_DTS := qcom-ipq4018-nbg6617
......
#!/bin/sh
# xor multiple hex values of the same length
xor() {
local val
local ret="0x$1"
local retlen=${#1}
shift
while [ -n "$1" ]; do
val="0x$1"
ret=$((ret ^ val))
shift
done
printf "%0${retlen}x" "$ret"
}
ath10kcal_die() {
echo "ath10cal: " "$*"
exit 1
}
ath10kcal_from_file() {
local source=$1
local offset=$2
local count=$3
dd if=$source of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \
ath10kcal_die "failed to extract calibration data from $source"
}
ath10kcal_extract() {
local part=$1
local offset=$2
local count=$3
local mtd
mtd=$(find_mtd_chardev $part)
[ -n "$mtd" ] || \
ath10kcal_die "no mtd device found for partition $part"
dd if=$mtd of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \
ath10kcal_die "failed to extract calibration data from $mtd"
}
ath10kcal_patch_mac_crc() {
local mac=$1
local mac_offset=6
local chksum_offset=2
local xor_mac
local xor_fw_mac
local xor_fw_chksum
[ -z "$mac" ] && return
xor_fw_mac=$(hexdump -v -n 6 -s $mac_offset -e '/1 "%02x"' /lib/firmware/$FIRMWARE)
xor_fw_mac="${xor_fw_mac:0:4} ${xor_fw_mac:4:4} ${xor_fw_mac:8:4}"
macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=6 count=6
xor_mac=${mac//:/}
xor_mac="${xor_mac:0:4} ${xor_mac:4:4} ${xor_mac:8:4}"
xor_fw_chksum=$(hexdump -v -n 2 -s $chksum_offset -e '/1 "%02x"' /lib/firmware/$FIRMWARE)
xor_fw_chksum=$(xor $xor_fw_chksum $xor_fw_mac $xor_mac)
printf "%b" "\x${xor_fw_chksum:0:2}\x${xor_fw_chksum:2:2}" | \
dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$chksum_offset count=2
}
[ -e /lib/firmware/$FIRMWARE ] && exit 0
. /lib/functions.sh
. /lib/functions/system.sh
. /lib/functions/caldata.sh
board=$(board_name)
......@@ -80,68 +10,68 @@ case "$FIRMWARE" in
"ath10k/pre-cal-pci-0000:01:00.0.bin")
case $board in
buffalo,wxr-2533dhp)
ath10kcal_extract "ART" 4096 12064
ath10kcal_patch_mac_crc $(mtd_get_mac_binary ART 30)
caldata_extract "ART" 0x1000 0x2f20
ath10k_patch_mac $(mtd_get_mac_binary ART 0x1e)
;;
linksys,ea8500)
ath10kcal_extract "art" 4096 12064
ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) +1)
caldata_extract "art" 0x1000 0x2f20
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) +1)
;;
nec,wg2600hp)
ath10kcal_extract "ART" 4096 12064
ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary PRODUCTDATA 12) +1)
caldata_extract "ART" 0x1000 0x2f20
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary PRODUCTDATA 0xc) +1)
;;
netgear,d7800 |\
netgear,r7500v2 |\
netgear,r7800)
ath10kcal_extract "art" 4096 12064
ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary art 6) +1)
caldata_extract "art" 0x1000 0x2f20
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x6) +1)
;;
tplink,c2600)
ath10kcal_extract "radio" 4096 12064
ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary default-mac 8) -1)
caldata_extract "radio" 0x1000 0x2f20
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary default-mac 0x8) -1)
;;
tplink,vr2600v)
ath10kcal_extract "ART" 4096 12064
ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary default-mac 0) -1)
caldata_extract "ART" 0x1000 0x2f20
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary default-mac 0x0) -1)
;;
zyxel,nbg6817)
ath10kcal_extract "0:ART" 4096 12064
ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii 0:APPSBLENV ethaddr) +1)
caldata_extract "0:ART" 0x1000 0x2f20
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii 0:APPSBLENV ethaddr) +1)
;;
esac
;;
"ath10k/pre-cal-pci-0001:01:00.0.bin")
case $board in
buffalo,wxr-2533dhp)
ath10kcal_extract "ART" 20480 12064
ath10kcal_patch_mac_crc $(mtd_get_mac_binary ART 24)
caldata_extract "ART" 0x5000 0x2f20
ath10k_patch_mac $(mtd_get_mac_binary ART 0x18)
;;
linksys,ea8500)
ath10kcal_extract "art" 20480 12064
ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) +2)
caldata_extract "art" 0x5000 0x2f20
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) +2)
;;
nec,wg2600hp)
ath10kcal_extract "ART" 20480 12064
ath10kcal_patch_mac_crc $(mtd_get_mac_binary PRODUCTDATA 12)
caldata_extract "ART" 0x5000 0x2f20
ath10k_patch_mac $(mtd_get_mac_binary PRODUCTDATA 0xc)
;;
netgear,d7800 |\
netgear,r7500v2 |\
netgear,r7800)
ath10kcal_extract "art" 20480 12064
ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary art 6) +2)
caldata_extract "art" 0x5000 0x2f20
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x6) +2)
;;
tplink,c2600)
ath10kcal_extract "radio" 20480 12064
ath10kcal_patch_mac_crc $(mtd_get_mac_binary default-mac 8)
caldata_extract "radio" 0x5000 0x2f20
ath10k_patch_mac $(mtd_get_mac_binary default-mac 0x8)
;;
tplink,vr2600v)
ath10kcal_extract "ART" 20480 12064
ath10kcal_patch_mac_crc $(mtd_get_mac_binary default-mac 0)
caldata_extract "ART" 0x5000 0x2f20
ath10k_patch_mac $(mtd_get_mac_binary default-mac 0x0)
;;
zyxel,nbg6817)
ath10kcal_extract "0:ART" 20480 12064
ath10kcal_patch_mac_crc $(mtd_get_mac_ascii 0:APPSBLENV ethaddr)
caldata_extract "0:ART" 0x5000 0x2f20
ath10k_patch_mac $(mtd_get_mac_ascii 0:APPSBLENV ethaddr)
;;
esac
;;
......
......@@ -29,4 +29,3 @@ set_ether_mac() {
}
boot_hook_add preinit_main set_ether_mac
......@@ -3,47 +3,18 @@
[ -e /lib/firmware/$FIRMWARE ] && exit 0
. /lib/functions.sh
. /lib/functions/system.sh
. /lib/upgrade/nand.sh
ath10k_caldata_die() {
echo "ath10k caldata: " "$*"
exit 1
}
ath10k_caldata_extract_ubi() {
local part=$1
local offset=$2
local count=$3
local ubidev=$(nand_find_ubi $CI_UBIPART)
local ubi
ubi=$(nand_find_volume $ubidev $part)
[ -n "$ubi" ] || \
ath10k_caldata_die "no UBI volume found for $part"
dd if=/dev/$ubi of=/lib/firmware/$FIRMWARE bs=1 skip=$offset count=$count 2>/dev/null || \
ath10k_caldata_die "failed to extract from $ubi"
}
ath10k_caldata_set_macaddr() {
local macaddr=$1
macaddr_2bin $macaddr | dd of=/lib/firmware/$FIRMWARE \
conv=notrunc bs=1 seek=6 count=6
}
. /lib/functions/caldata.sh
case "$FIRMWARE" in
"ath10k/cal-pci-0000:02:00.0.bin")
board=$(board_name)
case $board in
bt,homehub-v5a)
ath10k_caldata_extract_ubi "caldata" 20480 2116
ath10k_caldata_set_macaddr $(macaddr_add $(mtd_get_mac_binary_ubi caldata 4364) +3)
caldata_extract_ubi "caldata" 0x5000 0x844
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary_ubi caldata 0x110c) +3)
;;
*)
ath10k_caldata_die "board $board is not supported yet"
caldata_die "board $board is not supported yet"
;;
esac
;;
......
#!/bin/sh
# Based on ar71xx 10-ath9k-eeprom
[ -e /lib/firmware/$FIRMWARE ] && exit 0
. /lib/functions.sh
. /lib/functions/system.sh
. /lib/upgrade/nand.sh
. /lib/functions/caldata.sh
# xor multiple hex values of the same length
xor() {
local val
local ret="0x$1"
local retlen=${#1}
shift
while [ -n "$1" ]; do
val="0x$1"
ret=$((ret ^ val))
shift
done
printf "%0${retlen}x" "$ret"
}
ath9k_eeprom_die() {
echo "ath9k eeprom: $*"
exit 1
}
ath9k_eeprom_extract_raw() {
local source=$1
local offset=$2
local swap=$3
local size=4096
local bs=1
local conv=
if [ $swap -gt 0 ]; then
bs=2
conv="conv=swab"
size=$((size / bs))
offset=$((offset / bs))
fi
dd if=$source of=/lib/firmware/$FIRMWARE bs=$bs skip=$offset count=$size $conv 2>/dev/null || \
ath9k_eeprom_die "failed to extract from $mtd"
}
ath9k_eeprom_extract_reverse() {
caldata_extract_swap() {
local part=$1
local offset=$2
local count=$3
local mtd
local reversed
local caldata
mtd=$(find_mtd_chardev "$part")
reversed=$(hexdump -v -s $offset -n $count -e '/1 "%02x "' $mtd)
for byte in $reversed; do
caldata="\x${byte}${caldata}"
done
printf "%b" "$caldata" > /lib/firmware/$FIRMWARE
}
ath9k_eeprom_extract() {
local part=$1
local offset=$2
local swap=$3
local mtd
mtd=$(find_mtd_chardev $part)
[ -n "$mtd" ] || \
ath9k_eeprom_die "no mtd device found for partition $part"
ath9k_eeprom_extract_raw $mtd $offset $swap
}
ath9k_ubi_eeprom_extract() {
local part=$1
local offset=$2
local swap=$3
local ubidev=$(nand_find_ubi $CI_UBIPART)
local ubi
ubi=$(nand_find_volume $ubidev $part)
[ -n "$ubi" ] || \
ath9k_eeprom_die "no UBI volume found for $part"
ath9k_eeprom_extract_raw /dev/$ubi $offset $swap
}
ath9k_patch_fw_mac_crc() {
local mac=$1
local mac_offset=$2
local chksum_offset=$((mac_offset - 10))
ath9k_patch_fw_mac "${mac}" "${mac_offset}" "${chksum_offset}"
}
ath9k_patch_fw_mac() {
local mac=$1
local mac_offset=$2
local chksum_offset=$3
local xor_mac
local xor_fw_mac
local xor_fw_chksum
[ -z "$mac" -o -z "$mac_offset" ] && return
[ -n "$chksum_offset" ] && {
xor_mac=${mac//:/}
xor_mac="${xor_mac:0:4} ${xor_mac:4:4} ${xor_mac:8:4}"
xor_fw_mac=$(hexdump -v -n 6 -s $mac_offset -e '/1 "%02x"' /lib/firmware/$FIRMWARE)
xor_fw_mac="${xor_fw_mac:0:4} ${xor_fw_mac:4:4} ${xor_fw_mac:8:4}"
xor_fw_chksum=$(hexdump -v -n 2 -s $chksum_offset -e '/1 "%02x"' /lib/firmware/$FIRMWARE)
xor_fw_chksum=$(xor $xor_fw_chksum $xor_fw_mac $xor_mac)
[ -n "$mtd" ] || caldata_die "no mtd device found for partition $part"
printf "%b" "\x${xor_fw_chksum:0:2}\x${xor_fw_chksum:2:2}" | \
dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$chksum_offset count=2
}
offset=$(($offset / 2))
count=$(($count / 2))
macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$mac_offset count=6
dd if=$mtd of=/lib/firmware/$FIRMWARE bs=2 skip=$offset count=$count conv=swab 2>/dev/null || \
caldata_die "failed to extract calibration data from $mtd"
}
case "$FIRMWARE" in
......@@ -135,43 +28,43 @@ case "$FIRMWARE" in
case "$board" in
arcadyan,arv7518pw)
ath9k_eeprom_extract "boardconfig" 1024 1
caldata_extract_swap "boardconfig" 0x400 0x1000
;;
arcadyan,arv8539pw22)
ath9k_eeprom_extract "art" 1024 1
caldata_extract_swap "art" 0x400 0x1000
;;
bt,homehub-v2b)
ath9k_eeprom_extract "art" 0 1
ath9k_patch_fw_mac_crc "00:00:00:00:00:00" 524
caldata_extract_swap "art" 0x0 0x1000
ath9k_patch_mac_crc "00:00:00:00:00:00" 0x20c
;;
bt,homehub-v3a)
ath9k_eeprom_extract "art-copy" 0 1
ath9k_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_ascii uboot_env ethaddr) +2) 268
caldata_extract_swap "art-copy" 0x0 0x1000
ath9k_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii uboot_env ethaddr) +2) 0x10c
;;
bt,homehub-v5a)
ath9k_ubi_eeprom_extract "caldata" 4096 0
ath9k_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_binary_ubi caldata 4364) +2) 268
caldata_extract_ubi "caldata" 0x1000 0x1000
ath9k_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary_ubi caldata 0x110c) +2) 0x10c
;;
netgear,dgn3500|netgear,dgn3500b)
ath9k_eeprom_extract "calibration" 61440 0
ath9k_patch_fw_mac_crc $(macaddr_add $(mtd_get_mac_ascii uboot-env ethaddr) +2) 524
caldata_extract "calibration" 0xf000 0x1000
ath9k_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii uboot-env ethaddr) +2) 0x20c
;;
avm,fritz3370-rev2-hynix|\
avm,fritz3370-rev2-micron|\
avm,fritz7362sl)
ath9k_eeprom_extract_reverse "urlader" 5441 1088
caldata_extract_reverse "urlader" 0x1541 0x440
;;
avm,fritz7312|avm,fritz7320|avm,fritz7360sl)
ath9k_eeprom_extract "urlader" 2437 0
caldata_extract "urlader" 0x985 0x1000
;;
avm,fritz7412)
/usr/bin/fritz_cal_extract -i 1 -s 0x1e000 -e 0x207 -l 4096 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader")
;;
tplink,tdw8970|tplink,tdw8980)
ath9k_eeprom_extract "boardconfig" 135168 0
caldata_extract "boardconfig" 0x21000 0x1000
;;
*)
ath9k_eeprom_die "board $board is not supported yet"
caldata_die "board $board is not supported yet"
;;
esac
;;
......
......@@ -3,37 +3,7 @@
# Copyright (C) 2013 OpenWrt.org
#
LED_OPTIONS_CHANGED=0
. /lib/functions.sh
do_led_update_sysfs()
{
local cfg=$1; shift
local tuples="$@"
local sysfs
local name
config_get sysfs $cfg sysfs
config_get name $cfg name
[ -z "$sysfs" ] && return
for tuple in $tuples; do
local old=${tuple%=*}
local new=${tuple#*=}
local new_sysfs
new_sysfs=$(echo ${sysfs} | sed "s/${old}/${new}/")
[ "$new_sysfs" = "$sysfs" ] && continue
uci set system.${cfg}.sysfs="${new_sysfs}"
LED_OPTIONS_CHANGED=1
logger -t led-migration "sysfs option of LED \"${name}\" updated to ${new_sysfs}"
done;
}
. /lib/functions/migrations.sh
do_internet_led_rename()
{
......@@ -45,38 +15,29 @@ do_internet_led_rename()
uci rename system.led_internet=led_dsl
uci set system.led_dsl.name=dsl
LED_OPTIONS_CHANGED=1
logger -t led-migration "internet led renamed to dsl"
}
migrate_leds()
{
config_load system
config_foreach do_led_update_sysfs led "$@"
}
case "$(board_name)" in
alphanetworks,asl56026|\
arcadyan,arv452cqw|\
arcadyan,arv7510pw22|\
arcadyan,arv7519rw22|\
arcadyan,arv752dpw|\
arcadyan,arv752dpw22|\
alphanetworks,asl56026|\
arcadyan,vg3503j|\
avm,fritz7360sl|\
bt,homehub-v2b|\
bt,homehub-v3a|\
bt,homehub-v5a|\
avm,fritz7360sl|\
arcadyan,vg3503j)
bt,homehub-v5a)
do_internet_led_rename
;;
netgear,dgn3500|\
netgear,dgn3500b)
migrate_leds "dgn3500:blue:wireless=dgn3500:green:wireless"
;;
*)
;;
esac
[ "$LED_OPTIONS_CHANGED" = "1" ] && uci commit system
migrations_apply system
exit 0
#!/bin/sh
. /lib/functions.sh
. /lib/functions/lantiq.sh
IFNAME_CHANGED=0
......
#!/bin/sh
. /lib/functions/lantiq.sh
set_preinit_iface() {
ifname=eth0
}
boot_hook_add preinit_main set_preinit_iface
#!/bin/sh
FW_FILE="/lib/firmware/$FIRMWARE"
[ -e /lib/firmware/$FIRMWARE ] && exit 0
ath9k_eeprom_die() {
echo "ath9k eeprom: " "$*" >&2
exit 1
}
ath9k_eeprom_extract() {
local part=$1
local offset=$2
local count=$3
local mtd
mtd=$(find_mtd_chardev $part)
[ -n "$mtd" ] || \
ath9k_eeprom_die "no mtd device found for partition $part"
dd if=$mtd bs=$offset skip=1 count=1 2>/dev/null | dd of=$FW_FILE bs=$count count=1 2>/dev/null || \
ath9k_eeprom_die "failed to extract from $mtd"
}
tpl_set_wireless_mac()
{
local offset=$1
local mac
mac=$(mtd_get_mac_binary u-boot 326656)
mac=$(macaddr_add $mac $offset)
macaddr_2bin $mac | dd bs=1 count=6 seek=2 conv=notrunc of=$FW_FILE 2>/dev/null
}
[ -e $FW_FILE ] && exit 0
. /lib/functions.sh
. /lib/functions/system.sh
. /lib/functions/caldata.sh
board=$(board_name)
......@@ -43,11 +10,11 @@ case "$FIRMWARE" in
"pci_wmac0.eeprom")
case $board in
tplink,tl-wdr4900-v1)
ath9k_eeprom_extract "caldata" 4096 2048
tpl_set_wireless_mac 0
caldata_extract "caldata" 0x1000 0x800
ath9k_patch_mac $(mtd_get_mac_binary u-boot 0x4fc00)
;;
*)
ath9k_eeprom_die "board $board is not supported yet"
caldata_die "board $board is not supported yet"
;;
esac
;;
......@@ -55,11 +22,11 @@ case "$FIRMWARE" in
"pci_wmac1.eeprom")
case $board in
tplink,tl-wdr4900-v1)
ath9k_eeprom_extract "caldata" 20480 2048
tpl_set_wireless_mac -1
caldata_extract "caldata" 0x5000 0x800
ath9k_patch_mac $(macaddr_add $(mtd_get_mac_binary u-boot 0x4fc00) -1)
;;
*)
ath9k_eeprom_die "board $board is not supported yet"
caldata_die "board $board is not supported yet"
;;
esac
;;
......
......@@ -3,27 +3,54 @@
# Copyright (C) 2013 OpenWrt.org
#
. /lib/functions.sh
ramips_switchdev_from_soc() {
# The ethernet switch driver enables VLAN by default, but
# failsafe uses eth0, making the device unreachable:
# https://dev.openwrt.org/ticket/18768
local switchdev
local RT3X5X=$(grep -E "(RT3.5|RT5350|MT7628|MT7688|MT7620|MT7621)" /proc/cpuinfo)
[ -n "$RT3X5X" ] || return 1
case "$RT3X5X" in
*MT7620*)
switchdev=mt7620
;;
*MT7621*)
switchdev=mt7530
;;
*)
switchdev=rt305x
;;
esac
echo "$switchdev"
}
ramips_switchdev_from_board() {
# For these devices, external ethernet switch should be used
# instead of the SoC internal switch.
local switchdev
local board=$(board_name)
case "$board" in
esac
echo "$switchdev"
}
ramips_set_preinit_iface() {
RT3X5X=$(grep -E "(RT3.5|RT5350|MT7628|MT7688|MT7620|MT7621)" /proc/cpuinfo)
if [ -n "${RT3X5X}" ]; then
# The ethernet switch driver enables VLAN by default, but
# failsafe uses eth0, making the device unreachable:
# https://dev.openwrt.org/ticket/18768
case "${RT3X5X}" in
*MT7620*)
ralink_switchdev=mt7620
;;
*MT7621*)
ralink_switchdev=mt7530
;;
*)
ralink_switchdev=rt305x
;;
esac
swconfig dev $ralink_switchdev set reset 1
swconfig dev $ralink_switchdev set enable_vlan 0
swconfig dev $ralink_switchdev set apply 1
local switchdev=$(ramips_switchdev_from_board)
[ -n "$switchdev" ] || switchdev=$(ramips_switchdev_from_soc)
if [ -n "$switchdev" ]; then
swconfig dev $switchdev set reset 1
swconfig dev $switchdev set enable_vlan 0
swconfig dev $switchdev set apply 1
fi
ifname=eth0
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册