Skip to contentSkip to conversation

mtd: sharpslpart: Add sharpslpart partition parser

PATCH New Andrea Adami 1 participant 1 message Aug 31, 2017 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH v9 1/1 mtd: sharpslpart: Add sharpslpart partition parser

The Sharp SL Series (Zaurus) PXA handhelds have 16/64/128M of NAND flash and share the same layout of the first 7M partition, managed by Sharp FTL.

GPL 2.4 sources: http://support.ezaurus.com/developer/source/source_dl.asp

The purpose of this self-contained patch is to add a common parser and remove the hardcoded sizes in the board files (these devices are not yet converted to devicetree).
Users will have benefits because the mtdparts= tag will not be necessary anymore and they will be free to repartition the little sized flash.

The obsolete bootloader can not pass the partitioning info to modern kernels anymore so it has to be read from flash at known logical addresses. (see http://www.h5.dion.ne.jp/~rimemoon/zaurus/memo_006.htm )

In kernel, under arch/arm/mach-pxa we have already 8 machines:
MACH_POODLE, MACH_CORGI, MACH_SHEPERD, MACH_HUSKY, MACH_AKITA, MACH_SPITZ, MACH_BORZOI, MACH_TOSA.
Lost after the 2.4 vendor kernel are MACH_BOXER and MACH_TERRIER.

Almost every model has different factory partitioning: add to this the units can be repartitioned by users with userspace tools (nandlogical) and installers for popular (back then) linux distributions.

The Parameter Area in the first (boot) partition extends from 0x00040000 to 0x0007bfff (176k) and contains two copies of the partition table:
...

0x00060000: Partition Info1     16k
0x00064000: Partition Info2     16k
0x00668000: Model               16k

...

The first 7M partition is managed by the Sharp FTL reserving 5% + 1 blocks for wear-leveling: some blocks are remapped and one layer of translation (logical to physical) is necessary.

There isn't much documentation about this FTL in the 2.4 sources, just the MTD methods for reading and writing using logical addresses and the block management (wear-leveling, use counter).
It seems this FTL was tailored with 16KiB eraesize in mind so to fit one param block exactly, to have two copies of the partition table on two blocks.
Later pxa27x devices have same size but 128KiB erasesize and less blocks (56 vs. 448) but the same schema was adopted, even if the two tables are now in the same eraseblock.

For the purpose of the MTD parser only the read part of the code was taken.

The NAND drivers that can use this parser are sharpsl.c and tmio_nand.c.

---
Changelog:
v1 firt version, initial import of 2.4 sources
v2 refactor applying many suggested fixes
v3 put the partition parser types in the platform data
v4 refactor after ML review
v5 fix commit messages and texts, remove global, fixes after v4 review v6 refactor memory mgmt passing pointer to the FTL, fixes after v5 review v7 verify the oob are free for the FTL, renamings, fixes after v6 review v8 remove blank lines, use u8 instead of uint8_t, fixes after v7 review v9 fix kbuild failure explicitly including <linux/sizes.h> (for SZ_1M)

 drivers/mtd/parsers/Kconfig       |   8 +
 drivers/mtd/parsers/Makefile      |   1 +
 drivers/mtd/parsers/sharpslpart.c | 398 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 407 insertions(+)
 create mode 100644 drivers/mtd/parsers/sharpslpart.c
drivers/mtd/parsers/Kconfig +8 -0
index d206b3c..ee5ab99 100644
@@ -6,3 +6,11 @@ config MTD_PARSER_TRX
 	  may contain up to 3/4 partitions (depending on the version).
 	  This driver will parse TRX header and report at least two partitions:
 	  kernel and rootfs.
+
+config MTD_SHARPSL_PARTS
+	tristate "Sharp SL Series NAND flash partition parser"
+	depends on MTD_NAND_SHARPSL || MTD_NAND_TMIO || COMPILE_TEST
+	help
+	  This provides the read-only FTL logic necessary to read the partition
+	  table from the NAND flash of Sharp SL Series (Zaurus) and the MTD
+	  partition parser using this code.
drivers/mtd/parsers/Makefile +1 -0
index 4d9024e..5b1bcc3 100644
@@ -1 +1,2 @@
 obj-$(CONFIG_MTD_PARSER_TRX)		+= parser_trx.o
+obj-$(CONFIG_MTD_SHARPSL_PARTS)		+= sharpslpart.o
drivers/mtd/parsers/sharpslpart.c new file +398 -0

398 lines not on this page · raw message

Signature · 1 line
2.7.4