kernel/3.10: add new Kconfig option for firmware partition split
authorGabor Juhos <juhosg@openwrt.org>
Sun, 15 Sep 2013 17:03:29 +0000 (17:03 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Sun, 15 Sep 2013 17:03:29 +0000 (17:03 +0000)
Add a new kernel config option for generic firmware partition
split support and change the uImage split support to depend on
the new option. Aslo rename the MTD_UIMAGE_SPLIT_NAME option to
MTD_SPLIT_FIRMWARE_NAME to make it more generic.

The patch is in preparation for multiple firmware format
support.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
SVN-Revision: 38002

target/linux/ar71xx/config-3.10
target/linux/generic/config-3.10
target/linux/generic/patches-3.10/400-mtd-add-rootfs-split-support.patch
target/linux/generic/patches-3.10/430-mtd-add-myloader-partition-parser.patch
target/linux/lantiq/config-default
target/linux/ramips/mt7620a/config-3.10
target/linux/ramips/rt288x/config-3.10
target/linux/ramips/rt305x/config-3.10
target/linux/ramips/rt3883/config-3.10

index 6c75f144206ef7600418829c03f777b1ea941629..82559b8e125cfaf9d7636afa62c01185c4ffb40a 100644 (file)
@@ -207,6 +207,7 @@ CONFIG_MTD_MYLOADER_PARTS=y
 CONFIG_MTD_PHYSMAP=y
 CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-2
 CONFIG_MTD_REDBOOT_PARTS=y
+CONFIG_MTD_SPLIT_FIRMWARE=y
 CONFIG_MTD_TPLINK_PARTS=y
 CONFIG_MTD_UIMAGE_SPLIT=y
 CONFIG_MTD_WRT160NL_PARTS=y
index 3cf5bb2e0362c5c4bdd0ed0ff8ba61f95608ee66..0f3b78f2a73b882588aa2e46688c60f6c40e75bd 100644 (file)
@@ -1931,12 +1931,13 @@ CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1
 CONFIG_MTD_ROOTFS_ROOT_DEV=y
 CONFIG_MTD_ROOTFS_SPLIT=y
 # CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_SPLIT_FIRMWARE is not set
+CONFIG_MTD_SPLIT_FIRMWARE_NAME="firmware"
 # CONFIG_MTD_SST25L is not set
 # CONFIG_MTD_SWAP is not set
 # CONFIG_MTD_TESTS is not set
 # CONFIG_MTD_UBI is not set
 # CONFIG_MTD_UIMAGE_SPLIT is not set
-CONFIG_MTD_UIMAGE_SPLIT_NAME="firmware"
 # CONFIG_MUTEX_SPIN_ON_OWNER is not set
 # CONFIG_MV643XX_ETH is not set
 # CONFIG_MVMDIO is not set
index edbb70411565121e3c7f77112ea64146948eb042..6a4c16134e9e8f7183d3ed8bac2f41be3c7e1f5c 100644 (file)
@@ -1,6 +1,6 @@
 --- a/drivers/mtd/Kconfig
 +++ b/drivers/mtd/Kconfig
-@@ -12,6 +12,27 @@ menuconfig MTD
+@@ -12,6 +12,32 @@ menuconfig MTD
  
  if MTD
  
 +      bool "Automatically split 'rootfs' partition for squashfs"
 +      default y
 +
-+config MTD_UIMAGE_SPLIT
-+      bool "Automatically split off rootfs from a kernel partition containing a uImage"
++config MTD_SPLIT_FIRMWARE
++      bool "Automatically split firmware partition for kernel+rootfs"
 +      default y
 +
-+config MTD_UIMAGE_SPLIT_NAME
-+      string "uImage partition name"
-+      depends on MTD_UIMAGE_SPLIT
++config MTD_SPLIT_FIRMWARE_NAME
++      string "Firmware partition 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
++
 +endmenu
 +
  config MTD_TESTS
  int mtd_del_partition(struct mtd_info *master, int partno)
  {
        struct mtd_part *slave, *next;
-@@ -613,6 +627,148 @@ int mtd_del_partition(struct mtd_info *m
+@@ -613,6 +627,151 @@ int mtd_del_partition(struct mtd_info *m
  }
  EXPORT_SYMBOL_GPL(mtd_del_partition);
  
 +
 +#define UBOOT_MAGIC   0x27051956
 +
-+#ifdef CONFIG_MTD_UIMAGE_SPLIT_NAME
-+#define UIMAGE_SPLIT_NAME     CONFIG_MTD_UIMAGE_SPLIT_NAME
-+#else
-+#define UIMAGE_SPLIT_NAME     "unused"
-+#endif
-+
 +static void split_uimage(struct mtd_info *master, struct mtd_part *part)
 +{
 +      struct {
 +      } hdr;
 +      size_t len;
 +
-+      if (strcmp(part->mtd.name, UIMAGE_SPLIT_NAME) != 0)
-+              return;
-+
 +      if (mtd_read(master, part->offset, sizeof(hdr), &len, (void *) &hdr))
 +              return;
 +
 +                          part->mtd.size - len, false);
 +}
 +
++#ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME
++#define SPLIT_FIRMWARE_NAME   CONFIG_MTD_SPLIT_FIRMWARE_NAME
++#else
++#define SPLIT_FIRMWARE_NAME   "unused"
++#endif
++
++static void split_firmware(struct mtd_info *master, struct mtd_part *part)
++{
++      if (config_enabled(CONFIG_MTD_UIMAGE_SPLIT))
++              split_uimage(master, part);
++}
++
 +void __weak arch_split_mtd_part(struct mtd_info *master, const char *name,
 +                                int offset, int size)
 +{
 +}
 +
-+
 +static void mtd_partition_split(struct mtd_info *master, struct mtd_part *part)
 +{
 +      static int rootfs_found = 0;
 +                      split_rootfs_data(master, part);
 +      }
 +
-+      if (config_enabled(CONFIG_MTD_UIMAGE_SPLIT))
-+              split_uimage(master, part);
++      if (!strcmp(part->mtd.name, SPLIT_FIRMWARE_NAME) &&
++          config_enabled(CONFIG_MTD_SPLIT_FIRMWARE))
++              split_firmware(master, part);
 +
 +      arch_split_mtd_part(master, part->mtd.name, part->offset,
 +                          part->mtd.size);
  /*
   * 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 +798,7 @@ int add_mtd_partitions(struct mtd_info *
+@@ -642,6 +801,7 @@ int add_mtd_partitions(struct mtd_info *
                mutex_unlock(&mtd_partitions_mutex);
  
                add_mtd_device(&slave->mtd);
index 4b61307c3774d2ed3777ccda07a15cb188b4de37..bca00230ae4e406f676e5ecb5d142d187bb5454a 100644 (file)
@@ -1,6 +1,6 @@
 --- a/drivers/mtd/Kconfig
 +++ b/drivers/mtd/Kconfig
-@@ -176,6 +176,22 @@ config MTD_BCM47XX_PARTS
+@@ -181,6 +181,22 @@ config MTD_BCM47XX_PARTS
          This provides partitions parser for devices based on BCM47xx
          boards.
  
index 574fee39701e625e999eec2c4e59a86036c47f23..0ba6de9a40d98830d4815255cad35b815961a6da 100644 (file)
@@ -105,6 +105,7 @@ CONFIG_MTD_CMDLINE_PARTS=y
 CONFIG_MTD_LANTIQ=y
 CONFIG_MTD_OF_PARTS=y
 CONFIG_MTD_PHYSMAP_OF=y
+CONFIG_MTD_SPLIT_FIRMWARE=y
 CONFIG_MTD_UIMAGE_SPLIT=y
 CONFIG_NEED_DMA_MAP_STATE=y
 CONFIG_NEED_PER_CPU_KM=y
index fe54475be4a6e50ea5fec7f8608d3b89d31001c5..618c27a901e788bb2f3f4259b6bf3442cceebf14 100644 (file)
@@ -109,6 +109,7 @@ CONFIG_MTD_M25P80=y
 CONFIG_MTD_OF_PARTS=y
 CONFIG_MTD_PHYSMAP=y
 CONFIG_MTD_PHYSMAP_OF=y
+CONFIG_MTD_SPLIT_FIRMWARE=y
 CONFIG_MTD_UIMAGE_SPLIT=y
 CONFIG_NEED_DMA_MAP_STATE=y
 CONFIG_NEED_PER_CPU_KM=y
index b6bfe18ce7fc5a750ae22ef68f39e061dce64bf7..2b899b528b1b2814872503b79d820849fbee5e6f 100644 (file)
@@ -97,6 +97,7 @@ CONFIG_MTD_M25P80=y
 CONFIG_MTD_OF_PARTS=y
 CONFIG_MTD_PHYSMAP=y
 CONFIG_MTD_PHYSMAP_OF=y
+CONFIG_MTD_SPLIT_FIRMWARE=y
 CONFIG_MTD_UIMAGE_SPLIT=y
 CONFIG_NEED_DMA_MAP_STATE=y
 CONFIG_NEED_PER_CPU_KM=y
index fb414fa0be6a9479fe31bd7474405552f2627856..47d6d18060959a1e4b7f0e769030acc4a49d7d53 100644 (file)
@@ -100,6 +100,7 @@ CONFIG_MTD_M25P80=y
 CONFIG_MTD_OF_PARTS=y
 CONFIG_MTD_PHYSMAP=y
 CONFIG_MTD_PHYSMAP_OF=y
+CONFIG_MTD_SPLIT_FIRMWARE=y
 CONFIG_MTD_UIMAGE_SPLIT=y
 CONFIG_NEED_DMA_MAP_STATE=y
 CONFIG_NEED_PER_CPU_KM=y
index 3d2d9fe698bc8c99748d25d3cc15ca14871bdda5..509af454fb2d37e2fba8c88914599ff6956cb4e8 100644 (file)
@@ -100,6 +100,7 @@ CONFIG_MTD_M25P80=y
 CONFIG_MTD_OF_PARTS=y
 CONFIG_MTD_PHYSMAP=y
 CONFIG_MTD_PHYSMAP_OF=y
+CONFIG_MTD_SPLIT_FIRMWARE=y
 CONFIG_MTD_UIMAGE_SPLIT=y
 CONFIG_NEED_DMA_MAP_STATE=y
 CONFIG_NEED_PER_CPU_KM=y