tplink-safeloader: add TP-Link CPE605 v1 Support

Andrew Cameron apcameron at gmail.com
Thu Dec 8 04:24:16 PST 2022


Hi Sander,

Here is some of the information you requested.

Original partition layout from OEM image:
partition fs-uboot base 0x00000 size 0x20000
partition partition-table base 0x20000 size 0x02000
partition default-mac base 0x30000 size 0x00020
partition serial-number base 0x30100 size 0x00020
partition product-info base 0x31100 size 0x00100
partition device-info base 0x31400 size 0x00400
partition signature base 0x32000 size 0x00400
partition device-id base 0x33000 size 0x00100
partition os-image base 0x40000 size 0x170000
partition soft-version base 0x1b0000 size 0x00100
partition support-list base 0x1b1000 size 0x01000
partition file-system base 0x1c0000 size 0x600000
partition user-config base 0x7c0000 size 0x10000
partition default-config base 0x7d0000 size 0x10000
partition log base 0x7e0000 size 0x10000
partition radio base 0x7f0000 size 0x10000

The 'os-image' and 'file-system' partitions were merged into 'firmware'
to make use of the automatic mtd split.

Vendor Partition info from dmesg
7 cmdlinepart partitions found on MTD device ath-nor0
Creating 7 MTD partitions on "ath-nor0":
0x000000000000-0x000000020000 : "u-boot"
0x000000020000-0x000000030000 : "pation-table"
0x000000030000-0x000000040000 : "product-info"
0x000000040000-0x0000001c0000 : "kernel"
0x0000001c0000-0x0000007c0000 : "rootfs"
0x0000007c0000-0x0000007f0000 : "config"
0x0000007f0000-0x000000800000 : "ART"

OpenWrt Partition info from dmesg
[    0.459454] Creating 6 MTD partitions on "spi0.0":
[    0.464378] 0x000000000000-0x000000020000 : "u-boot"
[    0.476201] 0x000000020000-0x000000030000 : "partition-table"
[    0.483433] 0x000000030000-0x000000040000 : "info"
[    0.491830] 0x000000040000-0x0000007c0000 : "firmware"
[    0.507291] 2 uimage-fw partitions found on MTD device firmware
[    0.513403] Creating 2 MTD partitions on "firmware":
[    0.518456] 0x000000000000-0x000000270000 : "kernel"
[    0.525871] 0x000000270000-0x000000780000 : "rootfs"
[    0.532175] mtd: device 5 (rootfs) set to be root filesystem
[    0.539100] 1 squashfs-split partitions found on MTD device rootfs
[    0.545492] 0x000000590000-0x000000780000 : "rootfs_data"
[    0.553329] 0x0000007c0000-0x0000007f0000 : "config"
[    0.559679] 0x0000007f0000-0x000000800000 : "art"

This has been tested by the person who created this post  https://forum.openwrt.org/t/openwrt-support-for-tp-link-cpe605/141192
He has installed the firmware and restored it back to the vendor firmware using the tftp method.

Regards
Andrew
-----Original Message-----
From: Sander Vanheule [mailto:sander at svanheule.net] 
Sent: Wednesday, December 07, 2022 9:01 PM
To: Andrew Cameron <apcameron at gmail.com>; openwrt-devel at lists.openwrt.org
Subject: Re: tplink-safeloader: add TP-Link CPE605 v1 Support

Hi Andrew,

On Wed, 2022-11-09 at 13:23 +0000, Andrew Cameron wrote:
> From: Andrew Cameron <apcameron at softhome.net>
> 
> Enable creating images compatible with the TP-Link CPE605 v1 Router

Could you also add the original layout as defined in the vendor FW?

See for example commit 71e1db65a548 ("tplink-safeloader: add TP-Link Deco S4 v2
support")

> 
> Signed-off-by: Andrew Cameron <apcameron at softhome.net>
> ---
>  src/tplink-safeloader.c | 38 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 38 insertions(+)
> 
> diff --git a/src/tplink-safeloader.c b/src/tplink-safeloader.c index 
> 7f9081d..b920191 100644
> --- a/src/tplink-safeloader.c
> +++ b/src/tplink-safeloader.c
> @@ -468,6 +468,44 @@ static struct device_info boards[] = {
>                 .last_sysupgrade_partition = "support-list",
>         },
>  
> +       /** Firmware layout for the CPE605V1 */

Comparing to the FW found at [1], there seem to be some discrepancies.

[1] https://static.tp-link.com/2020/202012/20201216/CPE605(UN)_v1.0_20201028.zip

> +       {
> +               .id     = "CPE605V1",
> +               .vendor = "CPE605(TP-LINK|UN|N150-5):1.0\r\n",
> +               .support_list =
> +                       "SupportList:\r\n"
> +                       "CPE605(TP-LINK|UN|N150-5|00000000):1.0\r\n"
> +                       "CPE605(TP-LINK|EU|N150-5|45550000):1.0\r\n"
> +                       "CPE605(TP-LINK|US|N150-5|55530000):1.0\r\n"
> +                       "CPE605(TP-LINK|UN|N150-5):1.0\r\n"
> +                       "CPE605(TP-LINK|EU|N150-5):1.0\r\n"
> +                       "CPE605(TP-LINK|US|N150-5):1.0\r\n",

The last three items are absent. Not that it matters much to have too many items, since the support-list partition has room for 0x1000 bytes.

> +               .part_trail = 0xff,

Partition blobs are followed by a 0x00 byte. Again, this is normally ignored by TP-Link upgrade software, but this is here to mirror vendor FW as closely as possible. (If you have another FW upgrade binary which actually does have 0xff as trailing bytes, then that just goes to show how little this actually
matters.)

> +               .soft_ver = SOFT_VER_DEFAULT,
> +
> +               .partitions = {
> +                       {"fs-uboot", 0x00000, 0x20000},
> +                       {"partition-table", 0x20000, 0x02000},
> +                       {"default-mac", 0x30000, 0x00020},
> +                       {"serial-number", 0x30100, 0x00020},
> +                       {"product-info", 0x31100, 0x00100},
> +                       {"device-info", 0x31400, 0x00400},
> +                       {"signature", 0x32000, 0x00400},
> +                       {"device-id", 0x33000, 0x00100},
> +                       {"firmware", 0x40000, 0x770000},

A note is typically added that the 'firmware' partition replaces the 'os-image'
and 'file-system' partitions.

In the FW image I downloaded, the order of partitions is the following though (from `tplink-safeloader -i`):
   00040000 00170000 os-image
   001b0000 00000100 soft-version
   001b1000 00001000 support-list
   001c0000 00600000 file-system
   
with 'soft-version' and 'support-list' _between_ 'os-image' and 'file-system'.

I'm not sure if the upgrade utility will relocate these partitions and use the updated partition layout (as definded here and provided by the OpenWrt factory image). Did you verify this?

If the partitions are in fact relocated, I assume the 'partition-table', 'soft- version' and 'support-list' contents from the OpenWrt factory image are used.
Which should make it safe to return to stock FW as long as the kernel is at the same location (bootloader), because it would also use the new layout, and relocate things again when on the next vendor-to-vendor upgrade.


Best,
Sander

> +                       {"soft-version", 0x7b0000, 0x00100},
> +                       {"support-list", 0x7b1000, 0x01000},
> +                       {"user-config", 0x7c0000, 0x10000},
> +                       {"default-config", 0x7d0000, 0x10000},
> +                       {"log", 0x7e0000, 0x10000},
> +                       {"radio", 0x7f0000, 0x10000},
> +                       {NULL, 0, 0}
> +               },
> +
> +               .first_sysupgrade_partition = "os-image",
> +               .last_sysupgrade_partition = "support-list",
> +       },
> +
>         /** Firmware layout for the CPE610V1 */
>         {
>                 .id     = "CPE610V1",






More information about the openwrt-devel mailing list