dt-bindings: mtd: partitions: add TP-Link SafeLoader layout
Subsystems (3)
PATCH v3 1/2 dt-bindings: mtd: partitions: add TP-Link SafeLoader layout
From: Rafał Miłecki <[email protected]>
Most TP-Link home routers use the same partitioning system based on a custom ASCII table.
It doesn't seem to have any official name. GPL sources contain tool named simply "make_flash" and Makefile target "FlashMaker".
This partitions table format was first found in devices with a custom SafeLoader bootloader so it was called SafeLoader by a community. Later it was ported to other bootloaders but it seems the name sticked.
Add binding for describing flashes with SafeLoader partitions table. It allows operating systems to parse it properly and register proper flash layout.
---
V2: Fix typo in commit: s/same/name/
V3: Drop quotes from $ref
Describe flash space coverage & partitions types in the binding See commit body of PATCH 2/2 for real life example
--- .../tplink,safeloader-partitions.yaml | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Documentation/devicetree/bindings/mtd/partitions/tplink,safeloader-partitions.yaml
Documentation/devicetree/bindings/mtd/partitions/tplink,safeloader-partitions.yaml new file +49 -0
@@ -0,0 +1,49 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mtd/partitions/tplink,safeloader-partitions.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: TP-Link SafeLoader partitions + +description: | + TP-Link home routers store various data on flash (e.g. bootloader, + flash layout, firmware, product info, configuration, calibration + data). That requires flash partitioning. + + Flash space layout of TP-Link devices is stored on flash itself using + a custom ASCII-based format. That format was first found in TP-Link + devices with a custom SafeLoader bootloader. Later it was adapted to + CFE and U-Boot bootloaders. + + Partitions specified in partitions table cover whole flash space. Some + contain static data that shouldn't get modified (device's MAC or WiFi + calibration data). Others are semi-static (like kernel). Finally some + partitions contain fully changeable content (like rootfs). + + This binding describes partitioning method and defines offset of ASCII + based partitions table. That offset is picked at manufacturing process + and doesn't change. + +maintainers: + - Rafał Miłecki <[email protected]> + +properties: + compatible: + const: tplink,safeloader-partitions + + partitions-table-offset: + description: Flash offset of partitions table + $ref: /schemas/types.yaml#/definitions/uint32 + +required: + - partitions-table-offset + +additionalProperties: false + +examples: + - | + partitions { + compatible = "tplink,safeloader-partitions"; + partitions-table-offset = <0x100000>; + };
Signature · 1 line
2.34.1
PATCH v3 2/2 mtd: parsers: add TP-Link SafeLoader partitions table parser
From: Rafał Miłecki <[email protected]>
This parser deals with most TP-Link home routers. It reads info about partitions and registers them in the MTD subsystem.
Example from TP-Link Archer C5 V2:
spi-nor spi0.0: s25fl128s1 (16384 Kbytes)
15 tplink-safeloader partitions found on MTD device spi0.0 Creating 15 MTD partitions on "spi0.0":
0x000000000000-0x000000040000 : "fs-uboot" 0x000000040000-0x000000440000 : "os-image" 0x000000440000-0x000000e40000 : "rootfs" 0x000000e40000-0x000000e40200 : "default-mac" 0x000000e40200-0x000000e40400 : "pin" 0x000000e40400-0x000000e40600 : "product-info" 0x000000e50000-0x000000e60000 : "partition-table" 0x000000e60000-0x000000e60200 : "soft-version" 0x000000e61000-0x000000e70000 : "support-list" 0x000000e70000-0x000000e80000 : "profile" 0x000000e80000-0x000000e90000 : "default-config" 0x000000e90000-0x000000ee0000 : "user-config" 0x000000ee0000-0x000000fe0000 : "log" 0x000000fe0000-0x000000ff0000 : "radio_bk" 0x000000ff0000-0x000001000000 : "radio"
---
V2: Fix types (thanks kernel test robot)
Fix off-by-one when setting '\0'
V3: Include parsing example in commit body
--- drivers/mtd/parsers/Kconfig | 15 +++ drivers/mtd/parsers/Makefile | 1 + drivers/mtd/parsers/tplink_safeloader.c | 150 ++++++++++++++++++++++++ 3 files changed, 166 insertions(+) create mode 100644 drivers/mtd/parsers/tplink_safeloader.c
drivers/mtd/parsers/Kconfig +15 -0
@@ -123,6 +123,21 @@ config MTD_AFS_PARTS for your particular device. It won't happen automatically. The 'physmap' map driver (CONFIG_MTD_PHYSMAP) does this, for example. +config MTD_PARSER_TPLINK_SAFELOADER + tristate "TP-Link Safeloader partitions parser" + depends on MTD && (ARCH_BCM_5301X || ATH79 || SOC_MT7620 || SOC_MT7621 || COMPILE_TEST) + help + TP-Link home routers use flash partitions to store various data. Info + about flash space layout is stored in a partitions table using a + custom ASCII-based format. + + That format was first found in devices with SafeLoader bootloader and + was named after it. Later it was adapted to CFE and U-Boot + bootloaders. + + This driver reads partitions table, parses it and creates MTD + partitions. + config MTD_PARSER_TRX tristate "Parser for TRX format partitions" depends on MTD && (BCM47XX || ARCH_BCM_5301X || ARCH_MEDIATEK || RALINK || COMPILE_TEST)
drivers/mtd/parsers/Makefile +1 -0
@@ -10,6 +10,7 @@ ofpart-$(CONFIG_MTD_OF_PARTS_BCM4908) += ofpart_bcm4908.o ofpart-$(CONFIG_MTD_OF_PARTS_LINKSYS_NS)+= ofpart_linksys_ns.o obj-$(CONFIG_MTD_PARSER_IMAGETAG) += parser_imagetag.o obj-$(CONFIG_MTD_AFS_PARTS) += afs.o +obj-$(CONFIG_MTD_PARSER_TPLINK_SAFELOADER) += tplink_safeloader.o obj-$(CONFIG_MTD_PARSER_TRX) += parser_trx.o obj-$(CONFIG_MTD_SERCOMM_PARTS) += scpart.o obj-$(CONFIG_MTD_SHARPSL_PARTS) += sharpslpart.o
drivers/mtd/parsers/tplink_safeloader.c new file +150 -0
150 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH V3 2/2] mtd: parsers: add TP-Link SafeLoader partitions table parser
Quoted 26 lines · On Sat, 2022-10-15 at 09:29:50 UTC, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= wrote:
From: Rafał Miłecki <[email protected]>
This parser deals with most TP-Link home routers. It reads info about partitions and registers them in the MTD subsystem.
Example from TP-Link Archer C5 V2:
spi-nor spi0.0: s25fl128s1 (16384 Kbytes)
15 tplink-safeloader partitions found on MTD device spi0.0 Creating 15 MTD partitions on "spi0.0":
0x000000000000-0x000000040000 : "fs-uboot" 0x000000040000-0x000000440000 : "os-image" 0x000000440000-0x000000e40000 : "rootfs" 0x000000e40000-0x000000e40200 : "default-mac" 0x000000e40200-0x000000e40400 : "pin" 0x000000e40400-0x000000e40600 : "product-info" 0x000000e50000-0x000000e60000 : "partition-table" 0x000000e60000-0x000000e60200 : "soft-version" 0x000000e61000-0x000000e70000 : "support-list" 0x000000e70000-0x000000e80000 : "profile" 0x000000e80000-0x000000e90000 : "default-config" 0x000000e90000-0x000000ee0000 : "user-config" 0x000000ee0000-0x000000fe0000 : "log" 0x000000fe0000-0x000000ff0000 : "radio_bk" 0x000000ff0000-0x000001000000 : "radio"
Quoted 1 line
Signed-off-by Rafał Miłecki <[email protected]>
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.
Miquel
Quoted 22 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
Most TP-Link home routers use the same partitioning system based on a custom ASCII table.
It doesn't seem to have any official name. GPL sources contain tool named simply "
make_flash" andMakefiletarget "FlashMaker".This partitions table format was first found in devices with a custom SafeLoader bootloader so it was called SafeLoader by a community. Later it was ported to other bootloaders but it seems the name sticked.
Add binding for describing flashes with SafeLoader partitions table. It allows operating systems to parse it properly and register proper flash layout.
Signed-off-by Rafał Miłecki <[email protected]>---
V2: Fix typo in commit: s/same/name/
V3: Drop quotes from $ref
Describe flash space coverage & partitions types in the binding See commit body of PATCH 2/2 for real life example
Quoted 5 lines
--- .../tplink,safeloader-partitions.yaml | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Documentation/devicetree/bindings/mtd/partitions/tplink,safeloader-partitions.yaml
Quoted 12 lines · On Sat, 2022-10-15 at 09:29:49 UTC, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= wrote:
From: Rafał Miłecki <[email protected]>
Most TP-Link home routers use the same partitioning system based on a custom ASCII table.
It doesn't seem to have any official name. GPL sources contain tool named simply "
make_flash" andMakefiletarget "FlashMaker".This partitions table format was first found in devices with a custom SafeLoader bootloader so it was called SafeLoader by a community. Later it was ported to other bootloaders but it seems the name sticked.
Quoted 6 lines
Add binding for describing flashes with SafeLoader partitions table. It allows operating systems to parse it properly and register proper flash layout.
Signed-off-by Rafał Miłecki <[email protected]>Reviewed-by Rob Herring <[email protected]>
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.
Miquel