[U-Boot] [PATCH 5/6] cmd: mtdparts: support runtime generated mtdparts
Ladislav Michl
ladis at linux-mips.org
Sun Jun 5 19:43:09 CEST 2016
Some CPUs contains boot ROM code capable reading first few blocks
(where SPL resides) of NAND flash and executing it. It is wise to
create separate partition here for SPL. As block size depends on
NAND chip used, we could either use worst case (biggest) partition
size or base its size on actual block size. This patch adds support
for the latter option.
Signed-off-by: Ladislav Michl <ladis at linux-mips.org>
---
cmd/mtdparts.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/cmd/mtdparts.c b/cmd/mtdparts.c
index 53074a1..71c7acb 100644
--- a/cmd/mtdparts.c
+++ b/cmd/mtdparts.c
@@ -109,17 +109,20 @@ DECLARE_GLOBAL_DATA_PTR;
#define MTD_WRITEABLE_CMD 1
/* default values for mtdids and mtdparts variables */
-#if defined(MTDIDS_DEFAULT)
-static const char *const mtdids_default = MTDIDS_DEFAULT;
-#else
-static const char *const mtdids_default = NULL;
+#if !defined(MTDIDS_DEFAULT)
+#define MTDIDS_DEFAULT NULL
#endif
-
-#if defined(MTDPARTS_DEFAULT)
-static const char *const mtdparts_default = MTDPARTS_DEFAULT;
+#if !defined(MTDPARTS_DEFAULT)
+#define MTDPARTS_DEFAULT NULL
+#endif
+#if defined(CONFIG_SYS_MTDPARTS_DEFAULT_RUNTIME)
+#define MTD_DEFAULTS_READONLY
+extern void board_mtdparts_default(const char **mtdids, const char **mtdparts);
#else
-static const char *const mtdparts_default = NULL;
+#define MTD_DEFAULTS_READONLY const
#endif
+static const char *MTD_DEFAULTS_READONLY mtdids_default = MTDIDS_DEFAULT;
+static const char *MTD_DEFAULTS_READONLY mtdparts_default = MTDPARTS_DEFAULT;
/* copies of last seen 'mtdids', 'mtdparts' and 'partition' env variables */
#define MTDIDS_MAXLEN 128
@@ -1725,6 +1728,9 @@ int mtdparts_init(void)
memset(last_ids, 0, MTDIDS_MAXLEN);
memset(last_parts, 0, MTDPARTS_MAXLEN);
memset(last_partition, 0, PARTITION_MAXLEN);
+#if defined(CONFIG_SYS_MTDPARTS_DEFAULT_RUNTIME)
+ board_mtdparts_default(&mtdids_default, &mtdparts_default);
+#endif
use_defaults = 1;
initialized = 1;
}
--
2.1.4
More information about the U-Boot
mailing list