tplink-safeloader support-list on CPE/WBS devices

Matthias Schiffer mschiffer at universe-factory.net
Mon Aug 31 15:23:31 EDT 2020


On 8/31/20 11:18 AM, Sander Vanheule wrote:
> Hi Adrian,
> 
> On Sun, 2020-08-30 at 22:43 +0200, Adrian Schmutzler wrote:
>> Hi,
>>
>> while increasing the kernel partition for the TP-Link CPE devices, I
>> found that the partitions called "soft-version" and "support-list"
>> are handled as a part of the file-system/firmware partition, in
>> contrast to all other tplink-safeloader devices where it is part of a
>> read-only partition. Examples:
>>
>> CPE210 v1 (ar9344-based with okli loader, but without firmware-
>> splitter):
>>
>> tplink-safeloader.c:
>>
>> {"os-image", 0x40000, 0x300000},
>> {"file-system", 0x340000, 0x470000},
>> {"soft-version", 0x7b0000, 0x00100},
>> {"support-list", 0x7b1000, 0x00400},
>> {"user-config", 0x7c0000, 0x10000},
>>
>> .first_sysupgrade_partition = "os-image",
>> .last_sysupgrade_partition = "support-list",
> 
> Looking at the stock firmware partition table of the CPE210 v1/v2, I
> see the following:
>    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
> 
> The order of the file-system and 'device-info' partitions have been
> swapped, (probably) to allow for larger kernels.


Yes, we originally used the firmware layout of the stock firmware, until
the kernel became too big. The partitions were switched and resized in [1,
2]. For the factory install of OpenWrt, the position of these partitions
doesn't matter, only the content.


[1] https://git.openwrt.org/373dc11b519516682ab48bf7db501ffffced4e61
[2] https://git.openwrt.org/e39847ea2f70bf8880a4533b22a0eed110ffea98


[snip]

>> So, I wonder whether:
>> 1. the areas should really be rw for CPE devices, or whether it would
>> be better to just include them in the config partition
>> 2. support-list/soft-version should really be between
>> first_sysupgrade_partition and last_sysupgrade_partition
>>
>> Any hints/ideas?
> 
> The above reordering means that, when converting the device to OpenWrt,
> the following partitions need to be written:
>  * partition-table
>  * os-image (firmware)
>  * file-system (firmware)
>  * soft-version
>  * support-list
> 
> I don't know the behaviour TP-Link's upgrade code on these devices, but
> soft-version is normally rewritten to update the FW version info. I'm
> not sure about support-list and partition-table. At least the newly
> provided partition-table is honoured, otherwise file-system would end
> up in the wrong place.
> 
> When you use the current sysupgrade images to perform the initial
> OpenWrt flash (e.g. flashing from u-boot), partition-table would be
> left untouched and out-of-sync with the flash layout. So this scenario
> doesn't sound like a good way of upgrading.
> 
> For OpenWrt to OpenWrt upgrades (after a factory upgrade), I think you
> are right that soft-version and support-list can be left untouched.
> last_sysupgrade_partition could then be 'file-system', given the
> modified partition table for these devices.
> 

On CPE510 v1 etc., OpenWrt's sysupgrade handler checks that an upgrade
image's support-list section contains the correct string to verify image
validity (this was implemented long before the new metadata code became
reality). For simplicity, the sysupgrade image has the same layout that
would end up im flash after the factory install. The soft-version and
support-list partitions are then overwritten during rootfs creation.

I don't have much knowledge about other devices using the safeloader, but I
assume image validity has be checked in some other way there.

Kind regards,
Matthias

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://lists.openwrt.org/pipermail/openwrt-devel/attachments/20200831/212c8c2f/attachment.sig>


More information about the openwrt-devel mailing list