From: Felix Fietkau Date: Fri, 2 Jan 2015 21:52:35 +0000 (+0000) Subject: kernel: move mtdsplit files to drivers/mtd/mtdsplit/ to simplify maintenance, unify... X-Git-Tag: reboot~4852 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=4153c0adff074167f1eb934235129471d2c04199;p=openwrt%2Fstaging%2Fpepe2k.git kernel: move mtdsplit files to drivers/mtd/mtdsplit/ to simplify maintenance, unify patches across kernel versions Signed-off-by: Felix Fietkau SVN-Revision: 43805 --- diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit.c b/target/linux/generic/files/drivers/mtd/mtdsplit.c deleted file mode 100644 index 162739f472..0000000000 --- a/target/linux/generic/files/drivers/mtd/mtdsplit.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (C) 2009-2013 Felix Fietkau - * Copyright (C) 2009-2013 Gabor Juhos - * Copyright (C) 2012 Jonas Gorski - * Copyright (C) 2013 Hauke Mehrtens - * - * 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. - * - */ - -#define pr_fmt(fmt) "mtdsplit: " fmt - -#include -#include -#include -#include -#include -#include -#include - -#include "mtdsplit.h" - -struct squashfs_super_block { - __le32 s_magic; - __le32 pad0[9]; - __le64 bytes_used; -}; - -int mtd_get_squashfs_len(struct mtd_info *master, - size_t offset, - size_t *squashfs_len) -{ - struct squashfs_super_block sb; - size_t retlen; - int err; - - err = mtd_read(master, offset, sizeof(sb), &retlen, (void *)&sb); - if (err || (retlen != sizeof(sb))) { - pr_alert("error occured while reading from \"%s\"\n", - master->name); - return -EIO; - } - - if (le32_to_cpu(sb.s_magic) != SQUASHFS_MAGIC) { - pr_alert("no squashfs found in \"%s\"\n", master->name); - return -EINVAL; - } - - retlen = le64_to_cpu(sb.bytes_used); - if (retlen <= 0) { - pr_alert("squashfs is empty in \"%s\"\n", master->name); - return -ENODEV; - } - - if (offset + retlen > master->size) { - pr_alert("squashfs has invalid size in \"%s\"\n", - master->name); - return -EINVAL; - } - - *squashfs_len = retlen; - return 0; -} -EXPORT_SYMBOL_GPL(mtd_get_squashfs_len); - -static ssize_t mtd_next_eb(struct mtd_info *mtd, size_t offset) -{ - return mtd_rounddown_to_eb(offset, mtd) + mtd->erasesize; -} - -int mtd_check_rootfs_magic(struct mtd_info *mtd, size_t offset) -{ - u32 magic; - size_t retlen; - int ret; - - ret = mtd_read(mtd, offset, sizeof(magic), &retlen, - (unsigned char *) &magic); - if (ret) - return ret; - - if (retlen != sizeof(magic)) - return -EIO; - - if (le32_to_cpu(magic) != SQUASHFS_MAGIC && - magic != 0x19852003) - return -EINVAL; - - return 0; -} -EXPORT_SYMBOL_GPL(mtd_check_rootfs_magic); - -int mtd_find_rootfs_from(struct mtd_info *mtd, - size_t from, - size_t limit, - size_t *ret_offset) -{ - size_t offset; - int err; - - for (offset = from; offset < limit; - offset = mtd_next_eb(mtd, offset)) { - err = mtd_check_rootfs_magic(mtd, offset); - if (err) - continue; - - *ret_offset = offset; - return 0; - } - - return -ENODEV; -} -EXPORT_SYMBOL_GPL(mtd_find_rootfs_from); - diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit.h b/target/linux/generic/files/drivers/mtd/mtdsplit.h deleted file mode 100644 index 7ee88b0bb4..0000000000 --- a/target/linux/generic/files/drivers/mtd/mtdsplit.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2009-2013 Felix Fietkau - * Copyright (C) 2009-2013 Gabor Juhos - * Copyright (C) 2012 Jonas Gorski - * Copyright (C) 2013 Hauke Mehrtens - * - * 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. - * - */ - -#ifndef _MTDSPLIT_H -#define _MTDSPLIT_H - -#define KERNEL_PART_NAME "kernel" -#define ROOTFS_PART_NAME "rootfs" - -#define ROOTFS_SPLIT_NAME "rootfs_data" - -#ifdef CONFIG_MTD_SPLIT -int mtd_get_squashfs_len(struct mtd_info *master, - size_t offset, - size_t *squashfs_len); - -int mtd_check_rootfs_magic(struct mtd_info *mtd, size_t offset); - -int mtd_find_rootfs_from(struct mtd_info *mtd, - size_t from, - size_t limit, - size_t *ret_offset); - -#else -static inline int mtd_get_squashfs_len(struct mtd_info *master, - size_t offset, - size_t *squashfs_len) -{ - return -ENODEV; -} - -static inline int mtd_check_rootfs_magic(struct mtd_info *mtd, size_t offset) -{ - return -EINVAL; -} - -static inline int mtd_find_rootfs_from(struct mtd_info *mtd, - size_t from, - size_t limit, - size_t *ret_offset) -{ - return -ENODEV; -} -#endif /* CONFIG_MTD_SPLIT */ - -#endif /* _MTDSPLIT_H */ diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/Kconfig b/target/linux/generic/files/drivers/mtd/mtdsplit/Kconfig index 09794f4f84..9a32daadc8 100644 --- a/target/linux/generic/files/drivers/mtd/mtdsplit/Kconfig +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/Kconfig @@ -1,7 +1,16 @@ +config MTD_SPLIT + def_bool n + help + Generic MTD split support. + +config MTD_SPLIT_SUPPORT + def_bool MTD = y + comment "Rootfs partition parsers" config MTD_SPLIT_SQUASHFS_ROOT bool "Squashfs based root partition parser" + depends on MTD_SPLIT_SUPPORT select MTD_SPLIT default n help @@ -13,12 +22,15 @@ comment "Firmware partition parsers" config MTD_SPLIT_SEAMA_FW bool "Seama firmware parser" + depends on MTD_SPLIT_SUPPORT select MTD_SPLIT config MTD_SPLIT_UIMAGE_FW bool "uImage based firmware partition parser" + depends on MTD_SPLIT_SUPPORT select MTD_SPLIT config MTD_SPLIT_LZMA_FW bool "LZMA compressed kernel 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 new file mode 100644 index 0000000000..41bc1dec10 --- /dev/null +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/Makefile @@ -0,0 +1,5 @@ +obj-$(CONFIG_MTD_SPLIT) += mtdsplit.o +obj-$(CONFIG_MTD_SPLIT_SEAMA_FW) += mtdsplit_seama.o +obj-$(CONFIG_MTD_SPLIT_SQUASHFS_ROOT) += mtdsplit_squashfs.o +obj-$(CONFIG_MTD_SPLIT_UIMAGE_FW) += mtdsplit_uimage.o +obj-$(CONFIG_MTD_SPLIT_LZMA_FW) += mtdsplit_lzma.o diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.c new file mode 100644 index 0000000000..162739f472 --- /dev/null +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.c @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2009-2013 Felix Fietkau + * Copyright (C) 2009-2013 Gabor Juhos + * Copyright (C) 2012 Jonas Gorski + * Copyright (C) 2013 Hauke Mehrtens + * + * 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. + * + */ + +#define pr_fmt(fmt) "mtdsplit: " fmt + +#include +#include +#include +#include +#include +#include +#include + +#include "mtdsplit.h" + +struct squashfs_super_block { + __le32 s_magic; + __le32 pad0[9]; + __le64 bytes_used; +}; + +int mtd_get_squashfs_len(struct mtd_info *master, + size_t offset, + size_t *squashfs_len) +{ + struct squashfs_super_block sb; + size_t retlen; + int err; + + err = mtd_read(master, offset, sizeof(sb), &retlen, (void *)&sb); + if (err || (retlen != sizeof(sb))) { + pr_alert("error occured while reading from \"%s\"\n", + master->name); + return -EIO; + } + + if (le32_to_cpu(sb.s_magic) != SQUASHFS_MAGIC) { + pr_alert("no squashfs found in \"%s\"\n", master->name); + return -EINVAL; + } + + retlen = le64_to_cpu(sb.bytes_used); + if (retlen <= 0) { + pr_alert("squashfs is empty in \"%s\"\n", master->name); + return -ENODEV; + } + + if (offset + retlen > master->size) { + pr_alert("squashfs has invalid size in \"%s\"\n", + master->name); + return -EINVAL; + } + + *squashfs_len = retlen; + return 0; +} +EXPORT_SYMBOL_GPL(mtd_get_squashfs_len); + +static ssize_t mtd_next_eb(struct mtd_info *mtd, size_t offset) +{ + return mtd_rounddown_to_eb(offset, mtd) + mtd->erasesize; +} + +int mtd_check_rootfs_magic(struct mtd_info *mtd, size_t offset) +{ + u32 magic; + size_t retlen; + int ret; + + ret = mtd_read(mtd, offset, sizeof(magic), &retlen, + (unsigned char *) &magic); + if (ret) + return ret; + + if (retlen != sizeof(magic)) + return -EIO; + + if (le32_to_cpu(magic) != SQUASHFS_MAGIC && + magic != 0x19852003) + return -EINVAL; + + return 0; +} +EXPORT_SYMBOL_GPL(mtd_check_rootfs_magic); + +int mtd_find_rootfs_from(struct mtd_info *mtd, + size_t from, + size_t limit, + size_t *ret_offset) +{ + size_t offset; + int err; + + for (offset = from; offset < limit; + offset = mtd_next_eb(mtd, offset)) { + err = mtd_check_rootfs_magic(mtd, offset); + if (err) + continue; + + *ret_offset = offset; + return 0; + } + + return -ENODEV; +} +EXPORT_SYMBOL_GPL(mtd_find_rootfs_from); + diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.h b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.h new file mode 100644 index 0000000000..7ee88b0bb4 --- /dev/null +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2009-2013 Felix Fietkau + * Copyright (C) 2009-2013 Gabor Juhos + * Copyright (C) 2012 Jonas Gorski + * Copyright (C) 2013 Hauke Mehrtens + * + * 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. + * + */ + +#ifndef _MTDSPLIT_H +#define _MTDSPLIT_H + +#define KERNEL_PART_NAME "kernel" +#define ROOTFS_PART_NAME "rootfs" + +#define ROOTFS_SPLIT_NAME "rootfs_data" + +#ifdef CONFIG_MTD_SPLIT +int mtd_get_squashfs_len(struct mtd_info *master, + size_t offset, + size_t *squashfs_len); + +int mtd_check_rootfs_magic(struct mtd_info *mtd, size_t offset); + +int mtd_find_rootfs_from(struct mtd_info *mtd, + size_t from, + size_t limit, + size_t *ret_offset); + +#else +static inline int mtd_get_squashfs_len(struct mtd_info *master, + size_t offset, + size_t *squashfs_len) +{ + return -ENODEV; +} + +static inline int mtd_check_rootfs_magic(struct mtd_info *mtd, size_t offset) +{ + return -EINVAL; +} + +static inline int mtd_find_rootfs_from(struct mtd_info *mtd, + size_t from, + size_t limit, + size_t *ret_offset) +{ + return -ENODEV; +} +#endif /* CONFIG_MTD_SPLIT */ + +#endif /* _MTDSPLIT_H */ diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_lzma.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_lzma.c new file mode 100644 index 0000000000..64dc7cb31c --- /dev/null +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_lzma.c @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2014 Gabor Juhos + * + * 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 +#include +#include +#include +#include +#include + +#include + +#include "mtdsplit.h" + +#define LZMA_NR_PARTS 2 +#define LZMA_PROPERTIES_SIZE 5 + +struct lzma_header { + u8 props[LZMA_PROPERTIES_SIZE]; + u8 size_low[4]; + u8 size_high[4]; +}; + +static int mtdsplit_parse_lzma(struct mtd_info *master, + struct mtd_partition **pparts, + struct mtd_part_parser_data *data) +{ + struct lzma_header hdr; + size_t hdr_len, retlen; + size_t rootfs_offset; + u32 t; + struct mtd_partition *parts; + int err; + + hdr_len = sizeof(hdr); + err = mtd_read(master, 0, hdr_len, &retlen, (void *) &hdr); + if (err) + return err; + + if (retlen != hdr_len) + return -EIO; + + /* verify LZMA properties */ + if (hdr.props[0] >= (9 * 5 * 5)) + return -EINVAL; + + t = get_unaligned_le32(&hdr.props[1]); + if (!is_power_of_2(t)) + return -EINVAL; + + t = get_unaligned_le32(&hdr.size_high); + if (t) + return -EINVAL; + + err = mtd_find_rootfs_from(master, master->erasesize, + master->size, &rootfs_offset); + if (err) + return err; + + parts = kzalloc(LZMA_NR_PARTS * sizeof(*parts), GFP_KERNEL); + if (!parts) + return -ENOMEM; + + parts[0].name = KERNEL_PART_NAME; + parts[0].offset = 0; + parts[0].size = rootfs_offset; + + parts[1].name = ROOTFS_PART_NAME; + parts[1].offset = rootfs_offset; + parts[1].size = master->size - rootfs_offset; + + *pparts = parts; + return LZMA_NR_PARTS; +} + +static struct mtd_part_parser mtdsplit_lzma_parser = { + .owner = THIS_MODULE, + .name = "lzma-fw", + .parse_fn = mtdsplit_parse_lzma, + .type = MTD_PARSER_TYPE_FIRMWARE, +}; + +static int __init mtdsplit_lzma_init(void) +{ + register_mtd_parser(&mtdsplit_lzma_parser); + + return 0; +} + +subsys_initcall(mtdsplit_lzma_init); diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_seama.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_seama.c new file mode 100644 index 0000000000..6f21f8fb58 --- /dev/null +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_seama.c @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2013 Gabor Juhos + * + * 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 +#include +#include +#include +#include +#include +#include + +#include "mtdsplit.h" + +#define SEAMA_MAGIC 0x5EA3A417 +#define SEAMA_NR_PARTS 2 +#define SEAMA_MIN_ROOTFS_OFFS 0x80000 /* 512KiB */ + +struct seama_header { + __be32 magic; /* should always be SEAMA_MAGIC. */ + __be16 reserved; /* reserved for */ + __be16 metasize; /* size of the META data */ + __be32 size; /* size of the image */ +}; + +static int mtdsplit_parse_seama(struct mtd_info *master, + struct mtd_partition **pparts, + struct mtd_part_parser_data *data) +{ + struct seama_header hdr; + size_t hdr_len, retlen, kernel_size; + size_t rootfs_offset; + struct mtd_partition *parts; + int err; + + hdr_len = sizeof(hdr); + err = mtd_read(master, 0, hdr_len, &retlen, (void *) &hdr); + if (err) + return err; + + if (retlen != hdr_len) + return -EIO; + + /* sanity checks */ + if (be32_to_cpu(hdr.magic) != SEAMA_MAGIC) + return -EINVAL; + + kernel_size = hdr_len + be32_to_cpu(hdr.size) + + be16_to_cpu(hdr.metasize); + if (kernel_size > master->size) + return -EINVAL; + + /* Find the rootfs after the kernel. */ + err = mtd_check_rootfs_magic(master, kernel_size); + if (!err) { + rootfs_offset = kernel_size; + } else { + /* + * The size in the header might cover the rootfs as well. + * Start the search from an arbitrary offset. + */ + err = mtd_find_rootfs_from(master, SEAMA_MIN_ROOTFS_OFFS, + master->size, &rootfs_offset); + if (err) + return err; + } + + parts = kzalloc(SEAMA_NR_PARTS * sizeof(*parts), GFP_KERNEL); + if (!parts) + return -ENOMEM; + + parts[0].name = KERNEL_PART_NAME; + parts[0].offset = 0; + parts[0].size = rootfs_offset; + + parts[1].name = ROOTFS_PART_NAME; + parts[1].offset = rootfs_offset; + parts[1].size = master->size - rootfs_offset; + + *pparts = parts; + return SEAMA_NR_PARTS; +} + +static struct mtd_part_parser mtdsplit_seama_parser = { + .owner = THIS_MODULE, + .name = "seama-fw", + .parse_fn = mtdsplit_parse_seama, + .type = MTD_PARSER_TYPE_FIRMWARE, +}; + +static int __init mtdsplit_seama_init(void) +{ + register_mtd_parser(&mtdsplit_seama_parser); + + return 0; +} + +subsys_initcall(mtdsplit_seama_init); diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_squashfs.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_squashfs.c new file mode 100644 index 0000000000..3d80e078b5 --- /dev/null +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_squashfs.c @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2013 Felix Fietkau + * Copyright (C) 2013 Gabor Juhos + * + * 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. + * + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "mtdsplit.h" + +static int +mtdsplit_parse_squashfs(struct mtd_info *master, + struct mtd_partition **pparts, + struct mtd_part_parser_data *data) +{ + struct mtd_partition *part; + struct mtd_info *parent_mtd; + size_t part_offset; + size_t squashfs_len; + int err; + + err = mtd_get_squashfs_len(master, 0, &squashfs_len); + if (err) + return err; + + parent_mtd = mtdpart_get_master(master); + part_offset = mtdpart_get_offset(master); + + part = kzalloc(sizeof(*part), GFP_KERNEL); + if (!part) { + pr_alert("unable to allocate memory for \"%s\" partition\n", + ROOTFS_SPLIT_NAME); + return -ENOMEM; + } + + part->name = ROOTFS_SPLIT_NAME; + part->offset = mtd_roundup_to_eb(part_offset + squashfs_len, + parent_mtd) - part_offset; + part->size = master->size - part->offset; + + *pparts = part; + return 1; +} + +static struct mtd_part_parser mtdsplit_squashfs_parser = { + .owner = THIS_MODULE, + .name = "squashfs-split", + .parse_fn = mtdsplit_parse_squashfs, + .type = MTD_PARSER_TYPE_ROOTFS, +}; + +static int __init mtdsplit_squashfs_init(void) +{ + register_mtd_parser(&mtdsplit_squashfs_parser); + + return 0; +} + +subsys_initcall(mtdsplit_squashfs_init); diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c new file mode 100644 index 0000000000..7dad63c9bb --- /dev/null +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c @@ -0,0 +1,287 @@ +/* + * Copyright (C) 2013 Gabor Juhos + * + * 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. + * + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "mtdsplit.h" + +#define IH_MAGIC 0x27051956 /* Image Magic Number */ +#define IH_NMLEN 32 /* Image Name Length */ + +#define IH_OS_LINUX 5 /* Linux */ + +#define IH_TYPE_KERNEL 2 /* OS Kernel Image */ +#define IH_TYPE_FILESYSTEM 7 /* Filesystem Image */ + +/* + * Legacy format image header, + * all data in network byte order (aka natural aka bigendian). + */ +struct uimage_header { + uint32_t ih_magic; /* Image Header Magic Number */ + uint32_t ih_hcrc; /* Image Header CRC Checksum */ + uint32_t ih_time; /* Image Creation Timestamp */ + uint32_t ih_size; /* Image Data Size */ + uint32_t ih_load; /* Data Load Address */ + uint32_t ih_ep; /* Entry Point Address */ + uint32_t ih_dcrc; /* Image Data CRC Checksum */ + uint8_t ih_os; /* Operating System */ + uint8_t ih_arch; /* CPU architecture */ + uint8_t ih_type; /* Image Type */ + uint8_t ih_comp; /* Compression Type */ + uint8_t ih_name[IH_NMLEN]; /* Image Name */ +}; + +static int +read_uimage_header(struct mtd_info *mtd, size_t offset, + struct uimage_header *header) +{ + size_t header_len; + size_t retlen; + int ret; + + header_len = sizeof(*header); + ret = mtd_read(mtd, offset, header_len, &retlen, + (unsigned char *) header); + if (ret) { + pr_debug("read error in \"%s\"\n", mtd->name); + return ret; + } + + if (retlen != header_len) { + pr_debug("short read in \"%s\"\n", mtd->name); + return -EIO; + } + + return 0; +} + +static int __mtdsplit_parse_uimage(struct mtd_info *master, + struct mtd_partition **pparts, + struct mtd_part_parser_data *data, + bool (*verify)(struct uimage_header *hdr)) +{ + struct mtd_partition *parts; + struct uimage_header *header; + int nr_parts; + size_t offset; + size_t uimage_offset; + size_t uimage_size = 0; + size_t rootfs_offset; + size_t rootfs_size = 0; + int uimage_part, rf_part; + int ret; + + nr_parts = 2; + parts = kzalloc(nr_parts * sizeof(*parts), GFP_KERNEL); + if (!parts) + return -ENOMEM; + + header = vmalloc(sizeof(*header)); + if (!header) { + ret = -ENOMEM; + goto err_free_parts; + } + + /* find uImage on erase block boundaries */ + for (offset = 0; offset < master->size; offset += master->erasesize) { + uimage_size = 0; + + ret = read_uimage_header(master, offset, header); + if (ret) + continue; + + if (!verify(header)) { + pr_debug("no valid uImage found in \"%s\" at offset %llx\n", + master->name, (unsigned long long) offset); + continue; + } + + uimage_size = sizeof(*header) + be32_to_cpu(header->ih_size); + if ((offset + uimage_size) > master->size) { + pr_debug("uImage exceeds MTD device \"%s\"\n", + master->name); + continue; + } + break; + } + + if (uimage_size == 0) { + pr_debug("no uImage found in \"%s\"\n", master->name); + ret = -ENODEV; + goto err_free_header; + } + + uimage_offset = offset; + + if (uimage_offset == 0) { + uimage_part = 0; + rf_part = 1; + + /* find the roots after the uImage */ + ret = mtd_find_rootfs_from(master, + uimage_offset + uimage_size, + master->size, + &rootfs_offset); + if (ret) { + pr_debug("no rootfs after uImage in \"%s\"\n", + master->name); + goto err_free_header; + } + + rootfs_size = master->size - rootfs_offset; + uimage_size = rootfs_offset - uimage_offset; + } else { + rf_part = 0; + uimage_part = 1; + + /* check rootfs presence at offset 0 */ + ret = mtd_check_rootfs_magic(master, 0); + if (ret) { + pr_debug("no rootfs before uImage in \"%s\"\n", + master->name); + goto err_free_header; + } + + rootfs_offset = 0; + rootfs_size = uimage_offset; + } + + if (rootfs_size == 0) { + pr_debug("no rootfs found in \"%s\"\n", master->name); + ret = -ENODEV; + goto err_free_header; + } + + parts[uimage_part].name = KERNEL_PART_NAME; + parts[uimage_part].offset = uimage_offset; + parts[uimage_part].size = uimage_size; + + parts[rf_part].name = ROOTFS_PART_NAME; + parts[rf_part].offset = rootfs_offset; + parts[rf_part].size = rootfs_size; + + vfree(header); + + *pparts = parts; + return nr_parts; + +err_free_header: + vfree(header); + +err_free_parts: + kfree(parts); + return ret; +} + +static bool uimage_verify_default(struct uimage_header *header) +{ + /* default sanity checks */ + if (be32_to_cpu(header->ih_magic) != IH_MAGIC) { + pr_debug("invalid uImage magic: %08x\n", + be32_to_cpu(header->ih_magic)); + return false; + } + + if (header->ih_os != IH_OS_LINUX) { + pr_debug("invalid uImage OS: %08x\n", + be32_to_cpu(header->ih_os)); + return false; + } + + if (header->ih_type != IH_TYPE_KERNEL) { + pr_debug("invalid uImage type: %08x\n", + be32_to_cpu(header->ih_type)); + return false; + } + + return true; +} + +static int +mtdsplit_uimage_parse_generic(struct mtd_info *master, + struct mtd_partition **pparts, + struct mtd_part_parser_data *data) +{ + return __mtdsplit_parse_uimage(master, pparts, data, + uimage_verify_default); +} + +static struct mtd_part_parser uimage_generic_parser = { + .owner = THIS_MODULE, + .name = "uimage-fw", + .parse_fn = mtdsplit_uimage_parse_generic, + .type = MTD_PARSER_TYPE_FIRMWARE, +}; + +#define FW_MAGIC_WNR2000V3 0x32303033 +#define FW_MAGIC_WNR2000V4 0x32303034 +#define FW_MAGIC_WNR2200 0x32323030 +#define FW_MAGIC_WNR612V2 0x32303631 +#define FW_MAGIC_WNDR3700 0x33373030 +#define FW_MAGIC_WNDR3700V2 0x33373031 + +static bool uimage_verify_wndr3700(struct uimage_header *header) +{ + uint8_t expected_type = IH_TYPE_FILESYSTEM; + switch be32_to_cpu(header->ih_magic) { + case FW_MAGIC_WNR612V2: + case FW_MAGIC_WNR2000V3: + case FW_MAGIC_WNR2200: + case FW_MAGIC_WNDR3700: + case FW_MAGIC_WNDR3700V2: + break; + case FW_MAGIC_WNR2000V4: + expected_type = IH_TYPE_KERNEL; + break; + default: + return false; + } + + if (header->ih_os != IH_OS_LINUX || + header->ih_type != expected_type) + return false; + + return true; +} + +static int +mtdsplit_uimage_parse_netgear(struct mtd_info *master, + struct mtd_partition **pparts, + struct mtd_part_parser_data *data) +{ + return __mtdsplit_parse_uimage(master, pparts, data, + uimage_verify_wndr3700); +} + +static struct mtd_part_parser uimage_netgear_parser = { + .owner = THIS_MODULE, + .name = "netgear-fw", + .parse_fn = mtdsplit_uimage_parse_netgear, + .type = MTD_PARSER_TYPE_FIRMWARE, +}; + +static int __init mtdsplit_uimage_init(void) +{ + register_mtd_parser(&uimage_generic_parser); + register_mtd_parser(&uimage_netgear_parser); + + return 0; +} + +module_init(mtdsplit_uimage_init); diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit_lzma.c b/target/linux/generic/files/drivers/mtd/mtdsplit_lzma.c deleted file mode 100644 index 64dc7cb31c..0000000000 --- a/target/linux/generic/files/drivers/mtd/mtdsplit_lzma.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2014 Gabor Juhos - * - * 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 -#include -#include -#include -#include -#include - -#include - -#include "mtdsplit.h" - -#define LZMA_NR_PARTS 2 -#define LZMA_PROPERTIES_SIZE 5 - -struct lzma_header { - u8 props[LZMA_PROPERTIES_SIZE]; - u8 size_low[4]; - u8 size_high[4]; -}; - -static int mtdsplit_parse_lzma(struct mtd_info *master, - struct mtd_partition **pparts, - struct mtd_part_parser_data *data) -{ - struct lzma_header hdr; - size_t hdr_len, retlen; - size_t rootfs_offset; - u32 t; - struct mtd_partition *parts; - int err; - - hdr_len = sizeof(hdr); - err = mtd_read(master, 0, hdr_len, &retlen, (void *) &hdr); - if (err) - return err; - - if (retlen != hdr_len) - return -EIO; - - /* verify LZMA properties */ - if (hdr.props[0] >= (9 * 5 * 5)) - return -EINVAL; - - t = get_unaligned_le32(&hdr.props[1]); - if (!is_power_of_2(t)) - return -EINVAL; - - t = get_unaligned_le32(&hdr.size_high); - if (t) - return -EINVAL; - - err = mtd_find_rootfs_from(master, master->erasesize, - master->size, &rootfs_offset); - if (err) - return err; - - parts = kzalloc(LZMA_NR_PARTS * sizeof(*parts), GFP_KERNEL); - if (!parts) - return -ENOMEM; - - parts[0].name = KERNEL_PART_NAME; - parts[0].offset = 0; - parts[0].size = rootfs_offset; - - parts[1].name = ROOTFS_PART_NAME; - parts[1].offset = rootfs_offset; - parts[1].size = master->size - rootfs_offset; - - *pparts = parts; - return LZMA_NR_PARTS; -} - -static struct mtd_part_parser mtdsplit_lzma_parser = { - .owner = THIS_MODULE, - .name = "lzma-fw", - .parse_fn = mtdsplit_parse_lzma, - .type = MTD_PARSER_TYPE_FIRMWARE, -}; - -static int __init mtdsplit_lzma_init(void) -{ - register_mtd_parser(&mtdsplit_lzma_parser); - - return 0; -} - -subsys_initcall(mtdsplit_lzma_init); diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit_seama.c b/target/linux/generic/files/drivers/mtd/mtdsplit_seama.c deleted file mode 100644 index 6f21f8fb58..0000000000 --- a/target/linux/generic/files/drivers/mtd/mtdsplit_seama.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (C) 2013 Gabor Juhos - * - * 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 -#include -#include -#include -#include -#include -#include - -#include "mtdsplit.h" - -#define SEAMA_MAGIC 0x5EA3A417 -#define SEAMA_NR_PARTS 2 -#define SEAMA_MIN_ROOTFS_OFFS 0x80000 /* 512KiB */ - -struct seama_header { - __be32 magic; /* should always be SEAMA_MAGIC. */ - __be16 reserved; /* reserved for */ - __be16 metasize; /* size of the META data */ - __be32 size; /* size of the image */ -}; - -static int mtdsplit_parse_seama(struct mtd_info *master, - struct mtd_partition **pparts, - struct mtd_part_parser_data *data) -{ - struct seama_header hdr; - size_t hdr_len, retlen, kernel_size; - size_t rootfs_offset; - struct mtd_partition *parts; - int err; - - hdr_len = sizeof(hdr); - err = mtd_read(master, 0, hdr_len, &retlen, (void *) &hdr); - if (err) - return err; - - if (retlen != hdr_len) - return -EIO; - - /* sanity checks */ - if (be32_to_cpu(hdr.magic) != SEAMA_MAGIC) - return -EINVAL; - - kernel_size = hdr_len + be32_to_cpu(hdr.size) + - be16_to_cpu(hdr.metasize); - if (kernel_size > master->size) - return -EINVAL; - - /* Find the rootfs after the kernel. */ - err = mtd_check_rootfs_magic(master, kernel_size); - if (!err) { - rootfs_offset = kernel_size; - } else { - /* - * The size in the header might cover the rootfs as well. - * Start the search from an arbitrary offset. - */ - err = mtd_find_rootfs_from(master, SEAMA_MIN_ROOTFS_OFFS, - master->size, &rootfs_offset); - if (err) - return err; - } - - parts = kzalloc(SEAMA_NR_PARTS * sizeof(*parts), GFP_KERNEL); - if (!parts) - return -ENOMEM; - - parts[0].name = KERNEL_PART_NAME; - parts[0].offset = 0; - parts[0].size = rootfs_offset; - - parts[1].name = ROOTFS_PART_NAME; - parts[1].offset = rootfs_offset; - parts[1].size = master->size - rootfs_offset; - - *pparts = parts; - return SEAMA_NR_PARTS; -} - -static struct mtd_part_parser mtdsplit_seama_parser = { - .owner = THIS_MODULE, - .name = "seama-fw", - .parse_fn = mtdsplit_parse_seama, - .type = MTD_PARSER_TYPE_FIRMWARE, -}; - -static int __init mtdsplit_seama_init(void) -{ - register_mtd_parser(&mtdsplit_seama_parser); - - return 0; -} - -subsys_initcall(mtdsplit_seama_init); diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit_squashfs.c b/target/linux/generic/files/drivers/mtd/mtdsplit_squashfs.c deleted file mode 100644 index 3d80e078b5..0000000000 --- a/target/linux/generic/files/drivers/mtd/mtdsplit_squashfs.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2013 Felix Fietkau - * Copyright (C) 2013 Gabor Juhos - * - * 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. - * - */ - -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "mtdsplit.h" - -static int -mtdsplit_parse_squashfs(struct mtd_info *master, - struct mtd_partition **pparts, - struct mtd_part_parser_data *data) -{ - struct mtd_partition *part; - struct mtd_info *parent_mtd; - size_t part_offset; - size_t squashfs_len; - int err; - - err = mtd_get_squashfs_len(master, 0, &squashfs_len); - if (err) - return err; - - parent_mtd = mtdpart_get_master(master); - part_offset = mtdpart_get_offset(master); - - part = kzalloc(sizeof(*part), GFP_KERNEL); - if (!part) { - pr_alert("unable to allocate memory for \"%s\" partition\n", - ROOTFS_SPLIT_NAME); - return -ENOMEM; - } - - part->name = ROOTFS_SPLIT_NAME; - part->offset = mtd_roundup_to_eb(part_offset + squashfs_len, - parent_mtd) - part_offset; - part->size = master->size - part->offset; - - *pparts = part; - return 1; -} - -static struct mtd_part_parser mtdsplit_squashfs_parser = { - .owner = THIS_MODULE, - .name = "squashfs-split", - .parse_fn = mtdsplit_parse_squashfs, - .type = MTD_PARSER_TYPE_ROOTFS, -}; - -static int __init mtdsplit_squashfs_init(void) -{ - register_mtd_parser(&mtdsplit_squashfs_parser); - - return 0; -} - -subsys_initcall(mtdsplit_squashfs_init); diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit_uimage.c b/target/linux/generic/files/drivers/mtd/mtdsplit_uimage.c deleted file mode 100644 index 7dad63c9bb..0000000000 --- a/target/linux/generic/files/drivers/mtd/mtdsplit_uimage.c +++ /dev/null @@ -1,287 +0,0 @@ -/* - * Copyright (C) 2013 Gabor Juhos - * - * 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. - * - */ - -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "mtdsplit.h" - -#define IH_MAGIC 0x27051956 /* Image Magic Number */ -#define IH_NMLEN 32 /* Image Name Length */ - -#define IH_OS_LINUX 5 /* Linux */ - -#define IH_TYPE_KERNEL 2 /* OS Kernel Image */ -#define IH_TYPE_FILESYSTEM 7 /* Filesystem Image */ - -/* - * Legacy format image header, - * all data in network byte order (aka natural aka bigendian). - */ -struct uimage_header { - uint32_t ih_magic; /* Image Header Magic Number */ - uint32_t ih_hcrc; /* Image Header CRC Checksum */ - uint32_t ih_time; /* Image Creation Timestamp */ - uint32_t ih_size; /* Image Data Size */ - uint32_t ih_load; /* Data Load Address */ - uint32_t ih_ep; /* Entry Point Address */ - uint32_t ih_dcrc; /* Image Data CRC Checksum */ - uint8_t ih_os; /* Operating System */ - uint8_t ih_arch; /* CPU architecture */ - uint8_t ih_type; /* Image Type */ - uint8_t ih_comp; /* Compression Type */ - uint8_t ih_name[IH_NMLEN]; /* Image Name */ -}; - -static int -read_uimage_header(struct mtd_info *mtd, size_t offset, - struct uimage_header *header) -{ - size_t header_len; - size_t retlen; - int ret; - - header_len = sizeof(*header); - ret = mtd_read(mtd, offset, header_len, &retlen, - (unsigned char *) header); - if (ret) { - pr_debug("read error in \"%s\"\n", mtd->name); - return ret; - } - - if (retlen != header_len) { - pr_debug("short read in \"%s\"\n", mtd->name); - return -EIO; - } - - return 0; -} - -static int __mtdsplit_parse_uimage(struct mtd_info *master, - struct mtd_partition **pparts, - struct mtd_part_parser_data *data, - bool (*verify)(struct uimage_header *hdr)) -{ - struct mtd_partition *parts; - struct uimage_header *header; - int nr_parts; - size_t offset; - size_t uimage_offset; - size_t uimage_size = 0; - size_t rootfs_offset; - size_t rootfs_size = 0; - int uimage_part, rf_part; - int ret; - - nr_parts = 2; - parts = kzalloc(nr_parts * sizeof(*parts), GFP_KERNEL); - if (!parts) - return -ENOMEM; - - header = vmalloc(sizeof(*header)); - if (!header) { - ret = -ENOMEM; - goto err_free_parts; - } - - /* find uImage on erase block boundaries */ - for (offset = 0; offset < master->size; offset += master->erasesize) { - uimage_size = 0; - - ret = read_uimage_header(master, offset, header); - if (ret) - continue; - - if (!verify(header)) { - pr_debug("no valid uImage found in \"%s\" at offset %llx\n", - master->name, (unsigned long long) offset); - continue; - } - - uimage_size = sizeof(*header) + be32_to_cpu(header->ih_size); - if ((offset + uimage_size) > master->size) { - pr_debug("uImage exceeds MTD device \"%s\"\n", - master->name); - continue; - } - break; - } - - if (uimage_size == 0) { - pr_debug("no uImage found in \"%s\"\n", master->name); - ret = -ENODEV; - goto err_free_header; - } - - uimage_offset = offset; - - if (uimage_offset == 0) { - uimage_part = 0; - rf_part = 1; - - /* find the roots after the uImage */ - ret = mtd_find_rootfs_from(master, - uimage_offset + uimage_size, - master->size, - &rootfs_offset); - if (ret) { - pr_debug("no rootfs after uImage in \"%s\"\n", - master->name); - goto err_free_header; - } - - rootfs_size = master->size - rootfs_offset; - uimage_size = rootfs_offset - uimage_offset; - } else { - rf_part = 0; - uimage_part = 1; - - /* check rootfs presence at offset 0 */ - ret = mtd_check_rootfs_magic(master, 0); - if (ret) { - pr_debug("no rootfs before uImage in \"%s\"\n", - master->name); - goto err_free_header; - } - - rootfs_offset = 0; - rootfs_size = uimage_offset; - } - - if (rootfs_size == 0) { - pr_debug("no rootfs found in \"%s\"\n", master->name); - ret = -ENODEV; - goto err_free_header; - } - - parts[uimage_part].name = KERNEL_PART_NAME; - parts[uimage_part].offset = uimage_offset; - parts[uimage_part].size = uimage_size; - - parts[rf_part].name = ROOTFS_PART_NAME; - parts[rf_part].offset = rootfs_offset; - parts[rf_part].size = rootfs_size; - - vfree(header); - - *pparts = parts; - return nr_parts; - -err_free_header: - vfree(header); - -err_free_parts: - kfree(parts); - return ret; -} - -static bool uimage_verify_default(struct uimage_header *header) -{ - /* default sanity checks */ - if (be32_to_cpu(header->ih_magic) != IH_MAGIC) { - pr_debug("invalid uImage magic: %08x\n", - be32_to_cpu(header->ih_magic)); - return false; - } - - if (header->ih_os != IH_OS_LINUX) { - pr_debug("invalid uImage OS: %08x\n", - be32_to_cpu(header->ih_os)); - return false; - } - - if (header->ih_type != IH_TYPE_KERNEL) { - pr_debug("invalid uImage type: %08x\n", - be32_to_cpu(header->ih_type)); - return false; - } - - return true; -} - -static int -mtdsplit_uimage_parse_generic(struct mtd_info *master, - struct mtd_partition **pparts, - struct mtd_part_parser_data *data) -{ - return __mtdsplit_parse_uimage(master, pparts, data, - uimage_verify_default); -} - -static struct mtd_part_parser uimage_generic_parser = { - .owner = THIS_MODULE, - .name = "uimage-fw", - .parse_fn = mtdsplit_uimage_parse_generic, - .type = MTD_PARSER_TYPE_FIRMWARE, -}; - -#define FW_MAGIC_WNR2000V3 0x32303033 -#define FW_MAGIC_WNR2000V4 0x32303034 -#define FW_MAGIC_WNR2200 0x32323030 -#define FW_MAGIC_WNR612V2 0x32303631 -#define FW_MAGIC_WNDR3700 0x33373030 -#define FW_MAGIC_WNDR3700V2 0x33373031 - -static bool uimage_verify_wndr3700(struct uimage_header *header) -{ - uint8_t expected_type = IH_TYPE_FILESYSTEM; - switch be32_to_cpu(header->ih_magic) { - case FW_MAGIC_WNR612V2: - case FW_MAGIC_WNR2000V3: - case FW_MAGIC_WNR2200: - case FW_MAGIC_WNDR3700: - case FW_MAGIC_WNDR3700V2: - break; - case FW_MAGIC_WNR2000V4: - expected_type = IH_TYPE_KERNEL; - break; - default: - return false; - } - - if (header->ih_os != IH_OS_LINUX || - header->ih_type != expected_type) - return false; - - return true; -} - -static int -mtdsplit_uimage_parse_netgear(struct mtd_info *master, - struct mtd_partition **pparts, - struct mtd_part_parser_data *data) -{ - return __mtdsplit_parse_uimage(master, pparts, data, - uimage_verify_wndr3700); -} - -static struct mtd_part_parser uimage_netgear_parser = { - .owner = THIS_MODULE, - .name = "netgear-fw", - .parse_fn = mtdsplit_uimage_parse_netgear, - .type = MTD_PARSER_TYPE_FIRMWARE, -}; - -static int __init mtdsplit_uimage_init(void) -{ - register_mtd_parser(&uimage_generic_parser); - register_mtd_parser(&uimage_netgear_parser); - - return 0; -} - -module_init(mtdsplit_uimage_init); diff --git a/target/linux/generic/patches-3.10/400-mtd-add-rootfs-split-support.patch b/target/linux/generic/patches-3.10/400-mtd-add-rootfs-split-support.patch index 6c17b01e53..e14e7c094b 100644 --- a/target/linux/generic/patches-3.10/400-mtd-add-rootfs-split-support.patch +++ b/target/linux/generic/patches-3.10/400-mtd-add-rootfs-split-support.patch @@ -35,7 +35,7 @@ depends on m --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c -@@ -29,6 +29,7 @@ +@@ -29,9 +29,11 @@ #include #include #include @@ -43,7 +43,11 @@ #include #include "mtdcore.h" -@@ -45,13 +46,14 @@ struct mtd_part { ++#include "mtdsplit/mtdsplit.h" + + /* Our partition linked list */ + static LIST_HEAD(mtd_partitions); +@@ -45,13 +47,14 @@ struct mtd_part { struct list_head list; }; @@ -59,7 +63,7 @@ /* * MTD methods which simply translate the effective address and pass through * to the _real_ device. -@@ -533,8 +535,10 @@ out_register: +@@ -533,8 +536,10 @@ out_register: return slave; } @@ -72,7 +76,7 @@ { struct mtd_partition part; struct mtd_part *p, *new; -@@ -566,21 +570,24 @@ int mtd_add_partition(struct mtd_info *m +@@ -566,21 +571,24 @@ int mtd_add_partition(struct mtd_info *m end = offset + length; mutex_lock(&mtd_partitions_mutex); @@ -107,7 +111,7 @@ return ret; err_inv: -@@ -590,6 +597,12 @@ err_inv: +@@ -590,6 +598,12 @@ err_inv: } EXPORT_SYMBOL_GPL(mtd_add_partition); @@ -120,7 +124,7 @@ int mtd_del_partition(struct mtd_info *master, int partno) { struct mtd_part *slave, *next; -@@ -613,6 +626,144 @@ int mtd_del_partition(struct mtd_info *m +@@ -613,6 +627,144 @@ int mtd_del_partition(struct mtd_info *m } EXPORT_SYMBOL_GPL(mtd_del_partition); @@ -265,7 +269,7 @@ /* * This function, given a master MTD object and a partition table, creates * and registers slave MTD objects which are bound to the master according to -@@ -642,6 +793,7 @@ int add_mtd_partitions(struct mtd_info * +@@ -642,6 +794,7 @@ int add_mtd_partitions(struct mtd_info * mutex_unlock(&mtd_partitions_mutex); add_mtd_device(&slave->mtd); diff --git a/target/linux/generic/patches-3.10/401-mtd-add-support-for-different-partition-parser-types.patch b/target/linux/generic/patches-3.10/401-mtd-add-support-for-different-partition-parser-types.patch index bd35aa7d35..52b87f56cc 100644 --- a/target/linux/generic/patches-3.10/401-mtd-add-support-for-different-partition-parser-types.patch +++ b/target/linux/generic/patches-3.10/401-mtd-add-support-for-different-partition-parser-types.patch @@ -11,7 +11,7 @@ Signed-off-by: Gabor Juhos --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c -@@ -823,6 +823,30 @@ static struct mtd_part_parser *get_parti +@@ -824,6 +824,30 @@ static struct mtd_part_parser *get_parti #define put_partition_parser(p) do { module_put((p)->owner); } while (0) @@ -42,7 +42,7 @@ Signed-off-by: Gabor Juhos int register_mtd_parser(struct mtd_part_parser *p) { spin_lock(&part_parser_lock); -@@ -899,6 +923,38 @@ int parse_mtd_partitions(struct mtd_info +@@ -900,6 +924,38 @@ int parse_mtd_partitions(struct mtd_info return ret; } diff --git a/target/linux/generic/patches-3.10/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch b/target/linux/generic/patches-3.10/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch index 649693ff22..a614094851 100644 --- a/target/linux/generic/patches-3.10/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch +++ b/target/linux/generic/patches-3.10/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch @@ -1,6 +1,6 @@ --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c -@@ -626,6 +626,37 @@ int mtd_del_partition(struct mtd_info *m +@@ -627,6 +627,37 @@ int mtd_del_partition(struct mtd_info *m } EXPORT_SYMBOL_GPL(mtd_del_partition); @@ -38,7 +38,7 @@ static inline unsigned long mtd_pad_erasesize(struct mtd_info *mtd, int offset, int len) { -@@ -685,6 +716,10 @@ static void split_rootfs_data(struct mtd +@@ -686,6 +717,10 @@ static void split_rootfs_data(struct mtd unsigned int split_size; int ret; @@ -49,7 +49,7 @@ ret = split_squashfs(master, part->offset, &split_offset); if (ret) return; -@@ -734,6 +769,12 @@ static void split_uimage(struct mtd_info +@@ -735,6 +770,12 @@ static void split_uimage(struct mtd_info static void split_firmware(struct mtd_info *master, struct mtd_part *part) { diff --git a/target/linux/generic/patches-3.10/403-mtd-hook-mtdsplit-to-Kbuild.patch b/target/linux/generic/patches-3.10/403-mtd-hook-mtdsplit-to-Kbuild.patch index c24f34c5cc..23cbd6243c 100644 --- a/target/linux/generic/patches-3.10/403-mtd-hook-mtdsplit-to-Kbuild.patch +++ b/target/linux/generic/patches-3.10/403-mtd-hook-mtdsplit-to-Kbuild.patch @@ -1,13 +1,10 @@ --- a/drivers/mtd/Kconfig +++ b/drivers/mtd/Kconfig -@@ -36,6 +36,11 @@ config MTD_UIMAGE_SPLIT +@@ -36,6 +36,8 @@ config MTD_UIMAGE_SPLIT depends on MTD_SPLIT_FIRMWARE default y -+config MTD_SPLIT -+ def_bool n -+ help -+ Generic MTD split support. ++source "drivers/mtd/mtdsplit/Kconfig" + endmenu @@ -18,7 +15,7 @@ obj-$(CONFIG_MTD) += mtd.o mtd-y := mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o mtdchar.o -+mtd-$(CONFIG_MTD_SPLIT) += mtdsplit.o ++obj-$(CONFIG_MTD_SPLIT) += mtdsplit/ + obj-$(CONFIG_MTD_OF_PARTS) += ofpart.o obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o diff --git a/target/linux/generic/patches-3.10/404-mtd-use-mtd_get_squashfs_len-in-split_squasfh.patch b/target/linux/generic/patches-3.10/404-mtd-use-mtd_get_squashfs_len-in-split_squasfh.patch index 02e4e038c2..e4dd1e4852 100644 --- a/target/linux/generic/patches-3.10/404-mtd-use-mtd_get_squashfs_len-in-split_squasfh.patch +++ b/target/linux/generic/patches-3.10/404-mtd-use-mtd_get_squashfs_len-in-split_squasfh.patch @@ -1,14 +1,6 @@ --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c -@@ -33,6 +33,7 @@ - #include - - #include "mtdcore.h" -+#include "mtdsplit.h" - - /* Our partition linked list */ - static LIST_HEAD(mtd_partitions); -@@ -668,43 +669,16 @@ mtd_pad_erasesize(struct mtd_info *mtd, +@@ -669,43 +669,16 @@ mtd_pad_erasesize(struct mtd_info *mtd, return len; } diff --git a/target/linux/generic/patches-3.10/406-mtd-add-squashfs-parser.patch b/target/linux/generic/patches-3.10/406-mtd-add-squashfs-parser.patch deleted file mode 100644 index b3ff9d9ab2..0000000000 --- a/target/linux/generic/patches-3.10/406-mtd-add-squashfs-parser.patch +++ /dev/null @@ -1,30 +0,0 @@ ---- a/drivers/mtd/Kconfig -+++ b/drivers/mtd/Kconfig -@@ -37,6 +37,17 @@ config MTD_UIMAGE_SPLIT - depends on MTD_SPLIT_FIRMWARE - default y - -+comment "Rootfs partition parsers" -+ -+config MTD_SPLIT_SQUASHFS_ROOT -+ bool "Squashfs based root partition parser" -+ select MTD_SPLIT -+ default n -+ help -+ This provides a parsing function which allows to detect the -+ offset and size of the unused portion of a rootfs partition -+ containing a squashfs. -+ - config MTD_SPLIT - def_bool n - help ---- a/drivers/mtd/Makefile -+++ b/drivers/mtd/Makefile -@@ -7,6 +7,7 @@ obj-$(CONFIG_MTD) += mtd.o - mtd-y := mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o mtdchar.o - - mtd-$(CONFIG_MTD_SPLIT) += mtdsplit.o -+mtd-$(CONFIG_MTD_SPLIT_SQUASHFS_ROOT) += mtdsplit_squashfs.o - - obj-$(CONFIG_MTD_OF_PARTS) += ofpart.o - obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o diff --git a/target/linux/generic/patches-3.10/407-mtd-hook-mtdsplit_uimage-into-Kbuild.patch b/target/linux/generic/patches-3.10/407-mtd-hook-mtdsplit_uimage-into-Kbuild.patch deleted file mode 100644 index 02697f64eb..0000000000 --- a/target/linux/generic/patches-3.10/407-mtd-hook-mtdsplit_uimage-into-Kbuild.patch +++ /dev/null @@ -1,25 +0,0 @@ ---- a/drivers/mtd/Kconfig -+++ b/drivers/mtd/Kconfig -@@ -48,6 +48,12 @@ config MTD_SPLIT_SQUASHFS_ROOT - offset and size of the unused portion of a rootfs partition - containing a squashfs. - -+comment "Firmware partition parsers" -+ -+config MTD_SPLIT_UIMAGE_FW -+ bool "uImage based firmware partition parser" -+ select MTD_SPLIT -+ - config MTD_SPLIT - def_bool n - help ---- a/drivers/mtd/Makefile -+++ b/drivers/mtd/Makefile -@@ -8,6 +8,7 @@ mtd-y := mtdcore.o mtdsuper.o mtdconc - - mtd-$(CONFIG_MTD_SPLIT) += mtdsplit.o - mtd-$(CONFIG_MTD_SPLIT_SQUASHFS_ROOT) += mtdsplit_squashfs.o -+mtd-$(CONFIG_MTD_SPLIT_UIMAGE_FW) += mtdsplit_uimage.o - - obj-$(CONFIG_MTD_OF_PARTS) += ofpart.o - obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o diff --git a/target/linux/generic/patches-3.10/408-mtd-hook-mtdsplit_seama-into-Kbuild.patch b/target/linux/generic/patches-3.10/408-mtd-hook-mtdsplit_seama-into-Kbuild.patch deleted file mode 100644 index 016a9b6e4c..0000000000 --- a/target/linux/generic/patches-3.10/408-mtd-hook-mtdsplit_seama-into-Kbuild.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- a/drivers/mtd/Kconfig -+++ b/drivers/mtd/Kconfig -@@ -50,6 +50,10 @@ config MTD_SPLIT_SQUASHFS_ROOT - - comment "Firmware partition parsers" - -+config MTD_SPLIT_SEAMA_FW -+ bool "Seama firmware parser" -+ select MTD_SPLIT -+ - config MTD_SPLIT_UIMAGE_FW - bool "uImage based firmware partition parser" - select MTD_SPLIT ---- a/drivers/mtd/Makefile -+++ b/drivers/mtd/Makefile -@@ -7,6 +7,7 @@ obj-$(CONFIG_MTD) += mtd.o - mtd-y := mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o mtdchar.o - - mtd-$(CONFIG_MTD_SPLIT) += mtdsplit.o -+mtd-$(CONFIG_MTD_SPLIT_SEAMA_FW) += mtdsplit_seama.o - mtd-$(CONFIG_MTD_SPLIT_SQUASHFS_ROOT) += mtdsplit_squashfs.o - mtd-$(CONFIG_MTD_SPLIT_UIMAGE_FW) += mtdsplit_uimage.o - diff --git a/target/linux/generic/patches-3.10/409-mtd-hook-mtdsplit_lzma-into-Kbuild.patch b/target/linux/generic/patches-3.10/409-mtd-hook-mtdsplit_lzma-into-Kbuild.patch deleted file mode 100644 index cc9a971573..0000000000 --- a/target/linux/generic/patches-3.10/409-mtd-hook-mtdsplit_lzma-into-Kbuild.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- a/drivers/mtd/Kconfig -+++ b/drivers/mtd/Kconfig -@@ -58,6 +58,10 @@ config MTD_SPLIT_UIMAGE_FW - bool "uImage based firmware partition parser" - select MTD_SPLIT - -+config MTD_SPLIT_LZMA_FW -+ bool "LZMA compressed kernel based firmware partition parser" -+ select MTD_SPLIT -+ - config MTD_SPLIT - def_bool n - help ---- a/drivers/mtd/Makefile -+++ b/drivers/mtd/Makefile -@@ -10,6 +10,7 @@ mtd-$(CONFIG_MTD_SPLIT) += mtdsplit.o - mtd-$(CONFIG_MTD_SPLIT_SEAMA_FW) += mtdsplit_seama.o - mtd-$(CONFIG_MTD_SPLIT_SQUASHFS_ROOT) += mtdsplit_squashfs.o - mtd-$(CONFIG_MTD_SPLIT_UIMAGE_FW) += mtdsplit_uimage.o -+mtd-$(CONFIG_MTD_SPLIT_LZMA_FW) += mtdsplit_lzma.o - - obj-$(CONFIG_MTD_OF_PARTS) += ofpart.o - obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o diff --git a/target/linux/generic/patches-3.10/411-mtd-partial_eraseblock_write.patch b/target/linux/generic/patches-3.10/411-mtd-partial_eraseblock_write.patch index 9407411207..31d126c0a6 100644 --- a/target/linux/generic/patches-3.10/411-mtd-partial_eraseblock_write.patch +++ b/target/linux/generic/patches-3.10/411-mtd-partial_eraseblock_write.patch @@ -2,7 +2,7 @@ +++ b/drivers/mtd/mtdpart.c @@ -35,6 +35,8 @@ #include "mtdcore.h" - #include "mtdsplit.h" + #include "mtdsplit/mtdsplit.h" +#define MTD_ERASE_PARTIAL 0x8000 /* partition only covers parts of an erase block */ + diff --git a/target/linux/generic/patches-3.10/430-mtd-add-myloader-partition-parser.patch b/target/linux/generic/patches-3.10/430-mtd-add-myloader-partition-parser.patch index fc352d2779..b6a6b6e57c 100644 --- a/target/linux/generic/patches-3.10/430-mtd-add-myloader-partition-parser.patch +++ b/target/linux/generic/patches-3.10/430-mtd-add-myloader-partition-parser.patch @@ -1,6 +1,6 @@ --- a/drivers/mtd/Kconfig +++ b/drivers/mtd/Kconfig -@@ -212,6 +212,22 @@ config MTD_BCM47XX_PARTS +@@ -184,6 +184,22 @@ config MTD_BCM47XX_PARTS This provides partitions parser for devices based on BCM47xx boards. @@ -25,7 +25,7 @@ config MTD_BLKDEVS --- a/drivers/mtd/Makefile +++ b/drivers/mtd/Makefile -@@ -19,6 +19,7 @@ obj-$(CONFIG_MTD_AFS_PARTS) += afs.o +@@ -15,6 +15,7 @@ obj-$(CONFIG_MTD_AFS_PARTS) += afs.o obj-$(CONFIG_MTD_AR7_PARTS) += ar7part.o obj-$(CONFIG_MTD_BCM63XX_PARTS) += bcm63xxpart.o obj-$(CONFIG_MTD_BCM47XX_PARTS) += bcm47xxpart.o diff --git a/target/linux/generic/patches-3.10/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch b/target/linux/generic/patches-3.10/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch index f97a442cb1..002a79ab73 100644 --- a/target/linux/generic/patches-3.10/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch +++ b/target/linux/generic/patches-3.10/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch @@ -11,7 +11,7 @@ Signed-off-by: Daniel Golle --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c -@@ -1209,6 +1209,48 @@ +@@ -1207,6 +1207,48 @@ static struct mtd_info * __init open_mtd return mtd; } @@ -60,7 +60,7 @@ Signed-off-by: Daniel Golle static int __init ubi_init(void) { int err, i, k; -@@ -1298,6 +1340,12 @@ +@@ -1290,6 +1332,12 @@ static int __init ubi_init(void) } } diff --git a/target/linux/generic/patches-3.13/400-mtd-add-rootfs-split-support.patch b/target/linux/generic/patches-3.13/400-mtd-add-rootfs-split-support.patch index ce91d7ba5e..ae8c45fa99 100644 --- a/target/linux/generic/patches-3.13/400-mtd-add-rootfs-split-support.patch +++ b/target/linux/generic/patches-3.13/400-mtd-add-rootfs-split-support.patch @@ -35,7 +35,7 @@ depends on m --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c -@@ -29,6 +29,7 @@ +@@ -29,9 +29,11 @@ #include #include #include @@ -43,7 +43,11 @@ #include #include "mtdcore.h" -@@ -45,13 +46,14 @@ struct mtd_part { ++#include "mtdsplit/mtdsplit.h" + + /* Our partition linked list */ + static LIST_HEAD(mtd_partitions); +@@ -45,13 +47,14 @@ struct mtd_part { struct list_head list; }; @@ -59,7 +63,7 @@ /* * MTD methods which simply translate the effective address and pass through * to the _real_ device. -@@ -534,8 +536,10 @@ out_register: +@@ -534,8 +537,10 @@ out_register: return slave; } @@ -72,7 +76,7 @@ { struct mtd_partition part; struct mtd_part *p, *new; -@@ -567,21 +571,24 @@ int mtd_add_partition(struct mtd_info *m +@@ -567,21 +572,24 @@ int mtd_add_partition(struct mtd_info *m end = offset + length; mutex_lock(&mtd_partitions_mutex); @@ -107,7 +111,7 @@ return ret; err_inv: -@@ -591,6 +598,12 @@ err_inv: +@@ -591,6 +599,12 @@ err_inv: } EXPORT_SYMBOL_GPL(mtd_add_partition); @@ -120,7 +124,7 @@ int mtd_del_partition(struct mtd_info *master, int partno) { struct mtd_part *slave, *next; -@@ -614,6 +627,144 @@ int mtd_del_partition(struct mtd_info *m +@@ -614,6 +628,144 @@ int mtd_del_partition(struct mtd_info *m } EXPORT_SYMBOL_GPL(mtd_del_partition); @@ -265,7 +269,7 @@ /* * This function, given a master MTD object and a partition table, creates * and registers slave MTD objects which are bound to the master according to -@@ -643,6 +794,7 @@ int add_mtd_partitions(struct mtd_info * +@@ -643,6 +795,7 @@ int add_mtd_partitions(struct mtd_info * mutex_unlock(&mtd_partitions_mutex); add_mtd_device(&slave->mtd); diff --git a/target/linux/generic/patches-3.13/401-mtd-add-support-for-different-partition-parser-types.patch b/target/linux/generic/patches-3.13/401-mtd-add-support-for-different-partition-parser-types.patch index 52b87f56cc..793005d6e1 100644 --- a/target/linux/generic/patches-3.13/401-mtd-add-support-for-different-partition-parser-types.patch +++ b/target/linux/generic/patches-3.13/401-mtd-add-support-for-different-partition-parser-types.patch @@ -11,7 +11,7 @@ Signed-off-by: Gabor Juhos --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c -@@ -824,6 +824,30 @@ static struct mtd_part_parser *get_parti +@@ -825,6 +825,30 @@ static struct mtd_part_parser *get_parti #define put_partition_parser(p) do { module_put((p)->owner); } while (0) @@ -42,7 +42,7 @@ Signed-off-by: Gabor Juhos int register_mtd_parser(struct mtd_part_parser *p) { spin_lock(&part_parser_lock); -@@ -900,6 +924,38 @@ int parse_mtd_partitions(struct mtd_info +@@ -901,6 +925,38 @@ int parse_mtd_partitions(struct mtd_info return ret; } diff --git a/target/linux/generic/patches-3.13/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch b/target/linux/generic/patches-3.13/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch index a614094851..8d0bda825f 100644 --- a/target/linux/generic/patches-3.13/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch +++ b/target/linux/generic/patches-3.13/402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch @@ -1,6 +1,6 @@ --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c -@@ -627,6 +627,37 @@ int mtd_del_partition(struct mtd_info *m +@@ -628,6 +628,37 @@ int mtd_del_partition(struct mtd_info *m } EXPORT_SYMBOL_GPL(mtd_del_partition); @@ -38,7 +38,7 @@ static inline unsigned long mtd_pad_erasesize(struct mtd_info *mtd, int offset, int len) { -@@ -686,6 +717,10 @@ static void split_rootfs_data(struct mtd +@@ -687,6 +718,10 @@ static void split_rootfs_data(struct mtd unsigned int split_size; int ret; @@ -49,7 +49,7 @@ ret = split_squashfs(master, part->offset, &split_offset); if (ret) return; -@@ -735,6 +770,12 @@ static void split_uimage(struct mtd_info +@@ -736,6 +771,12 @@ static void split_uimage(struct mtd_info static void split_firmware(struct mtd_info *master, struct mtd_part *part) { diff --git a/target/linux/generic/patches-3.13/403-mtd-hook-mtdsplit-to-Kbuild.patch b/target/linux/generic/patches-3.13/403-mtd-hook-mtdsplit-to-Kbuild.patch index c24f34c5cc..23cbd6243c 100644 --- a/target/linux/generic/patches-3.13/403-mtd-hook-mtdsplit-to-Kbuild.patch +++ b/target/linux/generic/patches-3.13/403-mtd-hook-mtdsplit-to-Kbuild.patch @@ -1,13 +1,10 @@ --- a/drivers/mtd/Kconfig +++ b/drivers/mtd/Kconfig -@@ -36,6 +36,11 @@ config MTD_UIMAGE_SPLIT +@@ -36,6 +36,8 @@ config MTD_UIMAGE_SPLIT depends on MTD_SPLIT_FIRMWARE default y -+config MTD_SPLIT -+ def_bool n -+ help -+ Generic MTD split support. ++source "drivers/mtd/mtdsplit/Kconfig" + endmenu @@ -18,7 +15,7 @@ obj-$(CONFIG_MTD) += mtd.o mtd-y := mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o mtdchar.o -+mtd-$(CONFIG_MTD_SPLIT) += mtdsplit.o ++obj-$(CONFIG_MTD_SPLIT) += mtdsplit/ + obj-$(CONFIG_MTD_OF_PARTS) += ofpart.o obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o diff --git a/target/linux/generic/patches-3.13/404-mtd-use-mtd_get_squashfs_len-in-split_squasfh.patch b/target/linux/generic/patches-3.13/404-mtd-use-mtd_get_squashfs_len-in-split_squasfh.patch index a54b97b07c..4ae675faf9 100644 --- a/target/linux/generic/patches-3.13/404-mtd-use-mtd_get_squashfs_len-in-split_squasfh.patch +++ b/target/linux/generic/patches-3.13/404-mtd-use-mtd_get_squashfs_len-in-split_squasfh.patch @@ -1,14 +1,6 @@ --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c -@@ -33,6 +33,7 @@ - #include - - #include "mtdcore.h" -+#include "mtdsplit.h" - - /* Our partition linked list */ - static LIST_HEAD(mtd_partitions); -@@ -669,43 +670,16 @@ mtd_pad_erasesize(struct mtd_info *mtd, +@@ -670,43 +670,16 @@ mtd_pad_erasesize(struct mtd_info *mtd, return len; } diff --git a/target/linux/generic/patches-3.13/406-mtd-add-squashfs-parser.patch b/target/linux/generic/patches-3.13/406-mtd-add-squashfs-parser.patch deleted file mode 100644 index b3ff9d9ab2..0000000000 --- a/target/linux/generic/patches-3.13/406-mtd-add-squashfs-parser.patch +++ /dev/null @@ -1,30 +0,0 @@ ---- a/drivers/mtd/Kconfig -+++ b/drivers/mtd/Kconfig -@@ -37,6 +37,17 @@ config MTD_UIMAGE_SPLIT - depends on MTD_SPLIT_FIRMWARE - default y - -+comment "Rootfs partition parsers" -+ -+config MTD_SPLIT_SQUASHFS_ROOT -+ bool "Squashfs based root partition parser" -+ select MTD_SPLIT -+ default n -+ help -+ This provides a parsing function which allows to detect the -+ offset and size of the unused portion of a rootfs partition -+ containing a squashfs. -+ - config MTD_SPLIT - def_bool n - help ---- a/drivers/mtd/Makefile -+++ b/drivers/mtd/Makefile -@@ -7,6 +7,7 @@ obj-$(CONFIG_MTD) += mtd.o - mtd-y := mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o mtdchar.o - - mtd-$(CONFIG_MTD_SPLIT) += mtdsplit.o -+mtd-$(CONFIG_MTD_SPLIT_SQUASHFS_ROOT) += mtdsplit_squashfs.o - - obj-$(CONFIG_MTD_OF_PARTS) += ofpart.o - obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o diff --git a/target/linux/generic/patches-3.13/407-mtd-hook-mtdsplit_uimage-into-Kbuild.patch b/target/linux/generic/patches-3.13/407-mtd-hook-mtdsplit_uimage-into-Kbuild.patch deleted file mode 100644 index 02697f64eb..0000000000 --- a/target/linux/generic/patches-3.13/407-mtd-hook-mtdsplit_uimage-into-Kbuild.patch +++ /dev/null @@ -1,25 +0,0 @@ ---- a/drivers/mtd/Kconfig -+++ b/drivers/mtd/Kconfig -@@ -48,6 +48,12 @@ config MTD_SPLIT_SQUASHFS_ROOT - offset and size of the unused portion of a rootfs partition - containing a squashfs. - -+comment "Firmware partition parsers" -+ -+config MTD_SPLIT_UIMAGE_FW -+ bool "uImage based firmware partition parser" -+ select MTD_SPLIT -+ - config MTD_SPLIT - def_bool n - help ---- a/drivers/mtd/Makefile -+++ b/drivers/mtd/Makefile -@@ -8,6 +8,7 @@ mtd-y := mtdcore.o mtdsuper.o mtdconc - - mtd-$(CONFIG_MTD_SPLIT) += mtdsplit.o - mtd-$(CONFIG_MTD_SPLIT_SQUASHFS_ROOT) += mtdsplit_squashfs.o -+mtd-$(CONFIG_MTD_SPLIT_UIMAGE_FW) += mtdsplit_uimage.o - - obj-$(CONFIG_MTD_OF_PARTS) += ofpart.o - obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o diff --git a/target/linux/generic/patches-3.13/408-mtd-hook-mtdsplit_seama-into-Kbuild.patch b/target/linux/generic/patches-3.13/408-mtd-hook-mtdsplit_seama-into-Kbuild.patch deleted file mode 100644 index 016a9b6e4c..0000000000 --- a/target/linux/generic/patches-3.13/408-mtd-hook-mtdsplit_seama-into-Kbuild.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- a/drivers/mtd/Kconfig -+++ b/drivers/mtd/Kconfig -@@ -50,6 +50,10 @@ config MTD_SPLIT_SQUASHFS_ROOT - - comment "Firmware partition parsers" - -+config MTD_SPLIT_SEAMA_FW -+ bool "Seama firmware parser" -+ select MTD_SPLIT -+ - config MTD_SPLIT_UIMAGE_FW - bool "uImage based firmware partition parser" - select MTD_SPLIT ---- a/drivers/mtd/Makefile -+++ b/drivers/mtd/Makefile -@@ -7,6 +7,7 @@ obj-$(CONFIG_MTD) += mtd.o - mtd-y := mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o mtdchar.o - - mtd-$(CONFIG_MTD_SPLIT) += mtdsplit.o -+mtd-$(CONFIG_MTD_SPLIT_SEAMA_FW) += mtdsplit_seama.o - mtd-$(CONFIG_MTD_SPLIT_SQUASHFS_ROOT) += mtdsplit_squashfs.o - mtd-$(CONFIG_MTD_SPLIT_UIMAGE_FW) += mtdsplit_uimage.o - diff --git a/target/linux/generic/patches-3.13/409-mtd-hook-mtdsplit_lzma-into-Kbuild.patch b/target/linux/generic/patches-3.13/409-mtd-hook-mtdsplit_lzma-into-Kbuild.patch deleted file mode 100644 index cc9a971573..0000000000 --- a/target/linux/generic/patches-3.13/409-mtd-hook-mtdsplit_lzma-into-Kbuild.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- a/drivers/mtd/Kconfig -+++ b/drivers/mtd/Kconfig -@@ -58,6 +58,10 @@ config MTD_SPLIT_UIMAGE_FW - bool "uImage based firmware partition parser" - select MTD_SPLIT - -+config MTD_SPLIT_LZMA_FW -+ bool "LZMA compressed kernel based firmware partition parser" -+ select MTD_SPLIT -+ - config MTD_SPLIT - def_bool n - help ---- a/drivers/mtd/Makefile -+++ b/drivers/mtd/Makefile -@@ -10,6 +10,7 @@ mtd-$(CONFIG_MTD_SPLIT) += mtdsplit.o - mtd-$(CONFIG_MTD_SPLIT_SEAMA_FW) += mtdsplit_seama.o - mtd-$(CONFIG_MTD_SPLIT_SQUASHFS_ROOT) += mtdsplit_squashfs.o - mtd-$(CONFIG_MTD_SPLIT_UIMAGE_FW) += mtdsplit_uimage.o -+mtd-$(CONFIG_MTD_SPLIT_LZMA_FW) += mtdsplit_lzma.o - - obj-$(CONFIG_MTD_OF_PARTS) += ofpart.o - obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o diff --git a/target/linux/generic/patches-3.13/411-mtd-partial_eraseblock_write.patch b/target/linux/generic/patches-3.13/411-mtd-partial_eraseblock_write.patch index 8da080b2ad..668b7d7289 100644 --- a/target/linux/generic/patches-3.13/411-mtd-partial_eraseblock_write.patch +++ b/target/linux/generic/patches-3.13/411-mtd-partial_eraseblock_write.patch @@ -2,7 +2,7 @@ +++ b/drivers/mtd/mtdpart.c @@ -35,6 +35,8 @@ #include "mtdcore.h" - #include "mtdsplit.h" + #include "mtdsplit/mtdsplit.h" +#define MTD_ERASE_PARTIAL 0x8000 /* partition only covers parts of an erase block */ + diff --git a/target/linux/generic/patches-3.13/430-mtd-add-myloader-partition-parser.patch b/target/linux/generic/patches-3.13/430-mtd-add-myloader-partition-parser.patch index fc352d2779..b6a6b6e57c 100644 --- a/target/linux/generic/patches-3.13/430-mtd-add-myloader-partition-parser.patch +++ b/target/linux/generic/patches-3.13/430-mtd-add-myloader-partition-parser.patch @@ -1,6 +1,6 @@ --- a/drivers/mtd/Kconfig +++ b/drivers/mtd/Kconfig -@@ -212,6 +212,22 @@ config MTD_BCM47XX_PARTS +@@ -184,6 +184,22 @@ config MTD_BCM47XX_PARTS This provides partitions parser for devices based on BCM47xx boards. @@ -25,7 +25,7 @@ config MTD_BLKDEVS --- a/drivers/mtd/Makefile +++ b/drivers/mtd/Makefile -@@ -19,6 +19,7 @@ obj-$(CONFIG_MTD_AFS_PARTS) += afs.o +@@ -15,6 +15,7 @@ obj-$(CONFIG_MTD_AFS_PARTS) += afs.o obj-$(CONFIG_MTD_AR7_PARTS) += ar7part.o obj-$(CONFIG_MTD_BCM63XX_PARTS) += bcm63xxpart.o obj-$(CONFIG_MTD_BCM47XX_PARTS) += bcm47xxpart.o diff --git a/target/linux/generic/patches-3.13/471-mtd-m25p80-allow-to-disable-small-sector-erase.patch b/target/linux/generic/patches-3.13/471-mtd-m25p80-allow-to-disable-small-sector-erase.patch index 9bf5e33a08..372e578326 100644 --- a/target/linux/generic/patches-3.13/471-mtd-m25p80-allow-to-disable-small-sector-erase.patch +++ b/target/linux/generic/patches-3.13/471-mtd-m25p80-allow-to-disable-small-sector-erase.patch @@ -30,7 +30,7 @@ /****************************************************************************/ struct m25p { -@@ -1032,7 +1038,7 @@ static int m25p_probe(struct spi_device +@@ -1032,7 +1038,7 @@ static int m25p_probe(struct spi_device flash->mtd._write = m25p80_write; /* prefer "small sector" erase if possible */ diff --git a/target/linux/generic/patches-3.13/502-yaffs-3.10-disable-proc-entry.patch b/target/linux/generic/patches-3.13/502-yaffs-3.10-disable-proc-entry.patch index 5b73d3898b..5345678c56 100644 --- a/target/linux/generic/patches-3.13/502-yaffs-3.10-disable-proc-entry.patch +++ b/target/linux/generic/patches-3.13/502-yaffs-3.10-disable-proc-entry.patch @@ -8,7 +8,7 @@ static struct proc_dir_entry *my_proc_entry; static char *yaffs_dump_dev_part0(char *buf, struct yaffs_dev *dev) -@@ -3398,6 +3399,7 @@ static int yaffs_proc_write(struct file +@@ -3398,6 +3399,7 @@ static int yaffs_proc_write(struct file return yaffs_proc_debug_write(file, buf, count, data); return yaffs_proc_write_trace_options(file, buf, count, data); } diff --git a/target/linux/generic/patches-3.14/400-mtd-add-rootfs-split-support.patch b/target/linux/generic/patches-3.14/400-mtd-add-rootfs-split-support.patch index 5ffacaf642..94551e247f 100644 --- a/target/linux/generic/patches-3.14/400-mtd-add-rootfs-split-support.patch +++ b/target/linux/generic/patches-3.14/400-mtd-add-rootfs-split-support.patch @@ -34,7 +34,7 @@ #include #include "mtdcore.h" -+#include "mtdsplit.h" ++#include "mtdsplit/mtdsplit.h" /* Our partition linked list */ static LIST_HEAD(mtd_partitions); diff --git a/target/linux/generic/patches-3.14/403-mtd-hook-mtdsplit-to-Kbuild.patch b/target/linux/generic/patches-3.14/403-mtd-hook-mtdsplit-to-Kbuild.patch index d897034abd..0cf1c38555 100644 --- a/target/linux/generic/patches-3.14/403-mtd-hook-mtdsplit-to-Kbuild.patch +++ b/target/linux/generic/patches-3.14/403-mtd-hook-mtdsplit-to-Kbuild.patch @@ -1,13 +1,10 @@ --- a/drivers/mtd/Kconfig +++ b/drivers/mtd/Kconfig -@@ -27,6 +27,11 @@ config MTD_SPLIT_FIRMWARE_NAME +@@ -27,6 +27,8 @@ config MTD_SPLIT_FIRMWARE_NAME depends on MTD_SPLIT_FIRMWARE default "firmware" -+config MTD_SPLIT -+ def_bool n -+ help -+ Generic MTD split support. ++source "drivers/mtd/mtdsplit/Kconfig" + endmenu @@ -18,7 +15,7 @@ obj-$(CONFIG_MTD) += mtd.o mtd-y := mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o mtdchar.o -+mtd-$(CONFIG_MTD_SPLIT) += mtdsplit.o ++obj-$(CONFIG_MTD_SPLIT) += mtdsplit/ + obj-$(CONFIG_MTD_OF_PARTS) += ofpart.o obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o diff --git a/target/linux/generic/patches-3.14/404-mtd-add-more-helper-functions.patch b/target/linux/generic/patches-3.14/404-mtd-add-more-helper-functions.patch new file mode 100644 index 0000000000..f3f957b33f --- /dev/null +++ b/target/linux/generic/patches-3.14/404-mtd-add-more-helper-functions.patch @@ -0,0 +1,101 @@ +--- a/drivers/mtd/mtdpart.c ++++ b/drivers/mtd/mtdpart.c +@@ -434,14 +434,12 @@ static struct mtd_part *allocate_partiti + if (slave->offset == MTDPART_OFS_APPEND) + slave->offset = cur_offset; + if (slave->offset == MTDPART_OFS_NXTBLK) { +- slave->offset = cur_offset; +- if (mtd_mod_by_eb(cur_offset, master) != 0) { +- /* Round up to next erasesize */ +- slave->offset = (mtd_div_by_eb(cur_offset, master) + 1) * master->erasesize; ++ /* Round up to next erasesize */ ++ slave->offset = mtd_roundup_to_eb(cur_offset, master); ++ if (slave->offset != cur_offset) + printk(KERN_NOTICE "Moving partition %d: " + "0x%012llx -> 0x%012llx\n", partno, + (unsigned long long)cur_offset, (unsigned long long)slave->offset); +- } + } + if (slave->offset == MTDPART_OFS_RETAIN) { + slave->offset = cur_offset; +@@ -659,6 +657,17 @@ run_parsers_by_type(struct mtd_part *sla + return nr_parts; + } + ++static inline unsigned long ++mtd_pad_erasesize(struct mtd_info *mtd, int offset, int len) ++{ ++ unsigned long mask = mtd->erasesize - 1; ++ ++ len += offset & mask; ++ len = (len + mask) & ~mask; ++ len -= offset & mask; ++ return len; ++} ++ + #ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME + #define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME + #else +@@ -900,6 +909,24 @@ int mtd_is_partition(const struct mtd_in + } + EXPORT_SYMBOL_GPL(mtd_is_partition); + ++struct mtd_info *mtdpart_get_master(const struct mtd_info *mtd) ++{ ++ if (!mtd_is_partition(mtd)) ++ return (struct mtd_info *)mtd; ++ ++ return PART(mtd)->master; ++} ++EXPORT_SYMBOL_GPL(mtdpart_get_master); ++ ++uint64_t mtdpart_get_offset(const struct mtd_info *mtd) ++{ ++ if (!mtd_is_partition(mtd)) ++ return 0; ++ ++ return PART(mtd)->offset; ++} ++EXPORT_SYMBOL_GPL(mtdpart_get_offset); ++ + /* Returns the size of the entire flash chip */ + uint64_t mtd_get_device_size(const struct mtd_info *mtd) + { +--- a/include/linux/mtd/partitions.h ++++ b/include/linux/mtd/partitions.h +@@ -90,6 +90,8 @@ int mtd_is_partition(const struct mtd_in + int mtd_add_partition(struct mtd_info *master, const char *name, + long long offset, long long length); + int mtd_del_partition(struct mtd_info *master, int partno); ++struct mtd_info *mtdpart_get_master(const struct mtd_info *mtd); ++uint64_t mtdpart_get_offset(const struct mtd_info *mtd); + uint64_t mtd_get_device_size(const struct mtd_info *mtd); + extern void __weak arch_split_mtd_part(struct mtd_info *master, + const char *name, int offset, int size); +--- a/include/linux/mtd/mtd.h ++++ b/include/linux/mtd/mtd.h +@@ -331,6 +331,24 @@ static inline uint32_t mtd_mod_by_eb(uin + return do_div(sz, mtd->erasesize); + } + ++static inline uint64_t mtd_roundup_to_eb(uint64_t sz, struct mtd_info *mtd) ++{ ++ if (mtd_mod_by_eb(sz, mtd) == 0) ++ return sz; ++ ++ /* Round up to next erase block */ ++ return (mtd_div_by_eb(sz, mtd) + 1) * mtd->erasesize; ++} ++ ++static inline uint64_t mtd_rounddown_to_eb(uint64_t sz, struct mtd_info *mtd) ++{ ++ if (mtd_mod_by_eb(sz, mtd) == 0) ++ return sz; ++ ++ /* Round down to the start of the current erase block */ ++ return (mtd_div_by_eb(sz, mtd)) * mtd->erasesize; ++} ++ + static inline uint32_t mtd_div_by_ws(uint64_t sz, struct mtd_info *mtd) + { + if (mtd->writesize_shift) diff --git a/target/linux/generic/patches-3.14/405-mtd-add-more-helper-functions.patch b/target/linux/generic/patches-3.14/405-mtd-add-more-helper-functions.patch deleted file mode 100644 index f3f957b33f..0000000000 --- a/target/linux/generic/patches-3.14/405-mtd-add-more-helper-functions.patch +++ /dev/null @@ -1,101 +0,0 @@ ---- a/drivers/mtd/mtdpart.c -+++ b/drivers/mtd/mtdpart.c -@@ -434,14 +434,12 @@ static struct mtd_part *allocate_partiti - if (slave->offset == MTDPART_OFS_APPEND) - slave->offset = cur_offset; - if (slave->offset == MTDPART_OFS_NXTBLK) { -- slave->offset = cur_offset; -- if (mtd_mod_by_eb(cur_offset, master) != 0) { -- /* Round up to next erasesize */ -- slave->offset = (mtd_div_by_eb(cur_offset, master) + 1) * master->erasesize; -+ /* Round up to next erasesize */ -+ slave->offset = mtd_roundup_to_eb(cur_offset, master); -+ if (slave->offset != cur_offset) - printk(KERN_NOTICE "Moving partition %d: " - "0x%012llx -> 0x%012llx\n", partno, - (unsigned long long)cur_offset, (unsigned long long)slave->offset); -- } - } - if (slave->offset == MTDPART_OFS_RETAIN) { - slave->offset = cur_offset; -@@ -659,6 +657,17 @@ run_parsers_by_type(struct mtd_part *sla - return nr_parts; - } - -+static inline unsigned long -+mtd_pad_erasesize(struct mtd_info *mtd, int offset, int len) -+{ -+ unsigned long mask = mtd->erasesize - 1; -+ -+ len += offset & mask; -+ len = (len + mask) & ~mask; -+ len -= offset & mask; -+ return len; -+} -+ - #ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME - #define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME - #else -@@ -900,6 +909,24 @@ int mtd_is_partition(const struct mtd_in - } - EXPORT_SYMBOL_GPL(mtd_is_partition); - -+struct mtd_info *mtdpart_get_master(const struct mtd_info *mtd) -+{ -+ if (!mtd_is_partition(mtd)) -+ return (struct mtd_info *)mtd; -+ -+ return PART(mtd)->master; -+} -+EXPORT_SYMBOL_GPL(mtdpart_get_master); -+ -+uint64_t mtdpart_get_offset(const struct mtd_info *mtd) -+{ -+ if (!mtd_is_partition(mtd)) -+ return 0; -+ -+ return PART(mtd)->offset; -+} -+EXPORT_SYMBOL_GPL(mtdpart_get_offset); -+ - /* Returns the size of the entire flash chip */ - uint64_t mtd_get_device_size(const struct mtd_info *mtd) - { ---- a/include/linux/mtd/partitions.h -+++ b/include/linux/mtd/partitions.h -@@ -90,6 +90,8 @@ int mtd_is_partition(const struct mtd_in - int mtd_add_partition(struct mtd_info *master, const char *name, - long long offset, long long length); - int mtd_del_partition(struct mtd_info *master, int partno); -+struct mtd_info *mtdpart_get_master(const struct mtd_info *mtd); -+uint64_t mtdpart_get_offset(const struct mtd_info *mtd); - uint64_t mtd_get_device_size(const struct mtd_info *mtd); - extern void __weak arch_split_mtd_part(struct mtd_info *master, - const char *name, int offset, int size); ---- a/include/linux/mtd/mtd.h -+++ b/include/linux/mtd/mtd.h -@@ -331,6 +331,24 @@ static inline uint32_t mtd_mod_by_eb(uin - return do_div(sz, mtd->erasesize); - } - -+static inline uint64_t mtd_roundup_to_eb(uint64_t sz, struct mtd_info *mtd) -+{ -+ if (mtd_mod_by_eb(sz, mtd) == 0) -+ return sz; -+ -+ /* Round up to next erase block */ -+ return (mtd_div_by_eb(sz, mtd) + 1) * mtd->erasesize; -+} -+ -+static inline uint64_t mtd_rounddown_to_eb(uint64_t sz, struct mtd_info *mtd) -+{ -+ if (mtd_mod_by_eb(sz, mtd) == 0) -+ return sz; -+ -+ /* Round down to the start of the current erase block */ -+ return (mtd_div_by_eb(sz, mtd)) * mtd->erasesize; -+} -+ - static inline uint32_t mtd_div_by_ws(uint64_t sz, struct mtd_info *mtd) - { - if (mtd->writesize_shift) diff --git a/target/linux/generic/patches-3.14/405-mtd-old-firmware-uimage-splitter.patch b/target/linux/generic/patches-3.14/405-mtd-old-firmware-uimage-splitter.patch new file mode 100644 index 0000000000..c4ceb82a32 --- /dev/null +++ b/target/linux/generic/patches-3.14/405-mtd-old-firmware-uimage-splitter.patch @@ -0,0 +1,70 @@ +--- a/drivers/mtd/Kconfig ++++ b/drivers/mtd/Kconfig +@@ -27,6 +27,11 @@ config MTD_SPLIT_FIRMWARE_NAME + depends on MTD_SPLIT_FIRMWARE + default "firmware" + ++config MTD_UIMAGE_SPLIT ++ bool "Enable split support for firmware partitions containing a uImage" ++ depends on MTD_SPLIT_FIRMWARE ++ default y ++ + source "drivers/mtd/mtdsplit/Kconfig" + + endmenu +--- a/drivers/mtd/mtdpart.c ++++ b/drivers/mtd/mtdpart.c +@@ -668,6 +668,37 @@ mtd_pad_erasesize(struct mtd_info *mtd, + return len; + } + ++#define UBOOT_MAGIC 0x27051956 ++ ++static void split_uimage(struct mtd_info *master, struct mtd_part *part) ++{ ++ struct { ++ __be32 magic; ++ __be32 pad[2]; ++ __be32 size; ++ } hdr; ++ size_t len; ++ ++ if (mtd_read(master, part->offset, sizeof(hdr), &len, (void *) &hdr)) ++ return; ++ ++ if (len != sizeof(hdr) || hdr.magic != cpu_to_be32(UBOOT_MAGIC)) ++ return; ++ ++ len = be32_to_cpu(hdr.size) + 0x40; ++ len = mtd_pad_erasesize(master, part->offset, len); ++ if (len + master->erasesize > part->mtd.size) ++ return; ++ ++ if (config_enabled(CONFIG_MTD_SPLIT_UIMAGE_FW)) ++ pr_err("Dedicated partitioner didn't split firmware partition, please fill a bug report!\n"); ++ else ++ pr_warn("Support for built-in firmware splitter will be removed, please use CONFIG_MTD_SPLIT_UIMAGE_FW\n"); ++ ++ __mtd_add_partition(master, "rootfs", part->offset + len, ++ part->mtd.size - len, false); ++} ++ + #ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME + #define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME + #else +@@ -676,7 +707,14 @@ mtd_pad_erasesize(struct mtd_info *mtd, + + static void split_firmware(struct mtd_info *master, struct mtd_part *part) + { +- run_parsers_by_type(part, MTD_PARSER_TYPE_FIRMWARE); ++ int ret; ++ ++ ret = run_parsers_by_type(part, MTD_PARSER_TYPE_FIRMWARE); ++ if (ret > 0) ++ return; ++ ++ if (config_enabled(CONFIG_MTD_UIMAGE_SPLIT)) ++ split_uimage(master, part); + } + + void __weak arch_split_mtd_part(struct mtd_info *master, const char *name, diff --git a/target/linux/generic/patches-3.14/406-mtd-hook-mtdsplit-into-Kbuild.patch b/target/linux/generic/patches-3.14/406-mtd-hook-mtdsplit-into-Kbuild.patch deleted file mode 100644 index 008714bd15..0000000000 --- a/target/linux/generic/patches-3.14/406-mtd-hook-mtdsplit-into-Kbuild.patch +++ /dev/null @@ -1,24 +0,0 @@ ---- a/drivers/mtd/Kconfig -+++ b/drivers/mtd/Kconfig -@@ -27,6 +27,8 @@ config MTD_SPLIT_FIRMWARE_NAME - depends on MTD_SPLIT_FIRMWARE - default "firmware" - -+source "drivers/mtd/mtdsplit/Kconfig" -+ - config MTD_SPLIT - def_bool n - help ---- a/drivers/mtd/Makefile -+++ b/drivers/mtd/Makefile -@@ -7,6 +7,10 @@ obj-$(CONFIG_MTD) += mtd.o - mtd-y := mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o mtdchar.o - - mtd-$(CONFIG_MTD_SPLIT) += mtdsplit.o -+mtd-$(CONFIG_MTD_SPLIT_SEAMA_FW) += mtdsplit_seama.o -+mtd-$(CONFIG_MTD_SPLIT_SQUASHFS_ROOT) += mtdsplit_squashfs.o -+mtd-$(CONFIG_MTD_SPLIT_UIMAGE_FW) += mtdsplit_uimage.o -+mtd-$(CONFIG_MTD_SPLIT_LZMA_FW) += mtdsplit_lzma.o - - obj-$(CONFIG_MTD_OF_PARTS) += ofpart.o - obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o diff --git a/target/linux/generic/patches-3.14/406-mtd-old-rootfs-squashfs-splitter.patch b/target/linux/generic/patches-3.14/406-mtd-old-rootfs-squashfs-splitter.patch new file mode 100644 index 0000000000..9147d1df46 --- /dev/null +++ b/target/linux/generic/patches-3.14/406-mtd-old-rootfs-squashfs-splitter.patch @@ -0,0 +1,76 @@ +--- a/drivers/mtd/Kconfig ++++ b/drivers/mtd/Kconfig +@@ -18,6 +18,11 @@ config MTD_ROOTFS_ROOT_DEV + bool "Automatically set 'rootfs' partition to be root filesystem" + default y + ++config MTD_ROOTFS_SPLIT ++ bool "Automatically split 'rootfs' partition for squashfs" ++ select MTD_SPLIT ++ default y ++ + config MTD_SPLIT_FIRMWARE + bool "Automatically split firmware partition for kernel+rootfs" + default y +--- a/drivers/mtd/mtdpart.c ++++ b/drivers/mtd/mtdpart.c +@@ -668,6 +668,47 @@ mtd_pad_erasesize(struct mtd_info *mtd, + return len; + } + ++static int split_squashfs(struct mtd_info *master, int offset, int *split_offset) ++{ ++ size_t squashfs_len; ++ int len, ret; ++ ++ ret = mtd_get_squashfs_len(master, offset, &squashfs_len); ++ if (ret) ++ return ret; ++ ++ len = mtd_pad_erasesize(master, offset, squashfs_len); ++ *split_offset = offset + len; ++ ++ return 0; ++} ++ ++static void split_rootfs_data(struct mtd_info *master, struct mtd_part *part) ++{ ++ unsigned int split_offset = 0; ++ unsigned int split_size; ++ int ret; ++ ++ ret = split_squashfs(master, part->offset, &split_offset); ++ if (ret) ++ return; ++ ++ if (split_offset <= 0) ++ return; ++ ++ if (config_enabled(CONFIG_MTD_SPLIT_SQUASHFS_ROOT)) ++ pr_err("Dedicated partitioner didn't create \"rootfs_data\" partition, please fill a bug report!\n"); ++ else ++ pr_warn("Support for built-in \"rootfs_data\" splitter will be removed, please use CONFIG_MTD_SPLIT_SQUASHFS_ROOT\n"); ++ ++ split_size = part->mtd.size - (split_offset - part->offset); ++ printk(KERN_INFO "mtd: partition \"%s\" created automatically, ofs=0x%x, len=0x%x\n", ++ ROOTFS_SPLIT_NAME, split_offset, split_size); ++ ++ __mtd_add_partition(master, ROOTFS_SPLIT_NAME, split_offset, ++ split_size, false); ++} ++ + #define UBOOT_MAGIC 0x27051956 + + static void split_uimage(struct mtd_info *master, struct mtd_part *part) +@@ -730,7 +771,10 @@ static void mtd_partition_split(struct m + return; + + if (!strcmp(part->mtd.name, "rootfs")) { +- run_parsers_by_type(part, MTD_PARSER_TYPE_ROOTFS); ++ int num = run_parsers_by_type(part, MTD_PARSER_TYPE_ROOTFS); ++ ++ if (num <= 0 && config_enabled(CONFIG_MTD_ROOTFS_SPLIT)) ++ split_rootfs_data(master, part); + + rootfs_found = 1; + } diff --git a/target/linux/generic/patches-3.14/407-mtd-old-firmware-uimage-splitter.patch b/target/linux/generic/patches-3.14/407-mtd-old-firmware-uimage-splitter.patch deleted file mode 100644 index 3f7e910e72..0000000000 --- a/target/linux/generic/patches-3.14/407-mtd-old-firmware-uimage-splitter.patch +++ /dev/null @@ -1,70 +0,0 @@ ---- a/drivers/mtd/Kconfig -+++ b/drivers/mtd/Kconfig -@@ -27,6 +27,11 @@ config MTD_SPLIT_FIRMWARE_NAME - depends on MTD_SPLIT_FIRMWARE - default "firmware" - -+config MTD_UIMAGE_SPLIT -+ bool "Enable split support for firmware partitions containing a uImage" -+ depends on MTD_SPLIT_FIRMWARE -+ default y -+ - source "drivers/mtd/mtdsplit/Kconfig" - - config MTD_SPLIT ---- a/drivers/mtd/mtdpart.c -+++ b/drivers/mtd/mtdpart.c -@@ -668,6 +668,37 @@ mtd_pad_erasesize(struct mtd_info *mtd, - return len; - } - -+#define UBOOT_MAGIC 0x27051956 -+ -+static void split_uimage(struct mtd_info *master, struct mtd_part *part) -+{ -+ struct { -+ __be32 magic; -+ __be32 pad[2]; -+ __be32 size; -+ } hdr; -+ size_t len; -+ -+ if (mtd_read(master, part->offset, sizeof(hdr), &len, (void *) &hdr)) -+ return; -+ -+ if (len != sizeof(hdr) || hdr.magic != cpu_to_be32(UBOOT_MAGIC)) -+ return; -+ -+ len = be32_to_cpu(hdr.size) + 0x40; -+ len = mtd_pad_erasesize(master, part->offset, len); -+ if (len + master->erasesize > part->mtd.size) -+ return; -+ -+ if (config_enabled(CONFIG_MTD_SPLIT_UIMAGE_FW)) -+ pr_err("Dedicated partitioner didn't split firmware partition, please fill a bug report!\n"); -+ else -+ pr_warn("Support for built-in firmware splitter will be removed, please use CONFIG_MTD_SPLIT_UIMAGE_FW\n"); -+ -+ __mtd_add_partition(master, "rootfs", part->offset + len, -+ part->mtd.size - len, false); -+} -+ - #ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME - #define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME - #else -@@ -676,7 +707,14 @@ mtd_pad_erasesize(struct mtd_info *mtd, - - static void split_firmware(struct mtd_info *master, struct mtd_part *part) - { -- run_parsers_by_type(part, MTD_PARSER_TYPE_FIRMWARE); -+ int ret; -+ -+ ret = run_parsers_by_type(part, MTD_PARSER_TYPE_FIRMWARE); -+ if (ret > 0) -+ return; -+ -+ if (config_enabled(CONFIG_MTD_UIMAGE_SPLIT)) -+ split_uimage(master, part); - } - - void __weak arch_split_mtd_part(struct mtd_info *master, const char *name, diff --git a/target/linux/generic/patches-3.14/408-mtd-old-rootfs-squashfs-splitter.patch b/target/linux/generic/patches-3.14/408-mtd-old-rootfs-squashfs-splitter.patch deleted file mode 100644 index c29b137774..0000000000 --- a/target/linux/generic/patches-3.14/408-mtd-old-rootfs-squashfs-splitter.patch +++ /dev/null @@ -1,76 +0,0 @@ ---- a/drivers/mtd/Kconfig -+++ b/drivers/mtd/Kconfig -@@ -18,6 +18,11 @@ config MTD_ROOTFS_ROOT_DEV - bool "Automatically set 'rootfs' partition to be root filesystem" - default y - -+config MTD_ROOTFS_SPLIT -+ bool "Automatically split 'rootfs' partition for squashfs" -+ select MTD_SPLIT -+ default y -+ - config MTD_SPLIT_FIRMWARE - bool "Automatically split firmware partition for kernel+rootfs" - default y ---- a/drivers/mtd/mtdpart.c -+++ b/drivers/mtd/mtdpart.c -@@ -668,6 +668,47 @@ mtd_pad_erasesize(struct mtd_info *mtd, - return len; - } - -+static int split_squashfs(struct mtd_info *master, int offset, int *split_offset) -+{ -+ size_t squashfs_len; -+ int len, ret; -+ -+ ret = mtd_get_squashfs_len(master, offset, &squashfs_len); -+ if (ret) -+ return ret; -+ -+ len = mtd_pad_erasesize(master, offset, squashfs_len); -+ *split_offset = offset + len; -+ -+ return 0; -+} -+ -+static void split_rootfs_data(struct mtd_info *master, struct mtd_part *part) -+{ -+ unsigned int split_offset = 0; -+ unsigned int split_size; -+ int ret; -+ -+ ret = split_squashfs(master, part->offset, &split_offset); -+ if (ret) -+ return; -+ -+ if (split_offset <= 0) -+ return; -+ -+ if (config_enabled(CONFIG_MTD_SPLIT_SQUASHFS_ROOT)) -+ pr_err("Dedicated partitioner didn't create \"rootfs_data\" partition, please fill a bug report!\n"); -+ else -+ pr_warn("Support for built-in \"rootfs_data\" splitter will be removed, please use CONFIG_MTD_SPLIT_SQUASHFS_ROOT\n"); -+ -+ split_size = part->mtd.size - (split_offset - part->offset); -+ printk(KERN_INFO "mtd: partition \"%s\" created automatically, ofs=0x%x, len=0x%x\n", -+ ROOTFS_SPLIT_NAME, split_offset, split_size); -+ -+ __mtd_add_partition(master, ROOTFS_SPLIT_NAME, split_offset, -+ split_size, false); -+} -+ - #define UBOOT_MAGIC 0x27051956 - - static void split_uimage(struct mtd_info *master, struct mtd_part *part) -@@ -730,7 +771,10 @@ static void mtd_partition_split(struct m - return; - - if (!strcmp(part->mtd.name, "rootfs")) { -- run_parsers_by_type(part, MTD_PARSER_TYPE_ROOTFS); -+ int num = run_parsers_by_type(part, MTD_PARSER_TYPE_ROOTFS); -+ -+ if (num <= 0 && config_enabled(CONFIG_MTD_ROOTFS_SPLIT)) -+ split_rootfs_data(master, part); - - rootfs_found = 1; - } diff --git a/target/linux/generic/patches-3.14/411-mtd-partial_eraseblock_write.patch b/target/linux/generic/patches-3.14/411-mtd-partial_eraseblock_write.patch index 8da080b2ad..668b7d7289 100644 --- a/target/linux/generic/patches-3.14/411-mtd-partial_eraseblock_write.patch +++ b/target/linux/generic/patches-3.14/411-mtd-partial_eraseblock_write.patch @@ -2,7 +2,7 @@ +++ b/drivers/mtd/mtdpart.c @@ -35,6 +35,8 @@ #include "mtdcore.h" - #include "mtdsplit.h" + #include "mtdsplit/mtdsplit.h" +#define MTD_ERASE_PARTIAL 0x8000 /* partition only covers parts of an erase block */ + diff --git a/target/linux/generic/patches-3.14/430-mtd-add-myloader-partition-parser.patch b/target/linux/generic/patches-3.14/430-mtd-add-myloader-partition-parser.patch index ffc9e2199c..45af25dd61 100644 --- a/target/linux/generic/patches-3.14/430-mtd-add-myloader-partition-parser.patch +++ b/target/linux/generic/patches-3.14/430-mtd-add-myloader-partition-parser.patch @@ -1,6 +1,6 @@ --- a/drivers/mtd/Kconfig +++ b/drivers/mtd/Kconfig -@@ -189,6 +189,22 @@ config MTD_BCM47XX_PARTS +@@ -184,6 +184,22 @@ config MTD_BCM47XX_PARTS This provides partitions parser for devices based on BCM47xx boards. @@ -25,7 +25,7 @@ # --- a/drivers/mtd/Makefile +++ b/drivers/mtd/Makefile -@@ -19,6 +19,7 @@ obj-$(CONFIG_MTD_AFS_PARTS) += afs.o +@@ -15,6 +15,7 @@ obj-$(CONFIG_MTD_AFS_PARTS) += afs.o obj-$(CONFIG_MTD_AR7_PARTS) += ar7part.o obj-$(CONFIG_MTD_BCM63XX_PARTS) += bcm63xxpart.o obj-$(CONFIG_MTD_BCM47XX_PARTS) += bcm47xxpart.o diff --git a/target/linux/generic/patches-3.14/431-mtd-bcm47xxpart-support-TRX-data-partition-being-UBI.patch b/target/linux/generic/patches-3.14/431-mtd-bcm47xxpart-support-TRX-data-partition-being-UBI.patch index 4c4720341e..46881fca2c 100644 --- a/target/linux/generic/patches-3.14/431-mtd-bcm47xxpart-support-TRX-data-partition-being-UBI.patch +++ b/target/linux/generic/patches-3.14/431-mtd-bcm47xxpart-support-TRX-data-partition-being-UBI.patch @@ -17,7 +17,7 @@ u64 offset, uint32_t mask_flags) { part->name = name; -@@ -58,6 +59,26 @@ static void bcm47xxpart_add_part(struct +@@ -58,6 +59,26 @@ static void bcm47xxpart_add_part(struct part->mask_flags = mask_flags; } diff --git a/target/linux/generic/patches-3.14/471-mtd-m25p80-allow-to-disable-small-sector-erase.patch b/target/linux/generic/patches-3.14/471-mtd-m25p80-allow-to-disable-small-sector-erase.patch index eec90fa413..4f2f4e6586 100644 --- a/target/linux/generic/patches-3.14/471-mtd-m25p80-allow-to-disable-small-sector-erase.patch +++ b/target/linux/generic/patches-3.14/471-mtd-m25p80-allow-to-disable-small-sector-erase.patch @@ -30,7 +30,7 @@ /****************************************************************************/ enum read_type { -@@ -1192,7 +1198,7 @@ static int m25p_probe(struct spi_device +@@ -1192,7 +1198,7 @@ static int m25p_probe(struct spi_device flash->mtd._write = m25p80_write; /* prefer "small sector" erase if possible */ diff --git a/target/linux/generic/patches-3.18/400-mtd-add-rootfs-split-support.patch b/target/linux/generic/patches-3.18/400-mtd-add-rootfs-split-support.patch index 597adf5445..bf69a3509d 100644 --- a/target/linux/generic/patches-3.18/400-mtd-add-rootfs-split-support.patch +++ b/target/linux/generic/patches-3.18/400-mtd-add-rootfs-split-support.patch @@ -34,7 +34,7 @@ #include #include "mtdcore.h" -+#include "mtdsplit.h" ++#include "mtdsplit/mtdsplit.h" /* Our partition linked list */ static LIST_HEAD(mtd_partitions); diff --git a/target/linux/generic/patches-3.18/403-mtd-hook-mtdsplit-to-Kbuild.patch b/target/linux/generic/patches-3.18/403-mtd-hook-mtdsplit-to-Kbuild.patch index d897034abd..0cf1c38555 100644 --- a/target/linux/generic/patches-3.18/403-mtd-hook-mtdsplit-to-Kbuild.patch +++ b/target/linux/generic/patches-3.18/403-mtd-hook-mtdsplit-to-Kbuild.patch @@ -1,13 +1,10 @@ --- a/drivers/mtd/Kconfig +++ b/drivers/mtd/Kconfig -@@ -27,6 +27,11 @@ config MTD_SPLIT_FIRMWARE_NAME +@@ -27,6 +27,8 @@ config MTD_SPLIT_FIRMWARE_NAME depends on MTD_SPLIT_FIRMWARE default "firmware" -+config MTD_SPLIT -+ def_bool n -+ help -+ Generic MTD split support. ++source "drivers/mtd/mtdsplit/Kconfig" + endmenu @@ -18,7 +15,7 @@ obj-$(CONFIG_MTD) += mtd.o mtd-y := mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o mtdchar.o -+mtd-$(CONFIG_MTD_SPLIT) += mtdsplit.o ++obj-$(CONFIG_MTD_SPLIT) += mtdsplit/ + obj-$(CONFIG_MTD_OF_PARTS) += ofpart.o obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o diff --git a/target/linux/generic/patches-3.18/404-mtd-add-more-helper-functions.patch b/target/linux/generic/patches-3.18/404-mtd-add-more-helper-functions.patch new file mode 100644 index 0000000000..d7c38011ec --- /dev/null +++ b/target/linux/generic/patches-3.18/404-mtd-add-more-helper-functions.patch @@ -0,0 +1,101 @@ +--- a/drivers/mtd/mtdpart.c ++++ b/drivers/mtd/mtdpart.c +@@ -445,14 +445,12 @@ static struct mtd_part *allocate_partiti + if (slave->offset == MTDPART_OFS_APPEND) + slave->offset = cur_offset; + if (slave->offset == MTDPART_OFS_NXTBLK) { +- slave->offset = cur_offset; +- if (mtd_mod_by_eb(cur_offset, master) != 0) { +- /* Round up to next erasesize */ +- slave->offset = (mtd_div_by_eb(cur_offset, master) + 1) * master->erasesize; ++ /* Round up to next erasesize */ ++ slave->offset = mtd_roundup_to_eb(cur_offset, master); ++ if (slave->offset != cur_offset) + printk(KERN_NOTICE "Moving partition %d: " + "0x%012llx -> 0x%012llx\n", partno, + (unsigned long long)cur_offset, (unsigned long long)slave->offset); +- } + } + if (slave->offset == MTDPART_OFS_RETAIN) { + slave->offset = cur_offset; +@@ -672,6 +670,17 @@ run_parsers_by_type(struct mtd_part *sla + return nr_parts; + } + ++static inline unsigned long ++mtd_pad_erasesize(struct mtd_info *mtd, int offset, int len) ++{ ++ unsigned long mask = mtd->erasesize - 1; ++ ++ len += offset & mask; ++ len = (len + mask) & ~mask; ++ len -= offset & mask; ++ return len; ++} ++ + #ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME + #define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME + #else +@@ -913,6 +922,24 @@ int mtd_is_partition(const struct mtd_in + } + EXPORT_SYMBOL_GPL(mtd_is_partition); + ++struct mtd_info *mtdpart_get_master(const struct mtd_info *mtd) ++{ ++ if (!mtd_is_partition(mtd)) ++ return (struct mtd_info *)mtd; ++ ++ return PART(mtd)->master; ++} ++EXPORT_SYMBOL_GPL(mtdpart_get_master); ++ ++uint64_t mtdpart_get_offset(const struct mtd_info *mtd) ++{ ++ if (!mtd_is_partition(mtd)) ++ return 0; ++ ++ return PART(mtd)->offset; ++} ++EXPORT_SYMBOL_GPL(mtdpart_get_offset); ++ + /* Returns the size of the entire flash chip */ + uint64_t mtd_get_device_size(const struct mtd_info *mtd) + { +--- a/include/linux/mtd/partitions.h ++++ b/include/linux/mtd/partitions.h +@@ -90,6 +90,8 @@ int mtd_is_partition(const struct mtd_in + int mtd_add_partition(struct mtd_info *master, const char *name, + long long offset, long long length); + int mtd_del_partition(struct mtd_info *master, int partno); ++struct mtd_info *mtdpart_get_master(const struct mtd_info *mtd); ++uint64_t mtdpart_get_offset(const struct mtd_info *mtd); + uint64_t mtd_get_device_size(const struct mtd_info *mtd); + extern void __weak arch_split_mtd_part(struct mtd_info *master, + const char *name, int offset, int size); +--- a/include/linux/mtd/mtd.h ++++ b/include/linux/mtd/mtd.h +@@ -333,6 +333,24 @@ static inline uint32_t mtd_mod_by_eb(uin + return do_div(sz, mtd->erasesize); + } + ++static inline uint64_t mtd_roundup_to_eb(uint64_t sz, struct mtd_info *mtd) ++{ ++ if (mtd_mod_by_eb(sz, mtd) == 0) ++ return sz; ++ ++ /* Round up to next erase block */ ++ return (mtd_div_by_eb(sz, mtd) + 1) * mtd->erasesize; ++} ++ ++static inline uint64_t mtd_rounddown_to_eb(uint64_t sz, struct mtd_info *mtd) ++{ ++ if (mtd_mod_by_eb(sz, mtd) == 0) ++ return sz; ++ ++ /* Round down to the start of the current erase block */ ++ return (mtd_div_by_eb(sz, mtd)) * mtd->erasesize; ++} ++ + static inline uint32_t mtd_div_by_ws(uint64_t sz, struct mtd_info *mtd) + { + if (mtd->writesize_shift) diff --git a/target/linux/generic/patches-3.18/405-mtd-add-more-helper-functions.patch b/target/linux/generic/patches-3.18/405-mtd-add-more-helper-functions.patch deleted file mode 100644 index d7c38011ec..0000000000 --- a/target/linux/generic/patches-3.18/405-mtd-add-more-helper-functions.patch +++ /dev/null @@ -1,101 +0,0 @@ ---- a/drivers/mtd/mtdpart.c -+++ b/drivers/mtd/mtdpart.c -@@ -445,14 +445,12 @@ static struct mtd_part *allocate_partiti - if (slave->offset == MTDPART_OFS_APPEND) - slave->offset = cur_offset; - if (slave->offset == MTDPART_OFS_NXTBLK) { -- slave->offset = cur_offset; -- if (mtd_mod_by_eb(cur_offset, master) != 0) { -- /* Round up to next erasesize */ -- slave->offset = (mtd_div_by_eb(cur_offset, master) + 1) * master->erasesize; -+ /* Round up to next erasesize */ -+ slave->offset = mtd_roundup_to_eb(cur_offset, master); -+ if (slave->offset != cur_offset) - printk(KERN_NOTICE "Moving partition %d: " - "0x%012llx -> 0x%012llx\n", partno, - (unsigned long long)cur_offset, (unsigned long long)slave->offset); -- } - } - if (slave->offset == MTDPART_OFS_RETAIN) { - slave->offset = cur_offset; -@@ -672,6 +670,17 @@ run_parsers_by_type(struct mtd_part *sla - return nr_parts; - } - -+static inline unsigned long -+mtd_pad_erasesize(struct mtd_info *mtd, int offset, int len) -+{ -+ unsigned long mask = mtd->erasesize - 1; -+ -+ len += offset & mask; -+ len = (len + mask) & ~mask; -+ len -= offset & mask; -+ return len; -+} -+ - #ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME - #define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME - #else -@@ -913,6 +922,24 @@ int mtd_is_partition(const struct mtd_in - } - EXPORT_SYMBOL_GPL(mtd_is_partition); - -+struct mtd_info *mtdpart_get_master(const struct mtd_info *mtd) -+{ -+ if (!mtd_is_partition(mtd)) -+ return (struct mtd_info *)mtd; -+ -+ return PART(mtd)->master; -+} -+EXPORT_SYMBOL_GPL(mtdpart_get_master); -+ -+uint64_t mtdpart_get_offset(const struct mtd_info *mtd) -+{ -+ if (!mtd_is_partition(mtd)) -+ return 0; -+ -+ return PART(mtd)->offset; -+} -+EXPORT_SYMBOL_GPL(mtdpart_get_offset); -+ - /* Returns the size of the entire flash chip */ - uint64_t mtd_get_device_size(const struct mtd_info *mtd) - { ---- a/include/linux/mtd/partitions.h -+++ b/include/linux/mtd/partitions.h -@@ -90,6 +90,8 @@ int mtd_is_partition(const struct mtd_in - int mtd_add_partition(struct mtd_info *master, const char *name, - long long offset, long long length); - int mtd_del_partition(struct mtd_info *master, int partno); -+struct mtd_info *mtdpart_get_master(const struct mtd_info *mtd); -+uint64_t mtdpart_get_offset(const struct mtd_info *mtd); - uint64_t mtd_get_device_size(const struct mtd_info *mtd); - extern void __weak arch_split_mtd_part(struct mtd_info *master, - const char *name, int offset, int size); ---- a/include/linux/mtd/mtd.h -+++ b/include/linux/mtd/mtd.h -@@ -333,6 +333,24 @@ static inline uint32_t mtd_mod_by_eb(uin - return do_div(sz, mtd->erasesize); - } - -+static inline uint64_t mtd_roundup_to_eb(uint64_t sz, struct mtd_info *mtd) -+{ -+ if (mtd_mod_by_eb(sz, mtd) == 0) -+ return sz; -+ -+ /* Round up to next erase block */ -+ return (mtd_div_by_eb(sz, mtd) + 1) * mtd->erasesize; -+} -+ -+static inline uint64_t mtd_rounddown_to_eb(uint64_t sz, struct mtd_info *mtd) -+{ -+ if (mtd_mod_by_eb(sz, mtd) == 0) -+ return sz; -+ -+ /* Round down to the start of the current erase block */ -+ return (mtd_div_by_eb(sz, mtd)) * mtd->erasesize; -+} -+ - static inline uint32_t mtd_div_by_ws(uint64_t sz, struct mtd_info *mtd) - { - if (mtd->writesize_shift) diff --git a/target/linux/generic/patches-3.18/405-mtd-old-firmware-uimage-splitter.patch b/target/linux/generic/patches-3.18/405-mtd-old-firmware-uimage-splitter.patch new file mode 100644 index 0000000000..a19202a870 --- /dev/null +++ b/target/linux/generic/patches-3.18/405-mtd-old-firmware-uimage-splitter.patch @@ -0,0 +1,70 @@ +--- a/drivers/mtd/Kconfig ++++ b/drivers/mtd/Kconfig +@@ -27,6 +27,11 @@ config MTD_SPLIT_FIRMWARE_NAME + depends on MTD_SPLIT_FIRMWARE + default "firmware" + ++config MTD_UIMAGE_SPLIT ++ bool "Enable split support for firmware partitions containing a uImage" ++ depends on MTD_SPLIT_FIRMWARE ++ default y ++ + source "drivers/mtd/mtdsplit/Kconfig" + + endmenu +--- a/drivers/mtd/mtdpart.c ++++ b/drivers/mtd/mtdpart.c +@@ -681,6 +681,37 @@ mtd_pad_erasesize(struct mtd_info *mtd, + return len; + } + ++#define UBOOT_MAGIC 0x27051956 ++ ++static void split_uimage(struct mtd_info *master, struct mtd_part *part) ++{ ++ struct { ++ __be32 magic; ++ __be32 pad[2]; ++ __be32 size; ++ } hdr; ++ size_t len; ++ ++ if (mtd_read(master, part->offset, sizeof(hdr), &len, (void *) &hdr)) ++ return; ++ ++ if (len != sizeof(hdr) || hdr.magic != cpu_to_be32(UBOOT_MAGIC)) ++ return; ++ ++ len = be32_to_cpu(hdr.size) + 0x40; ++ len = mtd_pad_erasesize(master, part->offset, len); ++ if (len + master->erasesize > part->mtd.size) ++ return; ++ ++ if (config_enabled(CONFIG_MTD_SPLIT_UIMAGE_FW)) ++ pr_err("Dedicated partitioner didn't split firmware partition, please fill a bug report!\n"); ++ else ++ pr_warn("Support for built-in firmware splitter will be removed, please use CONFIG_MTD_SPLIT_UIMAGE_FW\n"); ++ ++ __mtd_add_partition(master, "rootfs", part->offset + len, ++ part->mtd.size - len, false); ++} ++ + #ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME + #define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME + #else +@@ -689,7 +720,14 @@ mtd_pad_erasesize(struct mtd_info *mtd, + + static void split_firmware(struct mtd_info *master, struct mtd_part *part) + { +- run_parsers_by_type(part, MTD_PARSER_TYPE_FIRMWARE); ++ int ret; ++ ++ ret = run_parsers_by_type(part, MTD_PARSER_TYPE_FIRMWARE); ++ if (ret > 0) ++ return; ++ ++ if (config_enabled(CONFIG_MTD_UIMAGE_SPLIT)) ++ split_uimage(master, part); + } + + void __weak arch_split_mtd_part(struct mtd_info *master, const char *name, diff --git a/target/linux/generic/patches-3.18/406-mtd-hook-mtdsplit-into-Kbuild.patch b/target/linux/generic/patches-3.18/406-mtd-hook-mtdsplit-into-Kbuild.patch deleted file mode 100644 index 008714bd15..0000000000 --- a/target/linux/generic/patches-3.18/406-mtd-hook-mtdsplit-into-Kbuild.patch +++ /dev/null @@ -1,24 +0,0 @@ ---- a/drivers/mtd/Kconfig -+++ b/drivers/mtd/Kconfig -@@ -27,6 +27,8 @@ config MTD_SPLIT_FIRMWARE_NAME - depends on MTD_SPLIT_FIRMWARE - default "firmware" - -+source "drivers/mtd/mtdsplit/Kconfig" -+ - config MTD_SPLIT - def_bool n - help ---- a/drivers/mtd/Makefile -+++ b/drivers/mtd/Makefile -@@ -7,6 +7,10 @@ obj-$(CONFIG_MTD) += mtd.o - mtd-y := mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o mtdchar.o - - mtd-$(CONFIG_MTD_SPLIT) += mtdsplit.o -+mtd-$(CONFIG_MTD_SPLIT_SEAMA_FW) += mtdsplit_seama.o -+mtd-$(CONFIG_MTD_SPLIT_SQUASHFS_ROOT) += mtdsplit_squashfs.o -+mtd-$(CONFIG_MTD_SPLIT_UIMAGE_FW) += mtdsplit_uimage.o -+mtd-$(CONFIG_MTD_SPLIT_LZMA_FW) += mtdsplit_lzma.o - - obj-$(CONFIG_MTD_OF_PARTS) += ofpart.o - obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o diff --git a/target/linux/generic/patches-3.18/406-mtd-old-rootfs-squashfs-splitter.patch b/target/linux/generic/patches-3.18/406-mtd-old-rootfs-squashfs-splitter.patch new file mode 100644 index 0000000000..d48a681483 --- /dev/null +++ b/target/linux/generic/patches-3.18/406-mtd-old-rootfs-squashfs-splitter.patch @@ -0,0 +1,76 @@ +--- a/drivers/mtd/Kconfig ++++ b/drivers/mtd/Kconfig +@@ -18,6 +18,11 @@ config MTD_ROOTFS_ROOT_DEV + bool "Automatically set 'rootfs' partition to be root filesystem" + default y + ++config MTD_ROOTFS_SPLIT ++ bool "Automatically split 'rootfs' partition for squashfs" ++ select MTD_SPLIT ++ default y ++ + config MTD_SPLIT_FIRMWARE + bool "Automatically split firmware partition for kernel+rootfs" + default y +--- a/drivers/mtd/mtdpart.c ++++ b/drivers/mtd/mtdpart.c +@@ -681,6 +681,47 @@ mtd_pad_erasesize(struct mtd_info *mtd, + return len; + } + ++static int split_squashfs(struct mtd_info *master, int offset, int *split_offset) ++{ ++ size_t squashfs_len; ++ int len, ret; ++ ++ ret = mtd_get_squashfs_len(master, offset, &squashfs_len); ++ if (ret) ++ return ret; ++ ++ len = mtd_pad_erasesize(master, offset, squashfs_len); ++ *split_offset = offset + len; ++ ++ return 0; ++} ++ ++static void split_rootfs_data(struct mtd_info *master, struct mtd_part *part) ++{ ++ unsigned int split_offset = 0; ++ unsigned int split_size; ++ int ret; ++ ++ ret = split_squashfs(master, part->offset, &split_offset); ++ if (ret) ++ return; ++ ++ if (split_offset <= 0) ++ return; ++ ++ if (config_enabled(CONFIG_MTD_SPLIT_SQUASHFS_ROOT)) ++ pr_err("Dedicated partitioner didn't create \"rootfs_data\" partition, please fill a bug report!\n"); ++ else ++ pr_warn("Support for built-in \"rootfs_data\" splitter will be removed, please use CONFIG_MTD_SPLIT_SQUASHFS_ROOT\n"); ++ ++ split_size = part->mtd.size - (split_offset - part->offset); ++ printk(KERN_INFO "mtd: partition \"%s\" created automatically, ofs=0x%x, len=0x%x\n", ++ ROOTFS_SPLIT_NAME, split_offset, split_size); ++ ++ __mtd_add_partition(master, ROOTFS_SPLIT_NAME, split_offset, ++ split_size, false); ++} ++ + #define UBOOT_MAGIC 0x27051956 + + static void split_uimage(struct mtd_info *master, struct mtd_part *part) +@@ -743,7 +784,10 @@ static void mtd_partition_split(struct m + return; + + if (!strcmp(part->mtd.name, "rootfs")) { +- run_parsers_by_type(part, MTD_PARSER_TYPE_ROOTFS); ++ int num = run_parsers_by_type(part, MTD_PARSER_TYPE_ROOTFS); ++ ++ if (num <= 0 && config_enabled(CONFIG_MTD_ROOTFS_SPLIT)) ++ split_rootfs_data(master, part); + + rootfs_found = 1; + } diff --git a/target/linux/generic/patches-3.18/407-mtd-old-firmware-uimage-splitter.patch b/target/linux/generic/patches-3.18/407-mtd-old-firmware-uimage-splitter.patch deleted file mode 100644 index 34a4b1aa8c..0000000000 --- a/target/linux/generic/patches-3.18/407-mtd-old-firmware-uimage-splitter.patch +++ /dev/null @@ -1,70 +0,0 @@ ---- a/drivers/mtd/Kconfig -+++ b/drivers/mtd/Kconfig -@@ -27,6 +27,11 @@ config MTD_SPLIT_FIRMWARE_NAME - depends on MTD_SPLIT_FIRMWARE - default "firmware" - -+config MTD_UIMAGE_SPLIT -+ bool "Enable split support for firmware partitions containing a uImage" -+ depends on MTD_SPLIT_FIRMWARE -+ default y -+ - source "drivers/mtd/mtdsplit/Kconfig" - - config MTD_SPLIT ---- a/drivers/mtd/mtdpart.c -+++ b/drivers/mtd/mtdpart.c -@@ -681,6 +681,37 @@ mtd_pad_erasesize(struct mtd_info *mtd, - return len; - } - -+#define UBOOT_MAGIC 0x27051956 -+ -+static void split_uimage(struct mtd_info *master, struct mtd_part *part) -+{ -+ struct { -+ __be32 magic; -+ __be32 pad[2]; -+ __be32 size; -+ } hdr; -+ size_t len; -+ -+ if (mtd_read(master, part->offset, sizeof(hdr), &len, (void *) &hdr)) -+ return; -+ -+ if (len != sizeof(hdr) || hdr.magic != cpu_to_be32(UBOOT_MAGIC)) -+ return; -+ -+ len = be32_to_cpu(hdr.size) + 0x40; -+ len = mtd_pad_erasesize(master, part->offset, len); -+ if (len + master->erasesize > part->mtd.size) -+ return; -+ -+ if (config_enabled(CONFIG_MTD_SPLIT_UIMAGE_FW)) -+ pr_err("Dedicated partitioner didn't split firmware partition, please fill a bug report!\n"); -+ else -+ pr_warn("Support for built-in firmware splitter will be removed, please use CONFIG_MTD_SPLIT_UIMAGE_FW\n"); -+ -+ __mtd_add_partition(master, "rootfs", part->offset + len, -+ part->mtd.size - len, false); -+} -+ - #ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME - #define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME - #else -@@ -689,7 +720,14 @@ mtd_pad_erasesize(struct mtd_info *mtd, - - static void split_firmware(struct mtd_info *master, struct mtd_part *part) - { -- run_parsers_by_type(part, MTD_PARSER_TYPE_FIRMWARE); -+ int ret; -+ -+ ret = run_parsers_by_type(part, MTD_PARSER_TYPE_FIRMWARE); -+ if (ret > 0) -+ return; -+ -+ if (config_enabled(CONFIG_MTD_UIMAGE_SPLIT)) -+ split_uimage(master, part); - } - - void __weak arch_split_mtd_part(struct mtd_info *master, const char *name, diff --git a/target/linux/generic/patches-3.18/408-mtd-old-rootfs-squashfs-splitter.patch b/target/linux/generic/patches-3.18/408-mtd-old-rootfs-squashfs-splitter.patch deleted file mode 100644 index ca81958432..0000000000 --- a/target/linux/generic/patches-3.18/408-mtd-old-rootfs-squashfs-splitter.patch +++ /dev/null @@ -1,76 +0,0 @@ ---- a/drivers/mtd/Kconfig -+++ b/drivers/mtd/Kconfig -@@ -18,6 +18,11 @@ config MTD_ROOTFS_ROOT_DEV - bool "Automatically set 'rootfs' partition to be root filesystem" - default y - -+config MTD_ROOTFS_SPLIT -+ bool "Automatically split 'rootfs' partition for squashfs" -+ select MTD_SPLIT -+ default y -+ - config MTD_SPLIT_FIRMWARE - bool "Automatically split firmware partition for kernel+rootfs" - default y ---- a/drivers/mtd/mtdpart.c -+++ b/drivers/mtd/mtdpart.c -@@ -681,6 +681,47 @@ mtd_pad_erasesize(struct mtd_info *mtd, - return len; - } - -+static int split_squashfs(struct mtd_info *master, int offset, int *split_offset) -+{ -+ size_t squashfs_len; -+ int len, ret; -+ -+ ret = mtd_get_squashfs_len(master, offset, &squashfs_len); -+ if (ret) -+ return ret; -+ -+ len = mtd_pad_erasesize(master, offset, squashfs_len); -+ *split_offset = offset + len; -+ -+ return 0; -+} -+ -+static void split_rootfs_data(struct mtd_info *master, struct mtd_part *part) -+{ -+ unsigned int split_offset = 0; -+ unsigned int split_size; -+ int ret; -+ -+ ret = split_squashfs(master, part->offset, &split_offset); -+ if (ret) -+ return; -+ -+ if (split_offset <= 0) -+ return; -+ -+ if (config_enabled(CONFIG_MTD_SPLIT_SQUASHFS_ROOT)) -+ pr_err("Dedicated partitioner didn't create \"rootfs_data\" partition, please fill a bug report!\n"); -+ else -+ pr_warn("Support for built-in \"rootfs_data\" splitter will be removed, please use CONFIG_MTD_SPLIT_SQUASHFS_ROOT\n"); -+ -+ split_size = part->mtd.size - (split_offset - part->offset); -+ printk(KERN_INFO "mtd: partition \"%s\" created automatically, ofs=0x%x, len=0x%x\n", -+ ROOTFS_SPLIT_NAME, split_offset, split_size); -+ -+ __mtd_add_partition(master, ROOTFS_SPLIT_NAME, split_offset, -+ split_size, false); -+} -+ - #define UBOOT_MAGIC 0x27051956 - - static void split_uimage(struct mtd_info *master, struct mtd_part *part) -@@ -743,7 +784,10 @@ static void mtd_partition_split(struct m - return; - - if (!strcmp(part->mtd.name, "rootfs")) { -- run_parsers_by_type(part, MTD_PARSER_TYPE_ROOTFS); -+ int num = run_parsers_by_type(part, MTD_PARSER_TYPE_ROOTFS); -+ -+ if (num <= 0 && config_enabled(CONFIG_MTD_ROOTFS_SPLIT)) -+ split_rootfs_data(master, part); - - rootfs_found = 1; - } diff --git a/target/linux/generic/patches-3.18/411-mtd-partial_eraseblock_write.patch b/target/linux/generic/patches-3.18/411-mtd-partial_eraseblock_write.patch index 4a17ccd8d6..0bb7be0848 100644 --- a/target/linux/generic/patches-3.18/411-mtd-partial_eraseblock_write.patch +++ b/target/linux/generic/patches-3.18/411-mtd-partial_eraseblock_write.patch @@ -2,7 +2,7 @@ +++ b/drivers/mtd/mtdpart.c @@ -35,6 +35,8 @@ #include "mtdcore.h" - #include "mtdsplit.h" + #include "mtdsplit/mtdsplit.h" +#define MTD_ERASE_PARTIAL 0x8000 /* partition only covers parts of an erase block */ + diff --git a/target/linux/generic/patches-3.18/430-mtd-add-myloader-partition-parser.patch b/target/linux/generic/patches-3.18/430-mtd-add-myloader-partition-parser.patch index ffc9e2199c..45af25dd61 100644 --- a/target/linux/generic/patches-3.18/430-mtd-add-myloader-partition-parser.patch +++ b/target/linux/generic/patches-3.18/430-mtd-add-myloader-partition-parser.patch @@ -1,6 +1,6 @@ --- a/drivers/mtd/Kconfig +++ b/drivers/mtd/Kconfig -@@ -189,6 +189,22 @@ config MTD_BCM47XX_PARTS +@@ -184,6 +184,22 @@ config MTD_BCM47XX_PARTS This provides partitions parser for devices based on BCM47xx boards. @@ -25,7 +25,7 @@ # --- a/drivers/mtd/Makefile +++ b/drivers/mtd/Makefile -@@ -19,6 +19,7 @@ obj-$(CONFIG_MTD_AFS_PARTS) += afs.o +@@ -15,6 +15,7 @@ obj-$(CONFIG_MTD_AFS_PARTS) += afs.o obj-$(CONFIG_MTD_AR7_PARTS) += ar7part.o obj-$(CONFIG_MTD_BCM63XX_PARTS) += bcm63xxpart.o obj-$(CONFIG_MTD_BCM47XX_PARTS) += bcm47xxpart.o diff --git a/target/linux/generic/patches-3.18/431-mtd-bcm47xxpart-support-TRX-data-partition-being-UBI.patch b/target/linux/generic/patches-3.18/431-mtd-bcm47xxpart-support-TRX-data-partition-being-UBI.patch index 4c4720341e..46881fca2c 100644 --- a/target/linux/generic/patches-3.18/431-mtd-bcm47xxpart-support-TRX-data-partition-being-UBI.patch +++ b/target/linux/generic/patches-3.18/431-mtd-bcm47xxpart-support-TRX-data-partition-being-UBI.patch @@ -17,7 +17,7 @@ u64 offset, uint32_t mask_flags) { part->name = name; -@@ -58,6 +59,26 @@ static void bcm47xxpart_add_part(struct +@@ -58,6 +59,26 @@ static void bcm47xxpart_add_part(struct part->mask_flags = mask_flags; } diff --git a/target/linux/generic/patches-3.18/502-yaffs-3.10-disable-proc-entry.patch b/target/linux/generic/patches-3.18/502-yaffs-3.10-disable-proc-entry.patch index 5b73d3898b..5345678c56 100644 --- a/target/linux/generic/patches-3.18/502-yaffs-3.10-disable-proc-entry.patch +++ b/target/linux/generic/patches-3.18/502-yaffs-3.10-disable-proc-entry.patch @@ -8,7 +8,7 @@ static struct proc_dir_entry *my_proc_entry; static char *yaffs_dump_dev_part0(char *buf, struct yaffs_dev *dev) -@@ -3398,6 +3399,7 @@ static int yaffs_proc_write(struct file +@@ -3398,6 +3399,7 @@ static int yaffs_proc_write(struct file return yaffs_proc_debug_write(file, buf, count, data); return yaffs_proc_write_trace_options(file, buf, count, data); }