147 lines
4.4 KiB
Diff
147 lines
4.4 KiB
Diff
Index: linux-3.10.49/drivers/mtd/Kconfig
|
|
===================================================================
|
|
--- linux-3.10.49.orig/drivers/mtd/Kconfig
|
|
+++ linux-3.10.49/drivers/mtd/Kconfig
|
|
@@ -80,6 +80,13 @@ config MTD_TESTS
|
|
WARNING: some of the tests will ERASE entire MTD device which they
|
|
test. Do not use these tests unless you really know what you do.
|
|
|
|
+config MTD_SIZE_DEPEND_PARTS
|
|
+ bool "Size depended partition generator (hardcoded)"
|
|
+ def_bool n
|
|
+ help
|
|
+ Generate a flash chip size depended partition layout. The layout itself
|
|
+ is hardcoded
|
|
+
|
|
config MTD_REDBOOT_PARTS
|
|
tristate "RedBoot partition table parsing"
|
|
---help---
|
|
Index: linux-3.10.49/drivers/mtd/Makefile
|
|
===================================================================
|
|
--- linux-3.10.49.orig/drivers/mtd/Makefile
|
|
+++ linux-3.10.49/drivers/mtd/Makefile
|
|
@@ -13,6 +13,7 @@ mtd-$(CONFIG_MTD_SPLIT_UIMAGE_FW) += mtd
|
|
mtd-$(CONFIG_MTD_SPLIT_LZMA_FW) += mtdsplit_lzma.o
|
|
|
|
obj-$(CONFIG_MTD_OF_PARTS) += ofpart.o
|
|
+obj-$(CONFIG_MTD_SIZE_DEPEND_PARTS) += size_depend.o
|
|
obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o
|
|
obj-$(CONFIG_MTD_CMDLINE_PARTS) += cmdlinepart.o
|
|
obj-$(CONFIG_MTD_AFS_PARTS) += afs.o
|
|
Index: linux-3.10.49/drivers/mtd/size_depend.c
|
|
===================================================================
|
|
--- /dev/null
|
|
+++ linux-3.10.49/drivers/mtd/size_depend.c
|
|
@@ -0,0 +1,111 @@
|
|
+/*
|
|
+ * Generate a mtd partition table based on the flash
|
|
+ * produce (hardcoded) layout.
|
|
+ *
|
|
+ * Copyright © 2015 Alexander Couzens <lynxis@fe80.eu>
|
|
+ *
|
|
+ * This program is free software; you can redistribute it and/or modify
|
|
+ * it under the terms of the GNU General Public License as published by
|
|
+ * the Free Software Foundation; either version 2 of the License, or
|
|
+ * (at your option) any later version.
|
|
+ *
|
|
+ * This program is distributed in the hope that it will be useful,
|
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
+ * GNU General Public License for more details.
|
|
+ *
|
|
+ */
|
|
+
|
|
+#include <linux/kernel.h>
|
|
+#include <linux/slab.h>
|
|
+#include <linux/init.h>
|
|
+#include <linux/vmalloc.h>
|
|
+
|
|
+#include <linux/mtd/mtd.h>
|
|
+#include <linux/mtd/partitions.h>
|
|
+#include <linux/module.h>
|
|
+#include <linux/err.h>
|
|
+
|
|
+static int parse_size_depend_partitions(struct mtd_info *master,
|
|
+ struct mtd_partition **pparts,
|
|
+ struct mtd_part_parser_data *data)
|
|
+{
|
|
+ /* 256k for "uboot" at the beginning
|
|
+ * space between for "firmware"
|
|
+ * 64k for "art" (calibration) data at the end
|
|
+ */
|
|
+ int nrparts;
|
|
+ int namelen;
|
|
+ struct mtd_partition *parts;
|
|
+ char *name;
|
|
+
|
|
+ printk(KERN_INFO "size_depend: generating mtd layout\n");
|
|
+ /* +1 for \0 bytes */
|
|
+ namelen = strlen("firmware") + 1
|
|
+ + strlen("u-boot") + 1
|
|
+ + strlen("u-boot-env") + 1
|
|
+ + strlen("art") + 1;
|
|
+
|
|
+ nrparts = 4;
|
|
+
|
|
+ parts = kzalloc(sizeof(*parts)*nrparts + namelen, GFP_KERNEL);
|
|
+ if (!parts)
|
|
+ return ERR_PTR(-ENOMEM);
|
|
+
|
|
+ name = (char *) &parts[nrparts];
|
|
+
|
|
+ parts[0].name = name;
|
|
+ parts[0].size = 256 * 1024;
|
|
+ parts[0].offset = 0;
|
|
+ parts[0].mask_flags |= MTD_WRITEABLE;
|
|
+ strlcpy(name, "u-boot", strlen("u-boot") + 1);
|
|
+ name += strlen("u-boot") + 1;
|
|
+
|
|
+ parts[1].name = name;
|
|
+ parts[1].size = 64 * 1024;
|
|
+ parts[1].offset = 256 * 1024;
|
|
+ strlcpy(name, "u-boot-env", strlen("u-boot-env") + 1);
|
|
+ name += strlen("u-boot-env") + 1;
|
|
+
|
|
+ parts[2].name = name;
|
|
+ parts[2].size = mtd_get_device_size(master) - ((320 * 1024) + (64 * 1024));
|
|
+ parts[2].offset = 320 * 1024;
|
|
+ strlcpy(name, "firmware", strlen("firmware") + 1);
|
|
+ name += strlen("firmware") + 1;
|
|
+
|
|
+ parts[3].name = name;
|
|
+ parts[3].size = 64 * 1024;
|
|
+ parts[3].offset = mtd_get_device_size(master) - (64 * 1024);
|
|
+ parts[3].mask_flags |= MTD_WRITEABLE;
|
|
+ strlcpy(name, "art", strlen("art") + 1);
|
|
+
|
|
+ *pparts = parts;
|
|
+
|
|
+ return nrparts;
|
|
+}
|
|
+
|
|
+static struct mtd_part_parser size_depend_parser = {
|
|
+ .owner = THIS_MODULE,
|
|
+ .parse_fn = parse_size_depend_partitions,
|
|
+ .name = "SizeDepend",
|
|
+};
|
|
+
|
|
+/* mtd parsers will request the module by parser name */
|
|
+MODULE_ALIAS("SizeDepend");
|
|
+
|
|
+static int __init size_depend_parser_init(void)
|
|
+{
|
|
+ return register_mtd_parser(&size_depend_parser);
|
|
+}
|
|
+
|
|
+static void __exit size_depend_parser_exit(void)
|
|
+{
|
|
+ deregister_mtd_parser(&size_depend_parser);
|
|
+}
|
|
+
|
|
+module_init(size_depend_parser_init);
|
|
+module_exit(size_depend_parser_exit);
|
|
+
|
|
+MODULE_LICENSE("GPL");
|
|
+MODULE_AUTHOR("Alexander Couzens <lynxis@fe80.eu>");
|
|
+MODULE_DESCRIPTION("Choose a partition table based on flash size");
|