aboutsummaryrefslogtreecommitdiffstats
path: root/target
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2016-01-17 10:41:08 +0000
committerFelix Fietkau <nbd@openwrt.org>2016-01-17 10:41:08 +0000
commitef3c786a0b64d25a04d09a83e61875223588527e (patch)
treee41969390e5fb1be6b5eda975715c6bdb232b642 /target
parentde23a020f3d3b08194e5ac0141b8d64bb766893b (diff)
downloadmaster-187ad058-ef3c786a0b64d25a04d09a83e61875223588527e.tar.gz
master-187ad058-ef3c786a0b64d25a04d09a83e61875223588527e.tar.bz2
master-187ad058-ef3c786a0b64d25a04d09a83e61875223588527e.zip
kernel: mtdsplit: add support for EVA images
This allows splitting EVA images (usually found in fritz devices). The firmware will be split into a kernel and a separate rootfs partition. Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@48262 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target')
-rw-r--r--target/linux/generic/config-3.181
-rw-r--r--target/linux/generic/config-4.11
-rw-r--r--target/linux/generic/config-4.31
-rw-r--r--target/linux/generic/config-4.41
-rw-r--r--target/linux/generic/files/drivers/mtd/mtdsplit/Kconfig5
-rw-r--r--target/linux/generic/files/drivers/mtd/mtdsplit/Makefile1
-rw-r--r--target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_eva.c96
7 files changed, 106 insertions, 0 deletions
diff --git a/target/linux/generic/config-3.18 b/target/linux/generic/config-3.18
index c8ba32802c..f3ec88d036 100644
--- a/target/linux/generic/config-3.18
+++ b/target/linux/generic/config-3.18
@@ -2266,6 +2266,7 @@ CONFIG_MTD_ROOTFS_SPLIT=y
# CONFIG_MTD_SPINAND_MT29F is not set
CONFIG_MTD_SPLIT=y
# CONFIG_MTD_SPLIT_BRNIMAGE_FW is not set
+# CONFIG_MTD_SPLIT_EVA_FW is not set
# CONFIG_MTD_SPLIT_FIRMWARE is not set
CONFIG_MTD_SPLIT_FIRMWARE_NAME="firmware"
# CONFIG_MTD_SPLIT_FIT_FW is not set
diff --git a/target/linux/generic/config-4.1 b/target/linux/generic/config-4.1
index ade6807b21..222f8c1c76 100644
--- a/target/linux/generic/config-4.1
+++ b/target/linux/generic/config-4.1
@@ -2358,6 +2358,7 @@ CONFIG_MTD_ROOTFS_ROOT_DEV=y
# CONFIG_MTD_SPINAND_MT29F is not set
CONFIG_MTD_SPLIT=y
# CONFIG_MTD_SPLIT_BRNIMAGE_FW is not set
+# CONFIG_MTD_SPLIT_EVA_FW is not set
# CONFIG_MTD_SPLIT_FIRMWARE is not set
CONFIG_MTD_SPLIT_FIRMWARE_NAME="firmware"
# CONFIG_MTD_SPLIT_FIT_FW is not set
diff --git a/target/linux/generic/config-4.3 b/target/linux/generic/config-4.3
index f5d8ce88a2..23e6048736 100644
--- a/target/linux/generic/config-4.3
+++ b/target/linux/generic/config-4.3
@@ -2416,6 +2416,7 @@ CONFIG_MTD_ROOTFS_ROOT_DEV=y
# CONFIG_MTD_SPINAND_MT29F is not set
CONFIG_MTD_SPLIT=y
# CONFIG_MTD_SPLIT_BRNIMAGE_FW is not set
+# CONFIG_MTD_SPLIT_EVA_FW is not set
# CONFIG_MTD_SPLIT_FIRMWARE is not set
CONFIG_MTD_SPLIT_FIRMWARE_NAME="firmware"
# CONFIG_MTD_SPLIT_FIT_FW is not set
diff --git a/target/linux/generic/config-4.4 b/target/linux/generic/config-4.4
index c27192d385..6ad3008af6 100644
--- a/target/linux/generic/config-4.4
+++ b/target/linux/generic/config-4.4
@@ -2319,6 +2319,7 @@ CONFIG_MTD_ROOTFS_ROOT_DEV=y
# CONFIG_MTD_SPI_NOR_USE_4K_SECTORS is not set
CONFIG_MTD_SPLIT=y
# CONFIG_MTD_SPLIT_BRNIMAGE_FW is not set
+# CONFIG_MTD_SPLIT_EVA_FW is not set
# CONFIG_MTD_SPLIT_FIRMWARE is not set
CONFIG_MTD_SPLIT_FIRMWARE_NAME="firmware"
# CONFIG_MTD_SPLIT_FIT_FW is not set
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/Kconfig b/target/linux/generic/files/drivers/mtd/mtdsplit/Kconfig
index 0370a21c9f..131a74fd30 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/Kconfig
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/Kconfig
@@ -54,3 +54,8 @@ config MTD_SPLIT_BRNIMAGE_FW
bool "brnImage (brnboot image) firmware parser"
depends on MTD_SPLIT_SUPPORT
select MTD_SPLIT
+
+config MTD_SPLIT_EVA_FW
+ bool "EVA image based firmware partition parser"
+ depends on MTD_SPLIT_SUPPORT
+ select MTD_SPLIT
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/Makefile b/target/linux/generic/files/drivers/mtd/mtdsplit/Makefile
index ca24c717dc..acf799e27a 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/Makefile
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/Makefile
@@ -7,3 +7,4 @@ obj-$(CONFIG_MTD_SPLIT_LZMA_FW) += mtdsplit_lzma.o
obj-$(CONFIG_MTD_SPLIT_TPLINK_FW) += mtdsplit_tplink.o
obj-$(CONFIG_MTD_SPLIT_TRX_FW) += mtdsplit_trx.o
obj-$(CONFIG_MTD_SPLIT_BRNIMAGE_FW) += mtdsplit_brnimage.o
+obj-$(CONFIG_MTD_SPLIT_EVA_FW) += mtdsplit_eva.o
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_eva.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_eva.c
new file mode 100644
index 0000000000..d262e6083e
--- /dev/null
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_eva.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2012 John Crispin <blogic@openwrt.org>
+ * Copyright (C) 2015 Martin Blumenstingl <martin.blumenstingl@googlemail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+#include <linux/byteorder/generic.h>
+
+#include "mtdsplit.h"
+
+#define EVA_NR_PARTS 2
+#define EVA_MAGIC 0xfeed1281
+#define EVA_FOOTER_SIZE 0x18
+#define EVA_DUMMY_SQUASHFS_SIZE 0x100
+
+struct eva_image_header {
+ uint32_t magic;
+ uint32_t size;
+};
+
+static int mtdsplit_parse_eva(struct mtd_info *master,
+ struct mtd_partition **pparts,
+ struct mtd_part_parser_data *data)
+{
+ struct mtd_partition *parts;
+ struct eva_image_header hdr;
+ size_t retlen;
+ unsigned long kernel_size, rootfs_offset;
+ int err;
+
+ err = mtd_read(master, 0, sizeof(hdr), &retlen, (void *) &hdr);
+ if (err)
+ return err;
+
+ if (retlen != sizeof(hdr))
+ return -EIO;
+
+ if (le32_to_cpu(hdr.magic) != EVA_MAGIC)
+ return -EINVAL;
+
+ kernel_size = le32_to_cpu(hdr.size) + EVA_FOOTER_SIZE;
+
+ /* rootfs starts at the next 0x10000 boundary: */
+ rootfs_offset = round_up(kernel_size, 0x10000);
+
+ /* skip the dummy EVA squashfs partition (with wrong endianness): */
+ rootfs_offset += EVA_DUMMY_SQUASHFS_SIZE;
+
+ if (rootfs_offset >= master->size)
+ return -EINVAL;
+
+ err = mtd_check_rootfs_magic(master, rootfs_offset);
+ if (err)
+ return err;
+
+ parts = kzalloc(EVA_NR_PARTS * sizeof(*parts), GFP_KERNEL);
+ if (!parts)
+ return -ENOMEM;
+
+ parts[0].name = KERNEL_PART_NAME;
+ parts[0].offset = 0;
+ parts[0].size = kernel_size;
+
+ parts[1].name = ROOTFS_PART_NAME;
+ parts[1].offset = rootfs_offset;
+ parts[1].size = master->size - rootfs_offset;
+
+ *pparts = parts;
+ return EVA_NR_PARTS;
+}
+
+static struct mtd_part_parser mtdsplit_eva_parser = {
+ .owner = THIS_MODULE,
+ .name = "eva-fw",
+ .parse_fn = mtdsplit_parse_eva,
+ .type = MTD_PARSER_TYPE_FIRMWARE,
+};
+
+static int __init mtdsplit_eva_init(void)
+{
+ register_mtd_parser(&mtdsplit_eva_parser);
+
+ return 0;
+}
+
+subsys_initcall(mtdsplit_eva_init);