Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: parsers: add TP-Link SafeLoader partitions table parser

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"

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20221015092950.27467-2-zajec5@gmail.com

authored by

Rafał Miłecki and committed by
Miquel Raynal
00a35880 132c57b4

+166
+15
drivers/mtd/parsers/Kconfig
··· 123 123 for your particular device. It won't happen automatically. The 124 124 'physmap' map driver (CONFIG_MTD_PHYSMAP) does this, for example. 125 125 126 + config MTD_PARSER_TPLINK_SAFELOADER 127 + tristate "TP-Link Safeloader partitions parser" 128 + depends on MTD && (ARCH_BCM_5301X || ATH79 || SOC_MT7620 || SOC_MT7621 || COMPILE_TEST) 129 + help 130 + TP-Link home routers use flash partitions to store various data. Info 131 + about flash space layout is stored in a partitions table using a 132 + custom ASCII-based format. 133 + 134 + That format was first found in devices with SafeLoader bootloader and 135 + was named after it. Later it was adapted to CFE and U-Boot 136 + bootloaders. 137 + 138 + This driver reads partitions table, parses it and creates MTD 139 + partitions. 140 + 126 141 config MTD_PARSER_TRX 127 142 tristate "Parser for TRX format partitions" 128 143 depends on MTD && (BCM47XX || ARCH_BCM_5301X || ARCH_MEDIATEK || RALINK || COMPILE_TEST)
+1
drivers/mtd/parsers/Makefile
··· 10 10 ofpart-$(CONFIG_MTD_OF_PARTS_LINKSYS_NS)+= ofpart_linksys_ns.o 11 11 obj-$(CONFIG_MTD_PARSER_IMAGETAG) += parser_imagetag.o 12 12 obj-$(CONFIG_MTD_AFS_PARTS) += afs.o 13 + obj-$(CONFIG_MTD_PARSER_TPLINK_SAFELOADER) += tplink_safeloader.o 13 14 obj-$(CONFIG_MTD_PARSER_TRX) += parser_trx.o 14 15 obj-$(CONFIG_MTD_SERCOMM_PARTS) += scpart.o 15 16 obj-$(CONFIG_MTD_SHARPSL_PARTS) += sharpslpart.o