tplink-safeloader: add TP-Link CPE605 v1 Support

Sander Vanheule sander at svanheule.net
Wed Dec 7 13:00:32 PST 2022


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