From patchwork Sun Feb 5 18:13:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [v2,03/15] build_patches: update / remove patches From: Tim Niemeyer X-Patchwork-Id: 295 Message-Id: <1486318428-7226-4-git-send-email-tim@tn-x.org> To: franken-dev@freifunk.net Cc: Tim Niemeyer Date: Sun, 5 Feb 2017 19:13:35 +0100 Signed-off-by: Tim Niemeyer --- Changes in v2: None .../openwrt/0001-sysupgrade_no_config_save.patch | 2 +- .../0003-ar71xx-add-support-for-GL-AR150.patch | 293 ------- ...string.patch => 0003-ntpd-host-as-string.patch} | 8 +- .../openwrt/0004-ar71xx-3.18-l2tp-stats.patch | 41 - ...-cpe510-enable-LNA-for-CPE210-220-510-520.patch | 40 - ...-a4fc62bc0ea4010ddbfbd738453c9db70988a57c.patch | 838 --------------------- build_patches/openwrt/0007-use-EU-code.patch | 31 - .../openwrt/0008-support-region-code-on-cpe.patch | 24 - 8 files changed, 5 insertions(+), 1272 deletions(-) delete mode 100644 build_patches/openwrt/0003-ar71xx-add-support-for-GL-AR150.patch rename build_patches/openwrt/{0009-ntpd-host-as-string.patch => 0003-ntpd-host-as-string.patch} (58%) delete mode 100644 build_patches/openwrt/0004-ar71xx-3.18-l2tp-stats.patch delete mode 100644 build_patches/openwrt/0005-ar71xx-cpe510-enable-LNA-for-CPE210-220-510-520.patch delete mode 100644 build_patches/openwrt/0006-mktplinkfw-lede-a4fc62bc0ea4010ddbfbd738453c9db70988a57c.patch delete mode 100644 build_patches/openwrt/0007-use-EU-code.patch delete mode 100644 build_patches/openwrt/0008-support-region-code-on-cpe.patch diff --git a/build_patches/openwrt/0001-sysupgrade_no_config_save.patch b/build_patches/openwrt/0001-sysupgrade_no_config_save.patch index 55b3d74..8c6566f 100644 --- a/build_patches/openwrt/0001-sysupgrade_no_config_save.patch +++ b/build_patches/openwrt/0001-sysupgrade_no_config_save.patch @@ -2,7 +2,7 @@ Index: package/base-files/files/sbin/sysupgrade =================================================================== --- package/base-files/files/sbin/sysupgrade +++ package/base-files/files/sbin/sysupgrade -@@ -101,7 +101,7 @@ +@@ -104,7 +104,7 @@ add_uci_conffiles() { local file="$1" ( find $(sed -ne '/^[[:space:]]*$/d; /^#/d; p' \ diff --git a/build_patches/openwrt/0003-ar71xx-add-support-for-GL-AR150.patch b/build_patches/openwrt/0003-ar71xx-add-support-for-GL-AR150.patch deleted file mode 100644 index deb6318..0000000 --- a/build_patches/openwrt/0003-ar71xx-add-support-for-GL-AR150.patch +++ /dev/null @@ -1,293 +0,0 @@ ---- target/linux/ar71xx/base-files/etc/uci-defaults/01_leds -+++ target/linux/ar71xx/base-files/etc/uci-defaults/01_leds -@@ -188,6 +188,10 @@ dlan-pro-1200-ac) - ucidef_set_led_trigger_gpio "plcr" "dLAN" "devolo:error:dlan" "16" "0" - ;; - -+gl-ar150) -+ ucidef_set_led_wlan "wlan" "WLAN" "gl_ar150:wlan" "phy0tpt" -+ ;; -+ - gl-inet) - ucidef_set_led_netdev "lan" "LAN" "gl-connect:green:lan" "eth1" - ucidef_set_led_wlan "wlan" "WLAN" "gl-connect:red:wlan" "phy0tpt" ---- target/linux/ar71xx/base-files/etc/uci-defaults/02_network -+++ target/linux/ar71xx/base-files/etc/uci-defaults/02_network -@@ -382,6 +382,7 @@ dir-505-a1) - alfa-ap96 |\ - alfa-nx |\ - ap83 |\ -+gl-ar150 |\ - gl-inet |\ - jwap003 |\ - pb42 |\ ---- target/linux/ar71xx/base-files/lib/ar71xx.sh -+++ target/linux/ar71xx/base-files/lib/ar71xx.sh -@@ -461,6 +461,9 @@ ar71xx_board_detect() { - name="gl-inet" - gl_inet_board_detect - ;; -+ *"GL AR150") -+ name="gl-ar150" -+ ;; - *"EnGenius EPG5000") - name="epg5000" - ;; ---- target/linux/ar71xx/base-files/lib/upgrade/platform.sh -+++ target/linux/ar71xx/base-files/lib/upgrade/platform.sh -@@ -217,6 +217,7 @@ platform_check_image() { - esr900 | \ - ew-dorin | \ - ew-dorin-router | \ -+ gl-ar150 | \ - hiwifi-hc6361 | \ - hornet-ub-x2 | \ - mzk-w04nu | \ ---- target/linux/ar71xx/config-3.18 -+++ target/linux/ar71xx/config-3.18 -@@ -70,6 +70,7 @@ CONFIG_ATH79_MACH_ESR1750=y - CONFIG_ATH79_MACH_ESR900=y - CONFIG_ATH79_MACH_EW_DORIN=y - CONFIG_ATH79_MACH_F9K1115V2=y -+CONFIG_ATH79_MACH_GL_AR150=y - CONFIG_ATH79_MACH_GL_INET=y - CONFIG_ATH79_MACH_GS_MINIBOX_V1=y - CONFIG_ATH79_MACH_GS_OOLITE=y ---- /dev/null -+++ target/linux/ar71xx/files/arch/mips/ath79/mach-gl-ar150.c -@@ -0,0 +1,125 @@ -+/* -+ * GL_ar150 board support -+ * -+ * Copyright (C) 2011 dongyuqi <729650915@qq.com> -+ * Copyright (C) 2011-2012 Gabor Juhos -+ * Copyright (C) 2013 alzhao -+ * Copyright (C) 2014 Michel Stempin -+ * -+ * This program is free software; you can redistribute it and/or modify it -+ * under the terms of the GNU General Public License version 2 as published -+ * by the Free Software Foundation. -+*/ -+ -+#include -+ -+#include -+ -+#include "dev-eth.h" -+#include "dev-gpio-buttons.h" -+#include "dev-leds-gpio.h" -+#include "dev-m25p80.h" -+#include "dev-usb.h" -+#include "dev-wmac.h" -+#include "machtypes.h" -+ -+#define GL_AR150_GPIO_LED_WLAN 0 -+#define GL_AR150_GPIO_LED_LAN 13 -+#define GL_AR150_GPIO_LED_WAN 15 -+ -+#define GL_AR150_GPIO_BIN_USB 6 -+#define GL_AR150_GPIO_BTN_MANUAL 7 -+#define GL_AR150_GPIO_BTN_AUTO 8 -+#define GL_AR150_GPIO_BTN_RESET 11 -+ -+#define GL_AR150_KEYS_POLL_INTERVAL 20 /* msecs */ -+#define GL_AR150_KEYS_DEBOUNCE_INTERVAL (3 * GL_AR150_KEYS_POLL_INTERVAL) -+ -+#define GL_AR150_MAC0_OFFSET 0x0000 -+#define GL_AR150_MAC1_OFFSET 0x0000 -+#define GL_AR150_CALDATA_OFFSET 0x1000 -+#define GL_AR150_WMAC_MAC_OFFSET 0x0000 -+ -+static struct gpio_led gl_ar150_leds_gpio[] __initdata = { -+ { -+ .name = "gl_ar150:wlan", -+ .gpio = GL_AR150_GPIO_LED_WLAN, -+ .active_low = 0, -+ }, -+ { -+ .name = "gl_ar150:lan", -+ .gpio = GL_AR150_GPIO_LED_LAN, -+ .active_low = 0, -+ }, -+ { -+ .name = "gl_ar150:wan", -+ .gpio = GL_AR150_GPIO_LED_WAN, -+ .active_low = 0, -+ .default_state = 1, -+ }, -+}; -+ -+static struct gpio_keys_button gl_ar150_gpio_keys[] __initdata = { -+ { -+ .desc = "BTN_7", -+ .type = EV_KEY, -+ .code = BTN_7, -+ .debounce_interval = GL_AR150_KEYS_DEBOUNCE_INTERVAL, -+ .gpio = GL_AR150_GPIO_BTN_MANUAL, -+ .active_low = 0, -+ }, -+ { -+ .desc = "BTN_8", -+ .type = EV_KEY, -+ .code = BTN_8, -+ .debounce_interval = GL_AR150_KEYS_DEBOUNCE_INTERVAL, -+ .gpio = GL_AR150_GPIO_BTN_AUTO, -+ .active_low = 0, -+ }, -+ { -+ .desc = "reset", -+ .type = EV_KEY, -+ .code = KEY_RESTART, -+ .debounce_interval = GL_AR150_KEYS_DEBOUNCE_INTERVAL, -+ .gpio = GL_AR150_GPIO_BTN_RESET, -+ .active_low = 0, -+ }, -+}; -+ -+static void __init gl_ar150_setup(void) -+{ -+ -+ /* ART base address */ -+ u8 *art = (u8 *) KSEG1ADDR(0x1fff0000); -+ -+ /* disable PHY_SWAP and PHY_ADDR_SWAP bits */ -+ ath79_setup_ar933x_phy4_switch(false, false); -+ -+ /* register flash. */ -+ ath79_register_m25p80(NULL); -+ -+ /* register gpio LEDs and keys */ -+ ath79_register_leds_gpio(-1, ARRAY_SIZE(gl_ar150_leds_gpio), -+ gl_ar150_leds_gpio); -+ ath79_register_gpio_keys_polled(-1, GL_AR150_KEYS_POLL_INTERVAL, -+ ARRAY_SIZE(gl_ar150_gpio_keys), -+ gl_ar150_gpio_keys); -+ -+ /* enable usb */ -+ gpio_request_one(GL_AR150_GPIO_BIN_USB, -+ GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED, -+ "USB power"); -+ ath79_register_usb(); -+ -+ /* register eth0 as WAN, eth1 as LAN */ -+ ath79_init_mac(ath79_eth0_data.mac_addr, art+GL_AR150_MAC0_OFFSET, 0); -+ ath79_init_mac(ath79_eth1_data.mac_addr, art+GL_AR150_MAC1_OFFSET, 0); -+ ath79_register_mdio(0, 0x0); -+ ath79_register_eth(0); -+ ath79_register_eth(1); -+ -+ /* register wireless mac with cal data */ -+ ath79_register_wmac(art + GL_AR150_CALDATA_OFFSET, art + GL_AR150_WMAC_MAC_OFFSET); -+} -+ -+MIPS_MACHINE(ATH79_MACH_GL_AR150, "GL-AR150", "GL AR150",gl_ar150_setup); ---- target/linux/ar71xx/generic/profiles/gl-connect.mk -+++ /dev/null -@@ -1,17 +0,0 @@ --# --# Copyright (C) 2014 OpenWrt.org --# --# This is free software, licensed under the GNU General Public License v2. --# See /LICENSE for more information. --# -- --define Profile/GLINET -- NAME:=GL.iNet -- PACKAGES:=kmod-usb-core kmod-usb2 --endef -- --define Profile/GLINET/Description -- Package set optimized for the GL-Connect GL.iNet v1. --endef -- --$(eval $(call Profile,GLINET)) ---- /dev/null -+++ target/linux/ar71xx/generic/profiles/gli.mk -@@ -0,0 +1,27 @@ -+# -+# Copyright (C) 2013 OpenWrt.org -+# -+# This is free software, licensed under the GNU General Public License v2. -+# See /LICENSE for more information. -+# -+define Profile/GLINET -+ NAME:=GL.iNet 6416 -+ PACKAGES:=kmod-usb-core kmod-usb2 -+endef -+ -+define Profile/GLINET/Description -+ Package set optimized for the GL-Connect GL.iNet v1. -+endef -+ -+$(eval $(call Profile,GLINET)) -+ -+define Profile/GL-AR150 -+ NAME:=GL AR150 -+ PACKAGES:=kmod-usb-core kmod-usb2 -+endef -+ -+define Profile/GL-AR150/Description -+ Configuration of GL AR150. -+endef -+ -+$(eval $(call Profile,GL-AR150)) ---- target/linux/ar71xx/image/Makefile -+++ target/linux/ar71xx/image/Makefile -@@ -144,6 +144,14 @@ define Device/weio - endef - TARGET_DEVICES += weio - -+define Device/gl-ar150 -+ BOARDNAME = GL-AR150 -+ IMAGE_SIZE = 16000k -+ CONSOLE = ttyATH0,115200 -+ MTDPARTS = spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,16000k(firmware),64k(art)ro -+endef -+TARGET_DEVICES += gl-ar150 -+ - define Device/wndr3700 - BOARDNAME = WNDR3700 - NETGEAR_KERNEL_MAGIC = 0x33373030 ---- /dev/null -+++ target/linux/ar71xx/patches-3.18/911-MIPS-ath79-add-gl_ar150.patch -@@ -0,0 +1,39 @@ -+--- a/arch/mips/ath79/Kconfig -++++ b/arch/mips/ath79/Kconfig -+@@ -577,6 +577,16 @@ config ATH79_MACH_EL_MINI -+ select ATH79_DEV_USB -+ select ATH79_DEV_WMAC -+ -++config ATH79_MACH_GL_AR150 -++ bool "GL AR150 support" -++ select SOC_AR933X -++ select ATH79_DEV_ETH -++ select ATH79_DEV_GPIO_BUTTONS -++ select ATH79_DEV_LEDS_GPIO -++ select ATH79_DEV_M25P80 -++ select ATH79_DEV_USB -++ select ATH79_DEV_WMAC -++ -+ config ATH79_MACH_GL_INET -+ bool "GL-INET support" -+ select SOC_AR933X -+--- a/arch/mips/ath79/Makefile -++++ b/arch/mips/ath79/Makefile -+@@ -83,6 +83,7 @@ obj-$(CONFIG_ATH79_MACH_EL_MINI) += mach -+ obj-$(CONFIG_ATH79_MACH_EPG5000) += mach-epg5000.o -+ obj-$(CONFIG_ATH79_MACH_ESR1750) += mach-esr1750.o -+ obj-$(CONFIG_ATH79_MACH_F9K1115V2) += mach-f9k1115v2.o -++obj-$(CONFIG_ATH79_MACH_GL_AR150) += mach-gl-ar150.o -+ obj-$(CONFIG_ATH79_MACH_GL_INET) += mach-gl-inet.o -+ obj-$(CONFIG_ATH79_MACH_GS_MINIBOX_V1) += mach-gs-minibox-v1.o -+ obj-$(CONFIG_ATH79_MACH_GS_OOLITE) += mach-gs-oolite.o -+--- a/arch/mips/ath79/machtypes.h -++++ b/arch/mips/ath79/machtypes.h -+@@ -72,6 +72,7 @@ enum ath79_mach_type { -+ ATH79_MACH_ESR1750, /* EnGenius ESR1750 */ -+ ATH79_MACH_EPG5000, /* EnGenius EPG5000 */ -+ ATH79_MACH_F9K1115V2, /* Belkin AC1750DB */ -++ ATH79_MACH_GL_AR150, /* GL-AR150 support */ -+ ATH79_MACH_GL_INET, /* GL-CONNECT GL-INET */ -+ ATH79_MACH_GS_MINIBOX_V1, /* Gainstrong MiniBox V1.0 */ -+ ATH79_MACH_GS_OOLITE, /* GS OOLITE V1.0 */ - diff --git a/build_patches/openwrt/0009-ntpd-host-as-string.patch b/build_patches/openwrt/0003-ntpd-host-as-string.patch similarity index 58% rename from build_patches/openwrt/0009-ntpd-host-as-string.patch rename to build_patches/openwrt/0003-ntpd-host-as-string.patch index 94c2ce2..fe5ae4d 100644 --- a/build_patches/openwrt/0009-ntpd-host-as-string.patch +++ b/build_patches/openwrt/0003-ntpd-host-as-string.patch @@ -1,13 +1,13 @@ diff --git package/utils/busybox/files/sysntpd package/utils/busybox/files/sysntpd -index f73bb83..61cb54c 100755 +index 98260be..07b738c 100755 --- package/utils/busybox/files/sysntpd +++ package/utils/busybox/files/sysntpd -@@ -9,7 +9,7 @@ HOTPLUG_SCRIPT=/usr/sbin/ntpd-hotplug +@@ -30,7 +30,7 @@ get_dhcp_ntp_servers() { validate_ntp_section() { uci_validate_section system timeserver "${1}" \ -- 'server:list(host)' 'enabled:bool:1' 'enable_server:bool:0' -+ 'server:list(string)' 'enabled:bool:1' 'enable_server:bool:0' +- 'server:list(host)' 'enabled:bool:1' 'enable_server:bool:0' 'use_dhcp:bool:1' 'dhcp_interface:list(string)' ++ 'server:list(string)' 'enabled:bool:1' 'enable_server:bool:0' 'use_dhcp:bool:1' 'dhcp_interface:list(string)' } start_service() { diff --git a/build_patches/openwrt/0004-ar71xx-3.18-l2tp-stats.patch b/build_patches/openwrt/0004-ar71xx-3.18-l2tp-stats.patch deleted file mode 100644 index 85a40c1..0000000 --- a/build_patches/openwrt/0004-ar71xx-3.18-l2tp-stats.patch +++ /dev/null @@ -1,41 +0,0 @@ ---- target/linux/ar71xx/patches-3.18/fix-l2tp-stats-couter-on-32-Bit-Systems.patch 1970-01-01 01:00:00.000000000 +0100 -+++ target/linux/ar71xx/patches-3.18/fix-l2tp-stats-couter-on-32-Bit-Systems.patch 2016-03-12 18:41:32.818602442 +0100 -@@ -0,0 +1,38 @@ -+From 19b1c8733b99f13005f2d8918bce588f0b2556f8 Mon Sep 17 00:00:00 2001 -+From: Dominik Heidler -+Date: Sat, 12 Mar 2016 18:37:42 +0100 -+Subject: [PATCH] Fix l2tp stats couter on 32 Bit Systems -+ -+--- -+ net/l2tp/l2tp_eth.c | 9 +++++++++ -+ 1 file changed, 9 insertions(+) -+ -+diff --git a/net/l2tp/l2tp_eth.c b/net/l2tp/l2tp_eth.c -+index e253c26..a18c2ff 100644 -+--- a/net/l2tp/l2tp_eth.c -++++ b/net/l2tp/l2tp_eth.c -+@@ -111,12 +111,21 @@ static struct rtnl_link_stats64 *l2tp_eth_get_stats64(struct net_device *dev, -+ { -+ struct l2tp_eth *priv = netdev_priv(dev); -+ -++ #if BITS_PER_LONG == 64 -+ stats->tx_bytes = atomic_long_read(&priv->tx_bytes); -+ stats->tx_packets = atomic_long_read(&priv->tx_packets); -+ stats->tx_dropped = atomic_long_read(&priv->tx_dropped); -+ stats->rx_bytes = atomic_long_read(&priv->rx_bytes); -+ stats->rx_packets = atomic_long_read(&priv->rx_packets); -+ stats->rx_errors = atomic_long_read(&priv->rx_errors); -++ #else -++ stats->tx_bytes = (unsigned long) atomic_long_read(&priv->tx_bytes); -++ stats->tx_packets = (unsigned long) atomic_long_read(&priv->tx_packets); -++ stats->tx_dropped = (unsigned long) atomic_long_read(&priv->tx_dropped); -++ stats->rx_bytes = (unsigned long) atomic_long_read(&priv->rx_bytes); -++ stats->rx_packets = (unsigned long) atomic_long_read(&priv->rx_packets); -++ stats->rx_errors = (unsigned long) atomic_long_read(&priv->rx_errors); -++ #endif -+ return stats; -+ } -+ -+-- -+2.7.2 -+ diff --git a/build_patches/openwrt/0005-ar71xx-cpe510-enable-LNA-for-CPE210-220-510-520.patch b/build_patches/openwrt/0005-ar71xx-cpe510-enable-LNA-for-CPE210-220-510-520.patch deleted file mode 100644 index 5f32936..0000000 --- a/build_patches/openwrt/0005-ar71xx-cpe510-enable-LNA-for-CPE210-220-510-520.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 94e23bf7409d6cc4c9efb55ed32aba8e5a497966 Mon Sep 17 00:00:00 2001 -From: Alexander Couzens -Date: Fri, 20 May 2016 13:10:36 +0200 -Subject: [PATCH] ar71xx/cpe510: enable LNA for CPE210/220/510/520 - -The LNA improves the rx path. Within a simple test setup -it improved the signal from -60dbm to -40dbm. - -Signed-off-by: Alexander Couzens ---- - target/linux/ar71xx/files/arch/mips/ath79/mach-cpe510.c | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git target/linux/ar71xx/files/arch/mips/ath79/mach-cpe510.c target/linux/ar71xx/files/arch/mips/ath79/mach-cpe510.c -index 8bf5c0f..5cb052a 100644 ---- target/linux/ar71xx/files/arch/mips/ath79/mach-cpe510.c -+++ target/linux/ar71xx/files/arch/mips/ath79/mach-cpe510.c -@@ -30,6 +30,9 @@ - #define CPE510_GPIO_LED_L3 15 - #define CPE510_GPIO_LED_L4 16 - -+#define CPE510_GPIO_EXTERNAL_LNA0 18 -+#define CPE510_GPIO_EXTERNAL_LNA1 19 -+ - #define CPE510_GPIO_BTN_RESET 4 - - #define CPE510_KEYS_POLL_INTERVAL 20 /* msecs */ -@@ -93,6 +96,9 @@ static void __init cpe510_setup(void) - ARRAY_SIZE(cpe510_gpio_keys), - cpe510_gpio_keys); - -+ ath79_wmac_set_ext_lna_gpio(0, CPE510_GPIO_EXTERNAL_LNA0); -+ ath79_wmac_set_ext_lna_gpio(1, CPE510_GPIO_EXTERNAL_LNA1); -+ - ath79_register_m25p80(NULL); - - ath79_register_mdio(1, 0); --- -2.10.1 - diff --git a/build_patches/openwrt/0006-mktplinkfw-lede-a4fc62bc0ea4010ddbfbd738453c9db70988a57c.patch b/build_patches/openwrt/0006-mktplinkfw-lede-a4fc62bc0ea4010ddbfbd738453c9db70988a57c.patch deleted file mode 100644 index 5643fd0..0000000 --- a/build_patches/openwrt/0006-mktplinkfw-lede-a4fc62bc0ea4010ddbfbd738453c9db70988a57c.patch +++ /dev/null @@ -1,838 +0,0 @@ -diff --git tools/firmware-utils/src/mktplinkfw.c tools/firmware-utils/src/mktplinkfw.c -index 6df869d..34e6546 100644 ---- tools/firmware-utils/src/mktplinkfw.c -+++ tools/firmware-utils/src/mktplinkfw.c -@@ -28,52 +28,10 @@ - #include "md5.h" - - #define ALIGN(x,a) ({ typeof(a) __a = (a); (((x) + __a - 1) & ~(__a - 1)); }) -+#define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0])) - - #define HEADER_VERSION_V1 0x01000000 --#define HWID_ANTMINER_S1 0x04440101 --#define HWID_ANTMINER_S3 0x04440301 --#define HWID_GL_INET_V1 0x08000001 --#define HWID_GS_OOLITE_V1 0x3C000101 --#define HWID_ONION_OMEGA 0x04700001 --#define HWID_TL_MR10U_V1 0x00100101 --#define HWID_TL_MR13U_V1 0x00130101 --#define HWID_TL_MR3020_V1 0x30200001 --#define HWID_TL_MR3220_V1 0x32200001 --#define HWID_TL_MR3220_V2 0x32200002 --#define HWID_TL_MR3420_V1 0x34200001 --#define HWID_TL_MR3420_V2 0x34200002 --#define HWID_TL_WA701N_V1 0x07010001 --#define HWID_TL_WA701N_V2 0x07010002 --#define HWID_TL_WA7210N_V2 0x72100002 --#define HWID_TL_WA7510N_V1 0x75100001 --#define HWID_TL_WA801ND_V1 0x08010001 --#define HWID_TL_WA830RE_V1 0x08300010 --#define HWID_TL_WA830RE_V2 0x08300002 --#define HWID_TL_WA801ND_V2 0x08010002 --#define HWID_TL_WA901ND_V1 0x09010001 --#define HWID_TL_WA901ND_V2 0x09010002 --#define HWID_TL_WA901ND_V4 0x09010004 --#define HWID_TL_WDR4300_V1_IL 0x43008001 --#define HWID_TL_WDR4900_V1 0x49000001 --#define HWID_TL_WR703N_V1 0x07030101 --#define HWID_TL_WR720N_V3 0x07200103 --#define HWID_TL_WR720N_V4 0x07200104 --#define HWID_TL_WR741ND_V1 0x07410001 --#define HWID_TL_WR741ND_V4 0x07410004 --#define HWID_TL_WR740N_V1 0x07400001 --#define HWID_TL_WR740N_V3 0x07400003 --#define HWID_TL_WR743ND_V1 0x07430001 --#define HWID_TL_WR743ND_V2 0x07430002 --#define HWID_TL_WR841N_V1_5 0x08410002 --#define HWID_TL_WR841ND_V3 0x08410003 --#define HWID_TL_WR841ND_V5 0x08410005 --#define HWID_TL_WR841ND_V7 0x08410007 --#define HWID_TL_WR941ND_V2 0x09410002 --#define HWID_TL_WR941ND_V4 0x09410004 --#define HWID_TL_WR1043ND_V1 0x10430001 --#define HWID_TL_WR1043ND_V2 0x10430002 --#define HWID_TL_WR1041N_V2 0x10410002 --#define HWID_TL_WR2543N_V1 0x25430001 -+#define HEADER_VERSION_V2 0x02000000 - - #define MD5SUM_LEN 16 - -@@ -88,7 +46,7 @@ struct fw_header { - char fw_version[36]; - uint32_t hw_id; /* hardware id */ - uint32_t hw_rev; /* hardware revision */ -- uint32_t unk1; -+ uint32_t region_code; /* region code */ - uint8_t md5sum1[MD5SUM_LEN]; - uint32_t unk2; - uint8_t md5sum2[MD5SUM_LEN]; -@@ -105,7 +63,10 @@ struct fw_header { - uint16_t ver_hi; - uint16_t ver_mid; - uint16_t ver_lo; -- uint8_t pad[354]; -+ uint8_t pad[130]; -+ char region_str1[32]; -+ char region_str2[32]; -+ uint8_t pad2[160]; - } __attribute__ ((packed)); - - struct flash_layout { -@@ -116,13 +77,12 @@ struct flash_layout { - uint32_t rootfs_ofs; - }; - --struct board_info { -- char *id; -- uint32_t hw_id; -- uint32_t hw_rev; -- char *layout_id; -+struct fw_region { -+ char name[4]; -+ uint32_t code; - }; - -+ - /* - * Globals - */ -@@ -131,15 +91,17 @@ static char *progname; - static char *vendor = "TP-LINK Technologies"; - static char *version = "ver. 1.0"; - static char *fw_ver = "0.0.0"; -+static uint32_t hdr_ver = HEADER_VERSION_V1; - --static char *board_id; --static struct board_info *board; - static char *layout_id; - static struct flash_layout *layout; - static char *opt_hw_id; - static uint32_t hw_id; - static char *opt_hw_rev; - static uint32_t hw_rev; -+static uint32_t opt_hdr_ver = 1; -+static char *country; -+static const struct fw_region *region; - static int fw_ver_lo; - static int fw_ver_mid; - static int fw_ver_hi; -@@ -162,12 +124,12 @@ static uint32_t reserved_space; - static struct file_info inspect_info; - static int extract = 0; - --char md5salt_normal[MD5SUM_LEN] = { -+static const char md5salt_normal[MD5SUM_LEN] = { - 0xdc, 0xd7, 0x3a, 0xa5, 0xc3, 0x95, 0x98, 0xfb, - 0xdd, 0xf9, 0xe7, 0xf4, 0x0e, 0xae, 0x47, 0x38, - }; - --char md5salt_boot[MD5SUM_LEN] = { -+static const char md5salt_boot[MD5SUM_LEN] = { - 0x8c, 0xef, 0x33, 0x5b, 0xd5, 0xc5, 0xce, 0xfa, - 0xa7, 0x9c, 0x28, 0xda, 0xb2, 0xe9, 0x0f, 0x42, - }; -@@ -212,7 +174,7 @@ static struct flash_layout layouts[] = { - }, { - .id = "16Mppc", - .fw_max_len = 0xf80000, -- .kernel_la = 0x00000000, -+ .kernel_la = 0x00000000 , - .kernel_ep = 0xc0000000, - .rootfs_ofs = 0x2a0000, - }, { -@@ -220,230 +182,10 @@ static struct flash_layout layouts[] = { - } - }; - --static struct board_info boards[] = { -- { -- .id = "TL-MR10Uv1", -- .hw_id = HWID_TL_MR10U_V1, -- .hw_rev = 1, -- .layout_id = "4Mlzma", -- }, { -- .id = "TL-MR13Uv1", -- .hw_id = HWID_TL_MR13U_V1, -- .hw_rev = 1, -- .layout_id = "4Mlzma", -- }, { -- .id = "TL-MR3020v1", -- .hw_id = HWID_TL_MR3020_V1, -- .hw_rev = 1, -- .layout_id = "4Mlzma", -- }, { -- .id = "TL-MR3220v1", -- .hw_id = HWID_TL_MR3220_V1, -- .hw_rev = 1, -- .layout_id = "4M", -- }, { -- .id = "TL-MR3220v2", -- .hw_id = HWID_TL_MR3220_V2, -- .hw_rev = 1, -- .layout_id = "4Mlzma", -- }, { -- .id = "TL-MR3420v1", -- .hw_id = HWID_TL_MR3420_V1, -- .hw_rev = 1, -- .layout_id = "4M", -- }, { -- .id = "TL-MR3420v2", -- .hw_id = HWID_TL_MR3420_V2, -- .hw_rev = 1, -- .layout_id = "4Mlzma", -- }, { -- .id = "TL-WA701Nv1", -- .hw_id = HWID_TL_WA701N_V1, -- .hw_rev = 1, -- .layout_id = "4M", -- }, { -- .id = "TL-WA701Nv2", -- .hw_id = HWID_TL_WA701N_V2, -- .hw_rev = 1, -- .layout_id = "4Mlzma", -- }, { -- .id = "TL-WA7210N", -- .hw_id = HWID_TL_WA7210N_V2, -- .hw_rev = 2, -- .layout_id = "4Mlzma", -- }, { -- .id = "TL-WA7510N", -- .hw_id = HWID_TL_WA7510N_V1, -- .hw_rev = 1, -- .layout_id = "4M", -- }, { -- .id = "TL-WA801NDv1", -- .hw_id = HWID_TL_WA801ND_V1, -- .hw_rev = 1, -- .layout_id = "4M", -- }, { -- .id = "TL-WA830REv1", -- .hw_id = HWID_TL_WA830RE_V1, -- .hw_rev = 1, -- .layout_id = "4M", -- }, { -- .id = "TL-WA830REv2", -- .hw_id = HWID_TL_WA830RE_V2, -- .hw_rev = 1, -- .layout_id = "4M", -- }, { -- .id = "TL-WA801NDv2", -- .hw_id = HWID_TL_WA801ND_V2, -- .hw_rev = 1, -- .layout_id = "4Mlzma", -- }, { -- .id = "TL-WA901NDv1", -- .hw_id = HWID_TL_WA901ND_V1, -- .hw_rev = 1, -- .layout_id = "4M", -- }, { -- .id = "TL-WA901NDv2", -- .hw_id = HWID_TL_WA901ND_V2, -- .hw_rev = 1, -- .layout_id = "4M", -- }, { -- .id = "TL-WA901NDv4", -- .hw_id = HWID_TL_WA901ND_V4, -- .hw_rev = 1, -- .layout_id = "4Mlzma", -- }, { -- .id = "TL-WDR4300v1", -- .hw_id = HWID_TL_WDR4300_V1_IL, -- .hw_rev = 1, -- .layout_id = "8Mlzma", -- }, { -- .id = "TL-WDR4900v1", -- .hw_id = HWID_TL_WDR4900_V1, -- .hw_rev = 1, -- .layout_id = "16Mppc", -- }, { -- .id = "TL-WR741NDv1", -- .hw_id = HWID_TL_WR741ND_V1, -- .hw_rev = 1, -- .layout_id = "4M", -- }, { -- .id = "TL-WR741NDv4", -- .hw_id = HWID_TL_WR741ND_V4, -- .hw_rev = 1, -- .layout_id = "4Mlzma", -- }, { -- .id = "TL-WR740Nv1", -- .hw_id = HWID_TL_WR740N_V1, -- .hw_rev = 1, -- .layout_id = "4M", -- }, { -- .id = "TL-WR740Nv3", -- .hw_id = HWID_TL_WR740N_V3, -- .hw_rev = 1, -- .layout_id = "4M", -- }, { -- .id = "TL-WR743NDv1", -- .hw_id = HWID_TL_WR743ND_V1, -- .hw_rev = 1, -- .layout_id = "4M", -- }, { -- .id = "TL-WR743NDv2", -- .hw_id = HWID_TL_WR743ND_V2, -- .hw_rev = 1, -- .layout_id = "4Mlzma", -- }, { -- .id = "TL-WR841Nv1.5", -- .hw_id = HWID_TL_WR841N_V1_5, -- .hw_rev = 2, -- .layout_id = "4M", -- }, { -- .id = "TL-WR841NDv3", -- .hw_id = HWID_TL_WR841ND_V3, -- .hw_rev = 3, -- .layout_id = "4M", -- }, { -- .id = "TL-WR841NDv5", -- .hw_id = HWID_TL_WR841ND_V5, -- .hw_rev = 1, -- .layout_id = "4M", -- }, { -- .id = "TL-WR841NDv7", -- .hw_id = HWID_TL_WR841ND_V7, -- .hw_rev = 1, -- .layout_id = "4M", -- }, { -- .id = "TL-WR941NDv2", -- .hw_id = HWID_TL_WR941ND_V2, -- .hw_rev = 2, -- .layout_id = "4M", -- }, { -- .id = "TL-WR941NDv4", -- .hw_id = HWID_TL_WR941ND_V4, -- .hw_rev = 1, -- .layout_id = "4M", -- }, { -- .id = "TL-WR1041Nv2", -- .hw_id = HWID_TL_WR1041N_V2, -- .hw_rev = 1, -- .layout_id = "4Mlzma", -- }, { -- .id = "TL-WR1043NDv1", -- .hw_id = HWID_TL_WR1043ND_V1, -- .hw_rev = 1, -- .layout_id = "8M", -- }, { -- .id = "TL-WR1043NDv2", -- .hw_id = HWID_TL_WR1043ND_V2, -- .hw_rev = 1, -- .layout_id = "8Mlzma", -- }, { -- .id = "TL-WR2543Nv1", -- .hw_id = HWID_TL_WR2543N_V1, -- .hw_rev = 1, -- .layout_id = "8Mlzma", -- }, { -- .id = "TL-WR703Nv1", -- .hw_id = HWID_TL_WR703N_V1, -- .hw_rev = 1, -- .layout_id = "4Mlzma", -- }, { -- .id = "TL-WR720Nv3", -- .hw_id = HWID_TL_WR720N_V3, -- .hw_rev = 1, -- .layout_id = "4Mlzma", -- }, { -- .id = "TL-WR720Nv4", -- .hw_id = HWID_TL_WR720N_V4, -- .hw_rev = 1, -- .layout_id = "4Mlzma", -- }, { -- .id = "GL-INETv1", -- .hw_id = HWID_GL_INET_V1, -- .hw_rev = 1, -- .layout_id = "8Mlzma", -- }, { -- .id = "GS-OOLITEv1", -- .hw_id = HWID_GS_OOLITE_V1, -- .hw_rev = 1, -- .layout_id = "16Mlzma", -- }, { -- .id = "ONION-OMEGA", -- .hw_id = HWID_ONION_OMEGA, -- .hw_rev = 1, -- .layout_id = "16Mlzma", -- }, { -- .id = "ANTMINER-S1", -- .hw_id = HWID_ANTMINER_S1, -- .hw_rev = 1, -- .layout_id = "8Mlzma", -- }, { -- .id = "ANTMINER-S3", -- .hw_id = HWID_ANTMINER_S3, -- .hw_rev = 1, -- .layout_id = "8Mlzma", -- }, { -- /* terminating entry */ -- } -+static const struct fw_region regions[] = { -+ /* Default region (universal) uses code 0 as well */ -+ {"US", 1}, -+ {"EU", 0}, - }; - - /* -@@ -458,7 +200,7 @@ static struct board_info boards[] = { - #define ERRS(fmt, ...) do { \ - int save = errno; \ - fflush(0); \ -- fprintf(stderr, "[%s] *** error: " fmt "\n", \ -+ fprintf(stderr, "[%s] *** error: " fmt ": %s\n", \ - progname, ## __VA_ARGS__, strerror(save)); \ - } while (0) - -@@ -466,35 +208,7 @@ static struct board_info boards[] = { - fprintf(stderr, "[%s] " fmt "\n", progname, ## __VA_ARGS__ ); \ - } while (0) - --static struct board_info *find_board(char *id) --{ -- struct board_info *ret; -- struct board_info *board; -- -- ret = NULL; -- for (board = boards; board->id != NULL; board++){ -- if (strcasecmp(id, board->id) == 0) { -- ret = board; -- break; -- } -- }; -- -- return ret; --} -- --static struct board_info *find_board_by_hwid(uint32_t hw_id) --{ -- struct board_info *board; -- -- for (board = boards; board->id != NULL; board++) { -- if (hw_id == board->hw_id) -- return board; -- }; -- -- return NULL; --} -- --static struct flash_layout *find_layout(char *id) -+static struct flash_layout *find_layout(const char *id) - { - struct flash_layout *ret; - struct flash_layout *l; -@@ -510,21 +224,29 @@ static struct flash_layout *find_layout(char *id) - return ret; - } - -+static const struct fw_region * find_region(const char *country) { -+ size_t i; -+ -+ for (i = 0; i < ARRAY_SIZE(regions); i++) { -+ if (strcasecmp(regions[i].name, country) == 0) -+ return ®ions[i]; -+ } -+ -+ return NULL; -+} -+ - static void usage(int status) - { -- FILE *stream = (status != EXIT_SUCCESS) ? stderr : stdout; -- struct board_info *board; -- -- fprintf(stream, "Usage: %s [OPTIONS...]\n", progname); -- fprintf(stream, -+ fprintf(stderr, "Usage: %s [OPTIONS...]\n", progname); -+ fprintf(stderr, - "\n" - "Options:\n" --" -B create image for the board specified with \n" - " -c use combined kernel image\n" - " -E overwrite kernel entry point with (hexval prefixed with 0x)\n" - " -L overwrite kernel load address with (hexval prefixed with 0x)\n" - " -H use hardware id specified with \n" - " -W use hardware revision specified with \n" -+" -C set region code to \n" - " -F use flash layout specified with \n" - " -k read kernel image from the file \n" - " -r read rootfs image from the file \n" -@@ -537,6 +259,7 @@ static void usage(int status) - " -N set image vendor to \n" - " -V set image version to \n" - " -v set firmware version to \n" -+" -m set header version to \n" - " -i inspect given firmware file \n" - " -x extract kernel and rootfs while inspecting (requires -i)\n" - " -X reserve bytes in the firmware image (hexval prefixed with 0x)\n" -@@ -546,7 +269,7 @@ static void usage(int status) - exit(status); - } - --static int get_md5(char *data, int size, char *md5) -+static void get_md5(const char *data, int size, uint8_t *md5) - { - MD5_CTX ctx; - -@@ -573,7 +296,7 @@ static int get_file_stat(struct file_info *fdata) - return 0; - } - --static int read_to_buf(struct file_info *fdata, char *buf) -+static int read_to_buf(const struct file_info *fdata, char *buf) - { - FILE *f; - int ret = EXIT_FAILURE; -@@ -602,6 +325,7 @@ static int read_to_buf(struct file_info *fdata, char *buf) - static int check_options(void) - { - int ret; -+ int exceed_bytes; - - if (inspect_info.file_name) { - ret = get_file_stat(&inspect_info); -@@ -614,33 +338,28 @@ static int check_options(void) - return -1; - } - -- if (board_id == NULL && opt_hw_id == NULL) { -- ERR("either board or hardware id must be specified"); -+ if (opt_hw_id == NULL) { -+ ERR("hardware id not specified"); - return -1; - } -+ hw_id = strtoul(opt_hw_id, NULL, 0); - -- if (board_id) { -- board = find_board(board_id); -- if (board == NULL) { -- ERR("unknown/unsupported board id \"%s\"", board_id); -- return -1; -- } -- if (layout_id == NULL) -- layout_id = board->layout_id; -+ if (layout_id == NULL) { -+ ERR("flash layout is not specified"); -+ return -1; -+ } - -- hw_id = board->hw_id; -- hw_rev = board->hw_rev; -- } else { -- if (layout_id == NULL) { -- ERR("flash layout is not specified"); -+ if (opt_hw_rev) -+ hw_rev = strtoul(opt_hw_rev, NULL, 0); -+ else -+ hw_rev = 1; -+ -+ if (country) { -+ region = find_region(country); -+ if (!region) { -+ ERR("unknown region code \"%s\"", country); - return -1; - } -- hw_id = strtoul(opt_hw_id, NULL, 0); -- -- if (opt_hw_rev) -- hw_rev = strtoul(opt_hw_rev, NULL, 0); -- else -- hw_rev = 1; - } - - layout = find_layout(layout_id); -@@ -675,10 +394,10 @@ static int check_options(void) - kernel_len = kernel_info.file_size; - - if (combined) { -- if (kernel_info.file_size > -- fw_max_len - sizeof(struct fw_header)) { -+ exceed_bytes = kernel_info.file_size - (fw_max_len - sizeof(struct fw_header)); -+ if (exceed_bytes > 0) { - if (!ignore_size) { -- ERR("kernel image is too big"); -+ ERR("kernel image is too big by %i bytes", exceed_bytes); - return -1; - } - layout->fw_max_len = sizeof(struct fw_header) + -@@ -702,21 +421,21 @@ static int check_options(void) - - DBG("kernel length aligned to %u", kernel_len); - -- if (kernel_len + rootfs_info.file_size > -- fw_max_len - sizeof(struct fw_header)) { -- ERR("images are too big"); -+ exceed_bytes = kernel_len + rootfs_info.file_size - (fw_max_len - sizeof(struct fw_header)); -+ if (exceed_bytes > 0) { -+ ERR("images are too big by %i bytes", exceed_bytes); - return -1; - } - } else { -- if (kernel_info.file_size > -- rootfs_ofs - sizeof(struct fw_header)) { -- ERR("kernel image is too big"); -+ exceed_bytes = kernel_info.file_size - (rootfs_ofs - sizeof(struct fw_header)); -+ if (exceed_bytes > 0) { -+ ERR("kernel image is too big by %i bytes", exceed_bytes); - return -1; - } - -- if (rootfs_info.file_size > -- (fw_max_len - rootfs_ofs)) { -- ERR("rootfs image is too big"); -+ exceed_bytes = rootfs_info.file_size - (fw_max_len - rootfs_ofs); -+ if (exceed_bytes > 0) { -+ ERR("rootfs image is too big by %i bytes", exceed_bytes); - return -1; - } - } -@@ -733,6 +452,15 @@ static int check_options(void) - return -1; - } - -+ if (opt_hdr_ver == 1) { -+ hdr_ver = HEADER_VERSION_V1; -+ } else if (opt_hdr_ver == 2) { -+ hdr_ver = HEADER_VERSION_V2; -+ } else { -+ ERR("invalid header version '%u'", opt_hdr_ver); -+ return -1; -+ } -+ - return 0; - } - -@@ -742,7 +470,7 @@ static void fill_header(char *buf, int len) - - memset(hdr, 0, sizeof(struct fw_header)); - -- hdr->version = htonl(HEADER_VERSION_V1); -+ hdr->version = htonl(hdr_ver); - strncpy(hdr->vendor_name, vendor, sizeof(hdr->vendor_name)); - strncpy(hdr->fw_version, version, sizeof(hdr->fw_version)); - hdr->hw_id = htonl(hw_id); -@@ -767,6 +495,18 @@ static void fill_header(char *buf, int len) - hdr->ver_mid = htons(fw_ver_mid); - hdr->ver_lo = htons(fw_ver_lo); - -+ if (region) { -+ hdr->region_code = htonl(region->code); -+ snprintf( -+ hdr->region_str1, sizeof(hdr->region_str1), "00000000;%02X%02X%02X%02X;", -+ region->name[0], region->name[1], region->name[2], region->name[3] -+ ); -+ snprintf( -+ hdr->region_str2, sizeof(hdr->region_str2), "%02X%02X%02X%02X", -+ region->name[0], region->name[1], region->name[2], region->name[3] -+ ); -+ } -+ - get_md5(buf, len, hdr->md5sum1); - } - -@@ -804,7 +544,7 @@ static int pad_jffs2(char *buf, int currlen) - return len; - } - --static int write_fw(char *data, int len) -+static int write_fw(const char *data, int len) - { - FILE *f; - int ret = EXIT_FAILURE; -@@ -896,61 +636,22 @@ static int build_fw(void) - } - - /* Helper functions to inspect_fw() representing different output formats */ --static inline void inspect_fw_pstr(char *label, char *str) -+static inline void inspect_fw_pstr(const char *label, const char *str) - { - printf("%-23s: %s\n", label, str); - } - --static inline void inspect_fw_phex(char *label, uint32_t val) -+static inline void inspect_fw_phex(const char *label, uint32_t val) - { - printf("%-23s: 0x%08x\n", label, val); - } - --static inline void inspect_fw_phexpost(char *label, -- uint32_t val, char *post) --{ -- printf("%-23s: 0x%08x (%s)\n", label, val, post); --} -- --static inline void inspect_fw_phexdef(char *label, -- uint32_t val, uint32_t defval) --{ -- printf("%-23s: 0x%08x ", label, val); -- -- if (val == defval) -- printf("(== OpenWrt default)\n"); -- else -- printf("(OpenWrt default: 0x%08x)\n", defval); --} -- --static inline void inspect_fw_phexexp(char *label, -- uint32_t val, uint32_t expval) --{ -- printf("%-23s: 0x%08x ", label, val); -- -- if (val == expval) -- printf("(ok)\n"); -- else -- printf("(expected: 0x%08x)\n", expval); --} -- --static inline void inspect_fw_phexdec(char *label, uint32_t val) -+static inline void inspect_fw_phexdec(const char *label, uint32_t val) - { - printf("%-23s: 0x%08x / %8u bytes\n", label, val, val); - } - --static inline void inspect_fw_phexdecdef(char *label, -- uint32_t val, uint32_t defval) --{ -- printf("%-23s: 0x%08x / %8u bytes ", label, val, val); -- -- if (val == defval) -- printf("(== OpenWrt default)\n"); -- else -- printf("(OpenWrt default: 0x%08x)\n", defval); --} -- --static inline void inspect_fw_pmd5sum(char *label, uint8_t *val, char *text) -+static inline void inspect_fw_pmd5sum(const char *label, const uint8_t *val, const char *text) - { - int i; - -@@ -965,7 +666,6 @@ static int inspect_fw(void) - char *buf; - struct fw_header *hdr; - uint8_t md5sum[MD5SUM_LEN]; -- struct board_info *board; - int ret = EXIT_FAILURE; - - buf = malloc(inspect_info.file_size); -@@ -982,16 +682,14 @@ static int inspect_fw(void) - inspect_fw_pstr("File name", inspect_info.file_name); - inspect_fw_phexdec("File size", inspect_info.file_size); - -- if (ntohl(hdr->version) != HEADER_VERSION_V1) { -- ERR("file does not seem to have V1 header!\n"); -+ if ((ntohl(hdr->version) != HEADER_VERSION_V1) && -+ (ntohl(hdr->version) != HEADER_VERSION_V2)) { -+ ERR("file does not seem to have V1/V2 header!\n"); - goto out_free_buf; - } - - inspect_fw_phexdec("Version 1 Header size", sizeof(struct fw_header)); - -- if (ntohl(hdr->unk1) != 0) -- inspect_fw_phexdec("Unknown value 1", hdr->unk1); -- - memcpy(md5sum, hdr->md5sum1, sizeof(md5sum)); - if (ntohl(hdr->boot_len) == 0) - memcpy(hdr->md5sum1, md5salt_normal, sizeof(md5sum)); -@@ -1016,19 +714,9 @@ static int inspect_fw(void) - - inspect_fw_pstr("Vendor name", hdr->vendor_name); - inspect_fw_pstr("Firmware version", hdr->fw_version); -- board = find_board_by_hwid(ntohl(hdr->hw_id)); -- if (board) { -- layout = find_layout(board->layout_id); -- inspect_fw_phexpost("Hardware ID", -- ntohl(hdr->hw_id), board->id); -- inspect_fw_phexexp("Hardware Revision", -- ntohl(hdr->hw_rev), board->hw_rev); -- } else { -- inspect_fw_phexpost("Hardware ID", -- ntohl(hdr->hw_id), "unknown"); -- inspect_fw_phex("Hardware Revision", -- ntohl(hdr->hw_rev)); -- } -+ inspect_fw_phex("Hardware ID", ntohl(hdr->hw_id)); -+ inspect_fw_phex("Hardware Revision", ntohl(hdr->hw_rev)); -+ inspect_fw_phex("Region code", ntohl(hdr->region_code)); - - printf("\n"); - -@@ -1036,24 +724,12 @@ static int inspect_fw(void) - ntohl(hdr->kernel_ofs)); - inspect_fw_phexdec("Kernel data length", - ntohl(hdr->kernel_len)); -- if (board) { -- inspect_fw_phexdef("Kernel load address", -- ntohl(hdr->kernel_la), -- layout ? layout->kernel_la : 0xffffffff); -- inspect_fw_phexdef("Kernel entry point", -- ntohl(hdr->kernel_ep), -- layout ? layout->kernel_ep : 0xffffffff); -- inspect_fw_phexdecdef("Rootfs data offset", -- ntohl(hdr->rootfs_ofs), -- layout ? layout->rootfs_ofs : 0xffffffff); -- } else { -- inspect_fw_phex("Kernel load address", -- ntohl(hdr->kernel_la)); -- inspect_fw_phex("Kernel entry point", -- ntohl(hdr->kernel_ep)); -- inspect_fw_phexdec("Rootfs data offset", -- ntohl(hdr->rootfs_ofs)); -- } -+ inspect_fw_phex("Kernel load address", -+ ntohl(hdr->kernel_la)); -+ inspect_fw_phex("Kernel entry point", -+ ntohl(hdr->kernel_ep)); -+ inspect_fw_phexdec("Rootfs data offset", -+ ntohl(hdr->rootfs_ofs)); - inspect_fw_phexdec("Rootfs data length", - ntohl(hdr->rootfs_len)); - inspect_fw_phexdec("Boot loader data offset", -@@ -1109,16 +785,13 @@ static int inspect_fw(void) - int main(int argc, char *argv[]) - { - int ret = EXIT_FAILURE; -- int err; -- -- FILE *outfile; - - progname = basename(argv[0]); - - while ( 1 ) { - int c; - -- c = getopt(argc, argv, "a:B:H:E:F:L:V:N:W:ci:k:r:R:o:xX:hsSjv:"); -+ c = getopt(argc, argv, "a:H:E:F:L:m:V:N:W:C:ci:k:r:R:o:xX:hsSjv:"); - if (c == -1) - break; - -@@ -1126,9 +799,6 @@ int main(int argc, char *argv[]) - case 'a': - sscanf(optarg, "0x%x", &rootfs_align); - break; -- case 'B': -- board_id = optarg; -- break; - case 'H': - opt_hw_id = optarg; - break; -@@ -1141,9 +811,15 @@ int main(int argc, char *argv[]) - case 'W': - opt_hw_rev = optarg; - break; -+ case 'C': -+ country = optarg; -+ break; - case 'L': - sscanf(optarg, "0x%x", &kernel_la); - break; -+ case 'm': -+ sscanf(optarg, "%u", &opt_hdr_ver); -+ break; - case 'V': - version = optarg; - break; -@@ -1207,4 +883,3 @@ int main(int argc, char *argv[]) - out: - return ret; - } -- diff --git a/build_patches/openwrt/0007-use-EU-code.patch b/build_patches/openwrt/0007-use-EU-code.patch deleted file mode 100644 index 1632bdb..0000000 --- a/build_patches/openwrt/0007-use-EU-code.patch +++ /dev/null @@ -1,31 +0,0 @@ -diff --git target/linux/ar71xx/image/Makefile target/linux/ar71xx/image/Makefile -index a8073f2..5f0df54 100644 ---- target/linux/ar71xx/image/Makefile -+++ target/linux/ar71xx/image/Makefile -@@ -58,13 +58,14 @@ define Build/mktplinkfw - -o $@.new \ - -j -X 0x40000 \ - -a $(call rootfs_align,$(FILESYSTEM)) \ -- $(if $(findstring sysupgrade,$1),-s) && mv $@.new $@ || rm -f $@ -+ $(wordlist 2,$(words $(1)),$(1)) \ -+ $(if $(findstring sysupgrade,$(word 1,$(1))),-s) && mv $@.new $@ || rm -f $@ - endef - - # -c combined image - define Build/mktplinkfw-initramfs - $(STAGING_DIR_HOST)/bin/mktplinkfw \ -- -H $(TPLINK_HWID) -W $(TPLINK_HWREV) -F $(TPLINK_FLASHLAYOUT) -N OpenWrt -V $(REVISION) \ -+ -H $(TPLINK_HWID) -W $(TPLINK_HWREV) -F $(TPLINK_FLASHLAYOUT) -N OpenWrt -V $(REVISION) $(1) \ - -k $@ \ - -o $@.new \ - -s -S \ -@@ -589,6 +598,9 @@ define Device/tl-wr841n-v11 - BOARDNAME := TL-WR841N-v11 - DEVICE_PROFILE := TLWR841 - TPLINK_HWID := 0x08410011 -+ IMAGES += factory-us.bin factory-eu.bin -+ IMAGE/factory-eu.bin := append-rootfs | mktplinkfw factory -C EU -+ IMAGE/factory-us.bin := append-rootfs | mktplinkfw factory -C US - endef - - define Device/tl-wr842n-v2 diff --git a/build_patches/openwrt/0008-support-region-code-on-cpe.patch b/build_patches/openwrt/0008-support-region-code-on-cpe.patch deleted file mode 100644 index 666cd9b..0000000 --- a/build_patches/openwrt/0008-support-region-code-on-cpe.patch +++ /dev/null @@ -1,24 +0,0 @@ -diff --git tools/firmware-utils/src/tplink-safeloader.c tools/firmware-utils/src/tplink-safeloader.c -index 77a894b..5889bda 100644 ---- tools/firmware-utils/src/tplink-safeloader.c -+++ tools/firmware-utils/src/tplink-safeloader.c -@@ -134,11 +134,19 @@ static const char cpe510_support_list[] = - "SupportList:\r\n" - "CPE510(TP-LINK|UN|N300-5):1.0\r\n" - "CPE510(TP-LINK|UN|N300-5):1.1\r\n" -+ "CPE510(TP-LINK|US|N300-5):1.1\r\n" -+ "CPE510(TP-LINK|EU|N300-5):1.1\r\n" - "CPE520(TP-LINK|UN|N300-5):1.0\r\n" - "CPE520(TP-LINK|UN|N300-5):1.1\r\n" -+ "CPE520(TP-LINK|US|N300-5):1.1\r\n" -+ "CPE520(TP-LINK|EU|N300-5):1.1\r\n" - "CPE210(TP-LINK|UN|N300-2):1.0\r\n" - "CPE210(TP-LINK|UN|N300-2):1.1\r\n" -+ "CPE210(TP-LINK|US|N300-2):1.1\r\n" -+ "CPE210(TP-LINK|EU|N300-2):1.1\r\n" - "CPE220(TP-LINK|UN|N300-2):1.0\r\n" -+ "CPE220(TP-LINK|US|N300-2):1.1\r\n" -+ "CPE220(TP-LINK|EU|N300-2):1.1\r\n" - "CPE220(TP-LINK|UN|N300-2):1.1\r\n"; - - #define error(_ret, _errno, _str, ...) \