Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ar71xx: Archer c25/c59/c60 support #1162

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,291 @@
From 2f964ef7d3e7bc0902e8171523e30a9623b6da0e Mon Sep 17 00:00:00 2001
From: Jan Niehusmann <jan@gondor.com>
Date: Fri, 19 May 2017 09:42:24 +0200
Subject: [PATCH] firmware-utils: tplink-safeloader: support strings as
soft_version

Some TP-Link routers (C25, C59, C60) contain a version string instead
of a binary structure in the soft_version partition.

Flashing LEDE from the original firmware's GUI, this version string
taken from the soft_ver partition of the firmware image is written to
the router's config partition.

When using tftp recovery to go back to the original Archer C25 firmware,
a version check compares that version to the version of the firmware to
be flashed.

Without proper contents in the config partition, reverting to the
original firmware fails.

Therefore, write the string "soft_ver:1.0.0\n" to that soft_ver
partition.

Signed-off-by: Jan Niehusmann <jan@gondor.com>
---
tools/firmware-utils/src/tplink-safeloader.c | 151 ++++++++++++++++++++++++++-
1 file changed, 150 insertions(+), 1 deletion(-)

diff --git a/tools/firmware-utils/src/tplink-safeloader.c b/tools/firmware-utils/src/tplink-safeloader.c
index 4e3d2058b2..9c9efc369c 100644
--- a/tools/firmware-utils/src/tplink-safeloader.c
+++ b/tools/firmware-utils/src/tplink-safeloader.c
@@ -75,6 +75,7 @@ struct device_info {
const char *vendor;
const char *support_list;
char support_trail;
+ const char *soft_ver;
const struct flash_partition_entry partitions[MAX_PARTITIONS+1];
const char *first_sysupgrade_partition;
const char *last_sysupgrade_partition;
@@ -130,6 +131,7 @@ static struct device_info boards[] = {
"CPE220(TP-LINK|US|N300-2):1.1\r\n"
"CPE220(TP-LINK|EU|N300-2):1.1\r\n",
.support_trail = '\xff',
+ .soft_ver = NULL,

.partitions = {
{"fs-uboot", 0x00000, 0x20000},
@@ -167,6 +169,7 @@ static struct device_info boards[] = {
"CPE520(TP-LINK|US|N300-5):1.1\r\n"
"CPE520(TP-LINK|EU|N300-5):1.1\r\n",
.support_trail = '\xff',
+ .soft_ver = NULL,

.partitions = {
{"fs-uboot", 0x00000, 0x20000},
@@ -198,6 +201,7 @@ static struct device_info boards[] = {
"WBS210(TP-LINK|US|N300-2):1.20\r\n"
"WBS210(TP-LINK|EU|N300-2):1.20\r\n",
.support_trail = '\xff',
+ .soft_ver = NULL,

.partitions = {
{"fs-uboot", 0x00000, 0x20000},
@@ -229,6 +233,7 @@ static struct device_info boards[] = {
"WBS510(TP-LINK|US|N300-5):1.20\r\n"
"WBS510(TP-LINK|EU|N300-5):1.20\r\n",
.support_trail = '\xff',
+ .soft_ver = NULL,

.partitions = {
{"fs-uboot", 0x00000, 0x20000},
@@ -259,6 +264,7 @@ static struct device_info boards[] = {
"SupportList:\r\n"
"{product_name:Archer C2600,product_ver:1.0.0,special_id:00000000}\r\n",
.support_trail = '\x00',
+ .soft_ver = NULL,

.partitions = {
{"SBL1", 0x00000, 0x20000},
@@ -293,6 +299,79 @@ static struct device_info boards[] = {
.last_sysupgrade_partition = "file-system"
},

+ /** Firmware layout for the C59v1 */
+ {
+ .id = "ARCHER-C59-V1",
+ .vendor = "",
+ .support_list =
+ "SupportList:\r\n"
+ "{product_name:Archer C59,product_ver:1.0.0,special_id:00000000}\r\n"
+ "{product_name:Archer C59,product_ver:1.0.0,special_id:45550000}\r\n"
+ "{product_name:Archer C59,product_ver:1.0.0,special_id:55530000}\r\n",
+ .support_trail = '\x00',
+ .soft_ver = "soft_ver:1.0.0\n",
+
+ .partitions = {
+ {"fs-uboot", 0x00000, 0x10000},
+ {"default-mac", 0x10000, 0x00200},
+ {"pin", 0x10200, 0x00200},
+ {"device-id", 0x10400, 0x00100},
+ {"product-info", 0x10500, 0x0fb00},
+ {"os-image", 0x20000, 0x180000},
+ {"file-system", 0x1a0000, 0xcb0000},
+ {"partition-table", 0xe50000, 0x10000},
+ {"soft-version", 0xe60000, 0x10000},
+ {"support-list", 0xe70000, 0x10000},
+ {"profile", 0xe80000, 0x10000},
+ {"default-config", 0xe90000, 0x10000},
+ {"user-config", 0xea0000, 0x40000},
+ {"usb-config", 0xee0000, 0x10000},
+ {"certificate", 0xef0000, 0x10000},
+ {"qos-db", 0xf00000, 0x40000},
+ {"log", 0xfe0000, 0x10000},
+ {"radio", 0xff0000, 0x10000},
+ {NULL, 0, 0}
+ },
+
+ .first_sysupgrade_partition = "os-image",
+ .last_sysupgrade_partition = "file-system",
+ },
+
+ /** Firmware layout for the C60v1 */
+ {
+ .id = "ARCHER-C60-V1",
+ .vendor = "",
+ .support_list =
+ "SupportList:\r\n"
+ "{product_name:Archer C60,product_ver:1.0.0,special_id:00000000}\r\n"
+ "{product_name:Archer C60,product_ver:1.0.0,special_id:45550000}\r\n"
+ "{product_name:Archer C60,product_ver:1.0.0,special_id:55530000}\r\n",
+ .support_trail = '\x00',
+ .soft_ver = "soft_ver:1.0.0\n",
+
+ .partitions = {
+ {"fs-uboot", 0x00000, 0x10000},
+ {"default-mac", 0x10000, 0x00200},
+ {"pin", 0x10200, 0x00200},
+ {"product-info", 0x10400, 0x00100},
+ {"partition-table", 0x10500, 0x00800},
+ {"soft-version", 0x11300, 0x00200},
+ {"support-list", 0x11500, 0x00100},
+ {"device-id", 0x11600, 0x00100},
+ {"profile", 0x11700, 0x03900},
+ {"default-config", 0x15000, 0x04000},
+ {"user-config", 0x19000, 0x04000},
+ {"os-image", 0x20000, 0x150000},
+ {"file-system", 0x170000, 0x678000},
+ {"certyficate", 0x7e8000, 0x08000},
+ {"radio", 0x7f0000, 0x10000},
+ {NULL, 0, 0}
+ },
+
+ .first_sysupgrade_partition = "os-image",
+ .last_sysupgrade_partition = "file-system",
+ },
+
/** Firmware layout for the C5 */
{
.id = "ARCHER-C5-V2",
@@ -303,6 +382,7 @@ static struct device_info boards[] = {
"product_ver:2.0.0,"
"special_id:00000000}\r\n",
.support_trail = '\x00',
+ .soft_ver = NULL,

.partitions = {
{"fs-uboot", 0x00000, 0x40000},
@@ -337,6 +417,7 @@ static struct device_info boards[] = {
"product_ver:1.0.0,"
"special_id:00000000}\n",
.support_trail = '\x00',
+ .soft_ver = NULL,

.partitions = {
{"fs-uboot", 0x00000, 0x40000},
@@ -369,6 +450,7 @@ static struct device_info boards[] = {
"SupportList:\r\n"
"EAP120(TP-LINK|UN|N300-2):1.0\r\n",
.support_trail = '\xff',
+ .soft_ver = NULL,

.partitions = {
{"fs-uboot", 0x00000, 0x20000},
@@ -390,6 +472,50 @@ static struct device_info boards[] = {
.last_sysupgrade_partition = "file-system"
},

+ /** Firmware layout for the TL-WA850RE v2 */
+ {
+ .id = "TLWA850REV2",
+ .vendor = "",
+ .support_list =
+ "SupportList:\n"
+ "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:55530000}\n"
+ "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:00000000}\n"
+ "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:55534100}\n"
+ "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:45550000}\n"
+ "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:4B520000}\n"
+ "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:42520000}\n"
+ "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:4A500000}\n"
+ "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:43410000}\n"
+ "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:41550000}\n"
+ "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:52550000}\n",
+ .support_trail = '\x00',
+ .soft_ver = NULL,
+
+ /**
+ 576KB were moved from file-system to os-image
+ in comparison to the stock image
+ */
+ .partitions = {
+ {"fs-uboot", 0x00000, 0x20000},
+ {"os-image", 0x20000, 0x150000},
+ {"file-system", 0x170000, 0x240000},
+ {"partition-table", 0x3b0000, 0x02000},
+ {"default-mac", 0x3c0000, 0x00020},
+ {"pin", 0x3c0100, 0x00020},
+ {"product-info", 0x3c1000, 0x01000},
+ {"soft-version", 0x3c2000, 0x00100},
+ {"support-list", 0x3c3000, 0x01000},
+ {"profile", 0x3c4000, 0x08000},
+ {"user-config", 0x3d0000, 0x10000},
+ {"default-config", 0x3e0000, 0x10000},
+ {"radio", 0x3f0000, 0x10000},
+ {NULL, 0, 0}
+ },
+
+ .first_sysupgrade_partition = "os-image",
+ .last_sysupgrade_partition = "file-system"
+ },
+
/** Firmware layout for the TL-WR1043 v4 */
{
.id = "TLWR1043NDV4",
@@ -398,6 +524,7 @@ static struct device_info boards[] = {
"SupportList:\n"
"{product_name:TL-WR1043ND,product_ver:4.0.0,special_id:45550000}\n",
.support_trail = '\x00',
+ .soft_ver = NULL,

/**
We use a bigger os-image partition than the stock images (and thus
@@ -441,6 +568,7 @@ static struct device_info boards[] = {
"{product_name:RE450,product_ver:1.0.0,special_id:4B520000}\r\n"
"{product_name:RE450,product_ver:1.0.0,special_id:55534100}\r\n",
.support_trail = '\x00',
+ .soft_ver = NULL,

/**
The flash partition table for RE450;
@@ -569,6 +697,23 @@ static struct image_partition_entry make_soft_version(uint32_t rev) {
return entry;
}

+static struct image_partition_entry make_soft_version_from_string(const char *soft_ver) {
+ /** String length _including_ the terminating zero byte */
+ uint32_t ver_len = strlen(soft_ver) + 1;
+ /** Partition contains 64 bit header, the version string, and one additional null byte */
+ size_t partition_len = 2*sizeof(uint32_t) + ver_len + 1;
+ struct image_partition_entry entry = alloc_image_partition("soft-version", partition_len);
+
+ uint32_t *len = (uint32_t *)entry.data;
+ len[0] = htonl(ver_len);
+ len[1] = 0;
+ memcpy(&len[2], soft_ver, ver_len);
+
+ entry.data[partition_len - 1] = 0;
+
+ return entry;
+}
+
/** Generates the support-list partition */
static struct image_partition_entry make_support_list(const struct device_info *info) {
size_t len = strlen(info->support_list);
@@ -799,7 +944,11 @@ static void build_image(const char *output,
struct image_partition_entry parts[6] = {};

parts[0] = make_partition_table(info->partitions);
- parts[1] = make_soft_version(rev);
+ if (info->soft_ver)
+ parts[1] = make_soft_version_from_string(info->soft_ver);
+ else
+ parts[1] = make_soft_version(rev);
+
parts[2] = make_support_list(info);
parts[3] = read_file("os-image", kernel_image, false);
parts[4] = read_file("file-system", rootfs_image, add_jffs2_eof);
--
2.13.1

@@ -0,0 +1,88 @@
From 11b595e5053115a726c075dcc5c9eddf8caaff7e Mon Sep 17 00:00:00 2001
From: Piotr Dymacz <pepe2k@gmail.com>
Date: Tue, 30 May 2017 22:25:02 +0200
Subject: [PATCH] ar71xx: image: drop redundant uboot-envtools from
DEVICE_PACKAGES

uboot-envtools is already included in DEFAULT_PACKAGES for ar71xx.

Signed-off-by: Piotr Dymacz <pepe2k@gmail.com>
---
target/linux/ar71xx/image/generic.mk | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/target/linux/ar71xx/image/generic.mk b/target/linux/ar71xx/image/generic.mk
index d978dec412..29ed108d5d 100644
--- a/target/linux/ar71xx/image/generic.mk
+++ b/target/linux/ar71xx/image/generic.mk
@@ -140,7 +140,7 @@ TARGET_DEVICES += gl-ar300

define Device/gl-ar300m
DEVICE_TITLE := GL AR300M
- DEVICE_PACKAGES := kmod-usb-core kmod-usb2 uboot-envtools
+ DEVICE_PACKAGES := kmod-usb-core kmod-usb2
BOARDNAME = GL-AR300M
IMAGE_SIZE = 16000k
CONSOLE = ttyS0,115200
@@ -259,7 +259,6 @@ TARGET_DEVICES += wndr3700 wndr3700v2 wndr3800 wndr3800ch wndrmac wndrmacv2

define Device/cap324
DEVICE_TITLE := PowerCloud CAP324 Cloud AP
- DEVICE_PACKAGES := uboot-envtools
BOARDNAME := CAP324
DEVICE_PROFILE := CAP324
IMAGE_SIZE = 15296k
@@ -270,7 +269,6 @@ TARGET_DEVICES += cap324

define Device/cap324-nocloud
DEVICE_TITLE := PowerCloud CAP324 Cloud AP (No-Cloud)
- DEVICE_PACKAGES := uboot-envtools
BOARDNAME := CAP324
DEVICE_PROFILE := CAP324
IMAGE_SIZE = 16000k
@@ -281,7 +279,6 @@ TARGET_DEVICES += cap324-nocloud

define Device/cr3000
DEVICE_TITLE := PowerCloud CR3000 Cloud Router
- DEVICE_PACKAGES := uboot-envtools
BOARDNAME := CR3000
DEVICE_PROFILE := CR3000
IMAGE_SIZE = 7104k
@@ -292,7 +289,6 @@ TARGET_DEVICES += cr3000

define Device/cr3000-nocloud
DEVICE_TITLE := PowerCloud CR3000 (No-Cloud)
- DEVICE_PACKAGES := uboot-envtools
BOARDNAME := CR3000
DEVICE_PROFILE := CR3000
IMAGE_SIZE = 7808k
@@ -303,7 +299,7 @@ TARGET_DEVICES += cr3000-nocloud

define Device/cr5000
DEVICE_TITLE := PowerCloud CR5000 Cloud Router
- DEVICE_PACKAGES := uboot-envtools kmod-usb2 kmod-usb-ohci kmod-usb-ledtrig-usbport kmod-usb-core
+ DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-usb-ledtrig-usbport kmod-usb-core
BOARDNAME := CR5000
DEVICE_PROFILE := CR5000
IMAGE_SIZE = 7104k
@@ -314,7 +310,7 @@ TARGET_DEVICES += cr5000

define Device/cr5000-nocloud
DEVICE_TITLE := PowerCloud CR5000 (No-Cloud)
- DEVICE_PACKAGES := uboot-envtools kmod-usb2 kmod-usb-ohci kmod-usb-ledtrig-usbport kmod-usb-core
+ DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-usb-ledtrig-usbport kmod-usb-core
BOARDNAME := CR5000
DEVICE_PROFILE := CR5000
IMAGE_SIZE = 7808k
@@ -690,7 +686,7 @@ endef

define Device/dap-2695-a1
DEVICE_TITLE := D-Link DAP-2695 rev. A1
- DEVICE_PACKAGES := ath10k-firmware-qca988x kmod-ath10k uboot-envtools
+ DEVICE_PACKAGES := ath10k-firmware-qca988x kmod-ath10k
BOARDNAME = DAP-2695-A1
IMAGES := factory.img sysupgrade.bin
IMAGE_SIZE = 15360k
--
2.13.1