3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 * Robert Schwebel, Pengutronix, <r.schwebel@pengutronix.de>
9 * Kai-Uwe Bloem, Auerswald GmbH & Co KG, <linux-development@auerswald.de>
12 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
14 * Added support for reading flash partition table from environment.
15 * Parsing routines are based on driver/mtd/cmdline.c from the linux 2.4
18 * $Id: cmdlinepart.c,v 1.17 2004/11/26 11:18:47 lavinen Exp $
19 * Copyright 2002 SYSGO Real-Time Solutions GmbH
21 * See file CREDITS for list of people who contributed to this
24 * This program is free software; you can redistribute it and/or
25 * modify it under the terms of the GNU General Public License as
26 * published by the Free Software Foundation; either version 2 of
27 * the License, or (at your option) any later version.
29 * This program is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU General Public License for more details.
34 * You should have received a copy of the GNU General Public License
35 * along with this program; if not, write to the Free Software
36 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
41 * Three environment variables are used by the parsing routines:
43 * 'partition' - keeps current partition identifier
45 * partition := <part-id>
46 * <part-id> := <dev-id>,part_num
49 * 'mtdids' - linux kernel mtd device id <-> u-boot device id mapping
51 * mtdids=<idmap>[,<idmap>,...]
53 * <idmap> := <dev-id>=<mtd-id>
54 * <dev-id> := 'nand'|'nor'|'onenand'<dev-num>
55 * <dev-num> := mtd device number, 0...
56 * <mtd-id> := unique device tag used by linux kernel to find mtd device (mtd->name)
59 * 'mtdparts' - partition list
61 * mtdparts=mtdparts=<mtd-def>[;<mtd-def>...]
63 * <mtd-def> := <mtd-id>:<part-def>[,<part-def>...]
64 * <mtd-id> := unique device tag used by linux kernel to find mtd device (mtd->name)
65 * <part-def> := <size>[@<offset>][<name>][<ro-flag>]
66 * <size> := standard linux memsize OR '-' to denote all remaining space
67 * <offset> := partition start offset within the device
68 * <name> := '(' NAME ')'
69 * <ro-flag> := when set to 'ro' makes partition read-only (not used, passed to kernel)
72 * - each <mtd-id> used in mtdparts must albo exist in 'mtddis' mapping
73 * - if the above variables are not set defaults for a given target are used
77 * 1 NOR Flash, with 1 single writable partition:
78 * mtdids=nor0=edb7312-nor
79 * mtdparts=mtdparts=edb7312-nor:-
81 * 1 NOR Flash with 2 partitions, 1 NAND with one
82 * mtdids=nor0=edb7312-nor,nand0=edb7312-nand
83 * mtdparts=mtdparts=edb7312-nor:256k(ARMboot)ro,-(root);edb7312-nand:-(home)
90 #include <jffs2/load_kernel.h>
91 #include <linux/list.h>
92 #include <linux/ctype.h>
93 #include <cramfs/cramfs_fs.h>
95 #if defined(CONFIG_CMD_NAND)
96 #ifdef CONFIG_NAND_LEGACY
97 #include <linux/mtd/nand_legacy.h>
98 #else /* !CONFIG_NAND_LEGACY */
99 #include <linux/mtd/nand.h>
101 #endif /* !CONFIG_NAND_LEGACY */
104 #if defined(CONFIG_CMD_ONENAND)
105 #include <linux/mtd/mtd.h>
106 #include <linux/mtd/onenand.h>
107 #include <onenand_uboot.h>
110 /* enable/disable debugging messages */
111 #define DEBUG_MTDPARTS
112 #undef DEBUG_MTDPARTS
114 #ifdef DEBUG_MTDPARTS
115 # define DEBUGF(fmt, args...) printf(fmt ,##args)
117 # define DEBUGF(fmt, args...)
120 /* special size referring to all the remaining space in a partition */
121 #define SIZE_REMAINING 0xFFFFFFFF
123 /* special offset value, it is used when not provided by user
125 * this value is used temporarily during parsing, later such offests
126 * are recalculated */
127 #define OFFSET_NOT_SPECIFIED 0xFFFFFFFF
129 /* minimum partition size */
130 #define MIN_PART_SIZE 4096
132 /* this flag needs to be set in part_info struct mask_flags
133 * field for read-only partitions */
134 #define MTD_WRITEABLE_CMD 1
136 /* default values for mtdids and mtdparts variables */
137 #if defined(MTDIDS_DEFAULT)
138 static const char *const mtdids_default = MTDIDS_DEFAULT;
140 #warning "MTDIDS_DEFAULT not defined!"
141 static const char *const mtdids_default = NULL;
144 #if defined(MTDPARTS_DEFAULT)
145 static const char *const mtdparts_default = MTDPARTS_DEFAULT;
147 #warning "MTDPARTS_DEFAULT not defined!"
148 static const char *const mtdparts_default = NULL;
151 /* copies of last seen 'mtdids', 'mtdparts' and 'partition' env variables */
152 #define MTDIDS_MAXLEN 128
153 #define MTDPARTS_MAXLEN 512
154 #define PARTITION_MAXLEN 16
155 static char last_ids[MTDIDS_MAXLEN];
156 static char last_parts[MTDPARTS_MAXLEN];
157 static char last_partition[PARTITION_MAXLEN];
159 /* low level jffs2 cache cleaning routine */
160 extern void jffs2_free_cache(struct part_info *part);
162 /* mtdids mapping list, filled by parse_ids() */
163 struct list_head mtdids;
165 /* device/partition list, parse_cmdline() parses into here */
166 struct list_head devices;
168 /* current active device and partition number */
169 static struct mtd_device *current_dev = NULL;
170 static u8 current_partnum = 0;
172 static struct part_info* mtd_part_info(struct mtd_device *dev, unsigned int part_num);
174 /* command line only routines */
175 static struct mtdids* id_find_by_mtd_id(const char *mtd_id, unsigned int mtd_id_len);
176 static int device_del(struct mtd_device *dev);
179 * Parses a string into a number. The number stored at ptr is
180 * potentially suffixed with K (for kilobytes, or 1024 bytes),
181 * M (for megabytes, or 1048576 bytes), or G (for gigabytes, or
182 * 1073741824). If the number is suffixed with K, M, or G, then
183 * the return value is the number multiplied by one kilobyte, one
184 * megabyte, or one gigabyte, respectively.
186 * @param ptr where parse begins
187 * @param retptr output pointer to next char after parse completes (output)
188 * @return resulting unsigned int
190 static unsigned long memsize_parse (const char *const ptr, const char **retptr)
192 unsigned long ret = simple_strtoul(ptr, (char **)retptr, 0);
213 * Format string describing supplied size. This routine does the opposite job
214 * to memsize_parse(). Size in bytes is converted to string and if possible
215 * shortened by using k (kilobytes), m (megabytes) or g (gigabytes) suffix.
217 * Note, that this routine does not check for buffer overflow, it's the caller
218 * who must assure enough space.
220 * @param buf output buffer
221 * @param size size to be converted to string
223 static void memsize_format(char *buf, u32 size)
225 #define SIZE_GB ((u32)1024*1024*1024)
226 #define SIZE_MB ((u32)1024*1024)
227 #define SIZE_KB ((u32)1024)
229 if ((size % SIZE_GB) == 0)
230 sprintf(buf, "%ug", size/SIZE_GB);
231 else if ((size % SIZE_MB) == 0)
232 sprintf(buf, "%um", size/SIZE_MB);
233 else if (size % SIZE_KB == 0)
234 sprintf(buf, "%uk", size/SIZE_KB);
236 sprintf(buf, "%u", size);
240 * This routine does global indexing of all partitions. Resulting index for
241 * current partition is saved in 'mtddevnum'. Current partition name in
244 static void index_partitions(void)
248 struct part_info *part;
249 struct list_head *dentry;
250 struct mtd_device *dev;
252 DEBUGF("--- index partitions ---\n");
256 list_for_each(dentry, &devices) {
257 dev = list_entry(dentry, struct mtd_device, link);
258 if (dev == current_dev) {
259 mtddevnum += current_partnum;
260 sprintf(buf, "%d", mtddevnum);
261 setenv("mtddevnum", buf);
264 mtddevnum += dev->num_parts;
267 part = mtd_part_info(current_dev, current_partnum);
268 setenv("mtddevname", part->name);
270 DEBUGF("=> mtddevnum %d,\n=> mtddevname %s\n", mtddevnum, part->name);
272 setenv("mtddevnum", NULL);
273 setenv("mtddevname", NULL);
275 DEBUGF("=> mtddevnum NULL\n=> mtddevname NULL\n");
280 * Save current device and partition in environment variable 'partition'.
282 static void current_save(void)
286 DEBUGF("--- current_save ---\n");
289 sprintf(buf, "%s%d,%d", MTD_DEV_TYPE(current_dev->id->type),
290 current_dev->id->num, current_partnum);
292 setenv("partition", buf);
293 strncpy(last_partition, buf, 16);
295 DEBUGF("=> partition %s\n", buf);
297 setenv("partition", NULL);
298 last_partition[0] = '\0';
300 DEBUGF("=> partition NULL\n");
306 * Performs sanity check for supplied NOR flash partition. Table of existing
307 * NOR flash devices is searched and partition device is located. Alignment
308 * with the granularity of NOR flash sectors is verified.
310 * @param id of the parent device
311 * @param part partition to validate
312 * @return 0 if partition is valid, 1 otherwise
314 static int part_validate_nor(struct mtdids *id, struct part_info *part)
316 #if defined(CONFIG_CMD_FLASH)
317 /* info for FLASH chips */
318 extern flash_info_t flash_info[];
321 u32 end_offset, sector_size = 0;
324 flash = &flash_info[id->num];
326 /* size of last sector */
327 part->sector_size = flash->size -
328 (flash->start[flash->sector_count-1] - flash->start[0]);
331 for (i = 0; i < flash->sector_count; i++) {
332 if ((flash->start[i] - flash->start[0]) == part->offset) {
337 if (offset_aligned == 0) {
338 printf("%s%d: partition (%s) start offset alignment incorrect\n",
339 MTD_DEV_TYPE(id->type), id->num, part->name);
343 end_offset = part->offset + part->size;
345 for (i = 0; i < flash->sector_count; i++) {
347 sector_size = flash->start[i] - flash->start[i-1];
348 if (part->sector_size < sector_size)
349 part->sector_size = sector_size;
351 if ((flash->start[i] - flash->start[0]) == end_offset)
355 if (offset_aligned || flash->size == end_offset)
358 printf("%s%d: partition (%s) size alignment incorrect\n",
359 MTD_DEV_TYPE(id->type), id->num, part->name);
365 * Performs sanity check for supplied NAND flash partition. Table of existing
366 * NAND flash devices is searched and partition device is located. Alignment
367 * with the granularity of nand erasesize is verified.
369 * @param id of the parent device
370 * @param part partition to validate
371 * @return 0 if partition is valid, 1 otherwise
373 static int part_validate_nand(struct mtdids *id, struct part_info *part)
375 #if defined(CONFIG_CMD_NAND)
376 /* info for NAND chips */
379 nand = &nand_info[id->num];
381 part->sector_size = nand->erasesize;
383 if ((unsigned long)(part->offset) % nand->erasesize) {
384 printf("%s%d: partition (%s) start offset alignment incorrect\n",
385 MTD_DEV_TYPE(id->type), id->num, part->name);
389 if (part->size % nand->erasesize) {
390 printf("%s%d: partition (%s) size alignment incorrect\n",
391 MTD_DEV_TYPE(id->type), id->num, part->name);
402 * Performs sanity check for supplied OneNAND flash partition.
403 * Table of existing OneNAND flash devices is searched and partition device
404 * is located. Alignment with the granularity of nand erasesize is verified.
406 * @param id of the parent device
407 * @param part partition to validate
408 * @return 0 if partition is valid, 1 otherwise
410 static int part_validate_onenand(struct mtdids *id, struct part_info *part)
412 #if defined(CONFIG_CMD_ONENAND)
413 /* info for OneNAND chips */
414 struct mtd_info *mtd;
418 part->sector_size = mtd->erasesize;
420 if ((unsigned long)(part->offset) % mtd->erasesize) {
421 printf("%s%d: partition (%s) start offset"
422 "alignment incorrect\n",
423 MTD_DEV_TYPE(id->type), id->num, part->name);
427 if (part->size % mtd->erasesize) {
428 printf("%s%d: partition (%s) size alignment incorrect\n",
429 MTD_DEV_TYPE(id->type), id->num, part->name);
441 * Performs sanity check for supplied partition. Offset and size are verified
442 * to be within valid range. Partition type is checked and either
443 * parts_validate_nor() or parts_validate_nand() is called with the argument
446 * @param id of the parent device
447 * @param part partition to validate
448 * @return 0 if partition is valid, 1 otherwise
450 static int part_validate(struct mtdids *id, struct part_info *part)
452 if (part->size == SIZE_REMAINING)
453 part->size = id->size - part->offset;
455 if (part->offset > id->size) {
456 printf("%s: offset %08x beyond flash size %08x\n",
457 id->mtd_id, part->offset, id->size);
461 if ((part->offset + part->size) <= part->offset) {
462 printf("%s%d: partition (%s) size too big\n",
463 MTD_DEV_TYPE(id->type), id->num, part->name);
467 if (part->offset + part->size > id->size) {
468 printf("%s: partitioning exceeds flash size\n", id->mtd_id);
472 if (id->type == MTD_DEV_TYPE_NAND)
473 return part_validate_nand(id, part);
474 else if (id->type == MTD_DEV_TYPE_NOR)
475 return part_validate_nor(id, part);
476 else if (id->type == MTD_DEV_TYPE_ONENAND)
477 return part_validate_onenand(id, part);
479 DEBUGF("part_validate: invalid dev type\n");
485 * Delete selected partition from the partion list of the specified device.
487 * @param dev device to delete partition from
488 * @param part partition to delete
489 * @return 0 on success, 1 otherwise
491 static int part_del(struct mtd_device *dev, struct part_info *part)
493 u8 current_save_needed = 0;
495 /* if there is only one partition, remove whole device */
496 if (dev->num_parts == 1)
497 return device_del(dev);
499 /* otherwise just delete this partition */
501 if (dev == current_dev) {
502 /* we are modyfing partitions for the current device,
504 struct part_info *curr_pi;
505 curr_pi = mtd_part_info(current_dev, current_partnum);
508 if (curr_pi == part) {
509 printf("current partition deleted, resetting current to 0\n");
511 } else if (part->offset <= curr_pi->offset) {
514 current_save_needed = 1;
518 #ifdef CONFIG_NAND_LEGACY
519 jffs2_free_cache(part);
521 list_del(&part->link);
525 if (current_save_needed > 0)
534 * Delete all partitions from parts head list, free memory.
536 * @param head list of partitions to delete
538 static void part_delall(struct list_head *head)
540 struct list_head *entry, *n;
541 struct part_info *part_tmp;
543 /* clean tmp_list and free allocated memory */
544 list_for_each_safe(entry, n, head) {
545 part_tmp = list_entry(entry, struct part_info, link);
547 #ifdef CONFIG_NAND_LEGACY
548 jffs2_free_cache(part_tmp);
556 * Add new partition to the supplied partition list. Make sure partitions are
557 * sorted by offset in ascending order.
559 * @param head list this partition is to be added to
560 * @param new partition to be added
562 static int part_sort_add(struct mtd_device *dev, struct part_info *part)
564 struct list_head *entry;
565 struct part_info *new_pi, *curr_pi;
567 /* link partition to parrent dev */
570 if (list_empty(&dev->parts)) {
571 DEBUGF("part_sort_add: list empty\n");
572 list_add(&part->link, &dev->parts);
578 new_pi = list_entry(&part->link, struct part_info, link);
580 /* get current partition info if we are updating current device */
582 if (dev == current_dev)
583 curr_pi = mtd_part_info(current_dev, current_partnum);
585 list_for_each(entry, &dev->parts) {
586 struct part_info *pi;
588 pi = list_entry(entry, struct part_info, link);
590 /* be compliant with kernel cmdline, allow only one partition at offset zero */
591 if ((new_pi->offset == pi->offset) && (pi->offset == 0)) {
592 printf("cannot add second partition at offset 0\n");
596 if (new_pi->offset <= pi->offset) {
597 list_add_tail(&part->link, entry);
600 if (curr_pi && (pi->offset <= curr_pi->offset)) {
601 /* we are modyfing partitions for the current
602 * device, update current */
612 list_add_tail(&part->link, &dev->parts);
619 * Add provided partition to the partition list of a given device.
621 * @param dev device to which partition is added
622 * @param part partition to be added
623 * @return 0 on success, 1 otherwise
625 static int part_add(struct mtd_device *dev, struct part_info *part)
627 /* verify alignment and size */
628 if (part_validate(dev->id, part) != 0)
631 /* partition is ok, add it to the list */
632 if (part_sort_add(dev, part) != 0)
639 * Parse one partition definition, allocate memory and return pointer to this
640 * location in retpart.
642 * @param partdef pointer to the partition definition string i.e. <part-def>
643 * @param ret output pointer to next char after parse completes (output)
644 * @param retpart pointer to the allocated partition (output)
645 * @return 0 on success, 1 otherwise
647 static int part_parse(const char *const partdef, const char **ret, struct part_info **retpart)
649 struct part_info *part;
651 unsigned long offset;
654 unsigned int mask_flags;
661 /* fetch the partition size */
663 /* assign all remaining space to this partition */
664 DEBUGF("'-': remaining size assigned\n");
665 size = SIZE_REMAINING;
668 size = memsize_parse(p, &p);
669 if (size < MIN_PART_SIZE) {
670 printf("partition size too small (%lx)\n", size);
675 /* check for offset */
676 offset = OFFSET_NOT_SPECIFIED;
679 offset = memsize_parse(p, &p);
682 /* now look for the name */
685 if ((p = strchr(name, ')')) == NULL) {
686 printf("no closing ) found in partition name\n");
689 name_len = p - name + 1;
690 if ((name_len - 1) == 0) {
691 printf("empty partition name\n");
696 /* 0x00000000@0x00000000 */
701 /* test for options */
703 if (strncmp(p, "ro", 2) == 0) {
704 mask_flags |= MTD_WRITEABLE_CMD;
708 /* check for next partition definition */
710 if (size == SIZE_REMAINING) {
712 printf("no partitions allowed after a fill-up partition\n");
716 } else if ((*p == ';') || (*p == '\0')) {
719 printf("unexpected character '%c' at the end of partition\n", *p);
724 /* allocate memory */
725 part = (struct part_info *)malloc(sizeof(struct part_info) + name_len);
727 printf("out of memory\n");
730 memset(part, 0, sizeof(struct part_info) + name_len);
732 part->offset = offset;
733 part->mask_flags = mask_flags;
734 part->name = (char *)(part + 1);
737 /* copy user provided name */
738 strncpy(part->name, name, name_len - 1);
741 /* auto generated name in form of size@offset */
742 sprintf(part->name, "0x%08lx@0x%08lx", size, offset);
746 part->name[name_len - 1] = '\0';
747 INIT_LIST_HEAD(&part->link);
749 DEBUGF("+ partition: name %-22s size 0x%08x offset 0x%08x mask flags %d\n",
750 part->name, part->size,
751 part->offset, part->mask_flags);
758 * Check device number to be within valid range for given device type.
760 * @param dev device to validate
761 * @return 0 if device is valid, 1 otherwise
763 int mtd_device_validate(u8 type, u8 num, u32 *size)
765 if (type == MTD_DEV_TYPE_NOR) {
766 #if defined(CONFIG_CMD_FLASH)
767 if (num < CONFIG_SYS_MAX_FLASH_BANKS) {
768 extern flash_info_t flash_info[];
769 *size = flash_info[num].size;
774 printf("no such FLASH device: %s%d (valid range 0 ... %d\n",
775 MTD_DEV_TYPE(type), num, CONFIG_SYS_MAX_FLASH_BANKS - 1);
777 printf("support for FLASH devices not present\n");
779 } else if (type == MTD_DEV_TYPE_NAND) {
780 #if defined(CONFIG_CMD_NAND)
781 if (num < CONFIG_SYS_MAX_NAND_DEVICE) {
782 #ifndef CONFIG_NAND_LEGACY
783 *size = nand_info[num].size;
785 extern struct nand_chip nand_dev_desc[CONFIG_SYS_MAX_NAND_DEVICE];
786 *size = nand_dev_desc[num].totlen;
791 printf("no such NAND device: %s%d (valid range 0 ... %d)\n",
792 MTD_DEV_TYPE(type), num, CONFIG_SYS_MAX_NAND_DEVICE - 1);
794 printf("support for NAND devices not present\n");
796 } else if (type == MTD_DEV_TYPE_ONENAND) {
797 #if defined(CONFIG_CMD_ONENAND)
798 *size = onenand_mtd.size;
801 printf("support for OneNAND devices not present\n");
804 printf("Unknown defice type %d\n", type);
810 * Delete all mtd devices from a supplied devices list, free memory allocated for
811 * each device and delete all device partitions.
813 * @return 0 on success, 1 otherwise
815 static int device_delall(struct list_head *head)
817 struct list_head *entry, *n;
818 struct mtd_device *dev_tmp;
820 /* clean devices list */
821 list_for_each_safe(entry, n, head) {
822 dev_tmp = list_entry(entry, struct mtd_device, link);
824 part_delall(&dev_tmp->parts);
827 INIT_LIST_HEAD(&devices);
833 * If provided device exists it's partitions are deleted, device is removed
834 * from device list and device memory is freed.
836 * @param dev device to be deleted
837 * @return 0 on success, 1 otherwise
839 static int device_del(struct mtd_device *dev)
841 part_delall(&dev->parts);
842 list_del(&dev->link);
845 if (dev == current_dev) {
846 /* we just deleted current device */
847 if (list_empty(&devices)) {
850 /* reset first partition from first dev from the
851 * devices list as current */
852 current_dev = list_entry(devices.next, struct mtd_device, link);
864 * Search global device list and return pointer to the device of type and num
867 * @param type device type
868 * @param num device number
869 * @return NULL if requested device does not exist
871 static struct mtd_device* device_find(u8 type, u8 num)
873 struct list_head *entry;
874 struct mtd_device *dev_tmp;
876 list_for_each(entry, &devices) {
877 dev_tmp = list_entry(entry, struct mtd_device, link);
879 if ((dev_tmp->id->type == type) && (dev_tmp->id->num == num))
887 * Add specified device to the global device list.
889 * @param dev device to be added
891 static void device_add(struct mtd_device *dev)
893 u8 current_save_needed = 0;
895 if (list_empty(&devices)) {
898 current_save_needed = 1;
901 list_add_tail(&dev->link, &devices);
903 if (current_save_needed > 0)
910 * Parse device type, name and mtd-id. If syntax is ok allocate memory and
911 * return pointer to the device structure.
913 * @param mtd_dev pointer to the device definition string i.e. <mtd-dev>
914 * @param ret output pointer to next char after parse completes (output)
915 * @param retdev pointer to the allocated device (output)
916 * @return 0 on success, 1 otherwise
918 static int device_parse(const char *const mtd_dev, const char **ret, struct mtd_device **retdev)
920 struct mtd_device *dev;
921 struct part_info *part;
924 unsigned int mtd_id_len;
925 const char *p, *pend;
927 struct list_head *entry, *n;
936 DEBUGF("===device_parse===\n");
940 if (!(p = strchr(mtd_id, ':'))) {
941 printf("no <mtd-id> identifier\n");
944 mtd_id_len = p - mtd_id + 1;
947 /* verify if we have a valid device specified */
948 if ((id = id_find_by_mtd_id(mtd_id, mtd_id_len - 1)) == NULL) {
949 printf("invalid mtd device '%.*s'\n", mtd_id_len - 1, mtd_id);
953 DEBUGF("dev type = %d (%s), dev num = %d, mtd-id = %s\n",
954 id->type, MTD_DEV_TYPE(id->type),
955 id->num, id->mtd_id);
956 pend = strchr(p, ';');
957 DEBUGF("parsing partitions %.*s\n", (pend ? pend - p : strlen(p)), p);
960 /* parse partitions */
964 if ((dev = device_find(id->type, id->num)) != NULL) {
965 /* if device already exists start at the end of the last partition */
966 part = list_entry(dev->parts.prev, struct part_info, link);
967 offset = part->offset + part->size;
970 while (p && (*p != '\0') && (*p != ';')) {
972 if ((part_parse(p, &p, &part) != 0) || (!part))
975 /* calculate offset when not specified */
976 if (part->offset == OFFSET_NOT_SPECIFIED)
977 part->offset = offset;
979 offset = part->offset;
981 /* verify alignment and size */
982 if (part_validate(id, part) != 0)
985 offset += part->size;
987 /* partition is ok, add it to the list */
988 list_add_tail(&part->link, &tmp_list);
993 part_delall(&tmp_list);
997 if (num_parts == 0) {
998 printf("no partitions for device %s%d (%s)\n",
999 MTD_DEV_TYPE(id->type), id->num, id->mtd_id);
1003 DEBUGF("\ntotal partitions: %d\n", num_parts);
1005 /* check for next device presence */
1009 } else if (*p == '\0') {
1012 printf("unexpected character '%c' at the end of device\n", *p);
1018 /* allocate memory for mtd_device structure */
1019 if ((dev = (struct mtd_device *)malloc(sizeof(struct mtd_device))) == NULL) {
1020 printf("out of memory\n");
1023 memset(dev, 0, sizeof(struct mtd_device));
1025 dev->num_parts = 0; /* part_sort_add increments num_parts */
1026 INIT_LIST_HEAD(&dev->parts);
1027 INIT_LIST_HEAD(&dev->link);
1029 /* move partitions from tmp_list to dev->parts */
1030 list_for_each_safe(entry, n, &tmp_list) {
1031 part = list_entry(entry, struct part_info, link);
1033 if (part_sort_add(dev, part) != 0) {
1046 * Initialize global device list.
1048 * @return 0 on success, 1 otherwise
1050 static int mtd_devices_init(void)
1052 last_parts[0] = '\0';
1056 return device_delall(&devices);
1060 * Search global mtdids list and find id of requested type and number.
1062 * @return pointer to the id if it exists, NULL otherwise
1064 static struct mtdids* id_find(u8 type, u8 num)
1066 struct list_head *entry;
1069 list_for_each(entry, &mtdids) {
1070 id = list_entry(entry, struct mtdids, link);
1072 if ((id->type == type) && (id->num == num))
1080 * Search global mtdids list and find id of a requested mtd_id.
1082 * Note: first argument is not null terminated.
1084 * @param mtd_id string containing requested mtd_id
1085 * @param mtd_id_len length of supplied mtd_id
1086 * @return pointer to the id if it exists, NULL otherwise
1088 static struct mtdids* id_find_by_mtd_id(const char *mtd_id, unsigned int mtd_id_len)
1090 struct list_head *entry;
1093 DEBUGF("--- id_find_by_mtd_id: '%.*s' (len = %d)\n",
1094 mtd_id_len, mtd_id, mtd_id_len);
1096 list_for_each(entry, &mtdids) {
1097 id = list_entry(entry, struct mtdids, link);
1099 DEBUGF("entry: '%s' (len = %d)\n",
1100 id->mtd_id, strlen(id->mtd_id));
1102 if (mtd_id_len != strlen(id->mtd_id))
1104 if (strncmp(id->mtd_id, mtd_id, mtd_id_len) == 0)
1112 * Parse device id string <dev-id> := 'nand'|'nor'|'onenand'<dev-num>,
1113 * return device type and number.
1115 * @param id string describing device id
1116 * @param ret_id output pointer to next char after parse completes (output)
1117 * @param dev_type parsed device type (output)
1118 * @param dev_num parsed device number (output)
1119 * @return 0 on success, 1 otherwise
1121 int mtd_id_parse(const char *id, const char **ret_id, u8 *dev_type, u8 *dev_num)
1126 if (strncmp(p, "nand", 4) == 0) {
1127 *dev_type = MTD_DEV_TYPE_NAND;
1129 } else if (strncmp(p, "nor", 3) == 0) {
1130 *dev_type = MTD_DEV_TYPE_NOR;
1132 } else if (strncmp(p, "onenand", 7) == 0) {
1133 *dev_type = MTD_DEV_TYPE_ONENAND;
1136 printf("incorrect device type in %s\n", id);
1141 printf("incorrect device number in %s\n", id);
1145 *dev_num = simple_strtoul(p, (char **)&p, 0);
1152 * Process all devices and generate corresponding mtdparts string describing
1153 * all partitions on all devices.
1155 * @param buf output buffer holding generated mtdparts string (output)
1156 * @param buflen buffer size
1157 * @return 0 on success, 1 otherwise
1159 static int generate_mtdparts(char *buf, u32 buflen)
1161 struct list_head *pentry, *dentry;
1162 struct mtd_device *dev;
1163 struct part_info *part, *prev_part;
1166 u32 size, offset, len, part_cnt;
1167 u32 maxlen = buflen - 1;
1169 DEBUGF("--- generate_mtdparts ---\n");
1171 if (list_empty(&devices)) {
1176 sprintf(p, "mtdparts=");
1179 list_for_each(dentry, &devices) {
1180 dev = list_entry(dentry, struct mtd_device, link);
1183 len = strlen(dev->id->mtd_id) + 1;
1186 memcpy(p, dev->id->mtd_id, len - 1);
1191 /* format partitions */
1194 list_for_each(pentry, &dev->parts) {
1195 part = list_entry(pentry, struct part_info, link);
1197 offset = part->offset;
1200 /* partition size */
1201 memsize_format(tmpbuf, size);
1202 len = strlen(tmpbuf);
1205 memcpy(p, tmpbuf, len);
1210 /* add offset only when there is a gap between
1212 if ((!prev_part && (offset != 0)) ||
1213 (prev_part && ((prev_part->offset + prev_part->size) != part->offset))) {
1215 memsize_format(tmpbuf, offset);
1216 len = strlen(tmpbuf) + 1;
1220 memcpy(p, tmpbuf, len - 1);
1225 /* copy name only if user supplied */
1226 if(!part->auto_name) {
1227 len = strlen(part->name) + 2;
1232 memcpy(p, part->name, len - 2);
1239 if (part->mask_flags && MTD_WRITEABLE_CMD) {
1248 /* print ',' separator if there are other partitions
1250 if (dev->num_parts > part_cnt) {
1258 /* print ';' separator if there are other devices following */
1259 if (dentry->next != &devices) {
1267 /* we still have at least one char left, as we decremented maxlen at
1274 last_parts[0] = '\0';
1279 * Call generate_mtdparts to process all devices and generate corresponding
1280 * mtdparts string, save it in mtdparts environment variable.
1282 * @param buf output buffer holding generated mtdparts string (output)
1283 * @param buflen buffer size
1284 * @return 0 on success, 1 otherwise
1286 static int generate_mtdparts_save(char *buf, u32 buflen)
1290 ret = generate_mtdparts(buf, buflen);
1292 if ((buf[0] != '\0') && (ret == 0))
1293 setenv("mtdparts", buf);
1295 setenv("mtdparts", NULL);
1301 * Format and print out a partition list for each device from global device
1304 static void list_partitions(void)
1306 struct list_head *dentry, *pentry;
1307 struct part_info *part;
1308 struct mtd_device *dev;
1311 DEBUGF("\n---list_partitions---\n");
1312 list_for_each(dentry, &devices) {
1313 dev = list_entry(dentry, struct mtd_device, link);
1314 printf("\ndevice %s%d <%s>, # parts = %d\n",
1315 MTD_DEV_TYPE(dev->id->type), dev->id->num,
1316 dev->id->mtd_id, dev->num_parts);
1317 printf(" #: name\t\t\tsize\t\toffset\t\tmask_flags\n");
1319 /* list partitions for given device */
1321 list_for_each(pentry, &dev->parts) {
1322 part = list_entry(pentry, struct part_info, link);
1323 printf("%2d: %-20s0x%08x\t0x%08x\t%d\n",
1324 part_num, part->name, part->size,
1325 part->offset, part->mask_flags);
1330 if (list_empty(&devices))
1331 printf("no partitions defined\n");
1333 /* current_dev is not NULL only when we have non empty device list */
1335 part = mtd_part_info(current_dev, current_partnum);
1337 printf("\nactive partition: %s%d,%d - (%s) 0x%08x @ 0x%08x\n",
1338 MTD_DEV_TYPE(current_dev->id->type),
1339 current_dev->id->num, current_partnum,
1340 part->name, part->size, part->offset);
1342 printf("could not get current partition info\n\n");
1346 printf("\ndefaults:\n");
1347 printf("mtdids : %s\n", mtdids_default);
1348 printf("mtdparts: %s\n", mtdparts_default);
1352 * Given partition identifier in form of <dev_type><dev_num>,<part_num> find
1353 * corresponding device and verify partition number.
1355 * @param id string describing device and partition or partition name
1356 * @param dev pointer to the requested device (output)
1357 * @param part_num verified partition number (output)
1358 * @param part pointer to requested partition (output)
1359 * @return 0 on success, 1 otherwise
1361 int find_dev_and_part(const char *id, struct mtd_device **dev,
1362 u8 *part_num, struct part_info **part)
1364 struct list_head *dentry, *pentry;
1365 u8 type, dnum, pnum;
1368 DEBUGF("--- find_dev_and_part ---\nid = %s\n", id);
1370 list_for_each(dentry, &devices) {
1372 *dev = list_entry(dentry, struct mtd_device, link);
1373 list_for_each(pentry, &(*dev)->parts) {
1374 *part = list_entry(pentry, struct part_info, link);
1375 if (strcmp((*part)->name, id) == 0)
1386 if (mtd_id_parse(p, &p, &type, &dnum) != 0)
1389 if ((*p++ != ',') || (*p == '\0')) {
1390 printf("no partition number specified\n");
1393 pnum = simple_strtoul(p, (char **)&p, 0);
1395 printf("unexpected trailing character '%c'\n", *p);
1399 if ((*dev = device_find(type, dnum)) == NULL) {
1400 printf("no such device %s%d\n", MTD_DEV_TYPE(type), dnum);
1404 if ((*part = mtd_part_info(*dev, pnum)) == NULL) {
1405 printf("no such partition\n");
1416 * Find and delete partition. For partition id format see find_dev_and_part().
1418 * @param id string describing device and partition
1419 * @return 0 on success, 1 otherwise
1421 static int delete_partition(const char *id)
1424 struct mtd_device *dev;
1425 struct part_info *part;
1427 if (find_dev_and_part(id, &dev, &pnum, &part) == 0) {
1429 DEBUGF("delete_partition: device = %s%d, partition %d = (%s) 0x%08lx@0x%08lx\n",
1430 MTD_DEV_TYPE(dev->id->type), dev->id->num, pnum,
1431 part->name, part->size, part->offset);
1433 if (part_del(dev, part) != 0)
1436 if (generate_mtdparts_save(last_parts, MTDPARTS_MAXLEN) != 0) {
1437 printf("generated mtdparts too long, reseting to null\n");
1443 printf("partition %s not found\n", id);
1448 * Accept character string describing mtd partitions and call device_parse()
1449 * for each entry. Add created devices to the global devices list.
1451 * @param mtdparts string specifing mtd partitions
1452 * @return 0 on success, 1 otherwise
1454 static int parse_mtdparts(const char *const mtdparts)
1456 const char *p = mtdparts;
1457 struct mtd_device *dev;
1460 DEBUGF("\n---parse_mtdparts---\nmtdparts = %s\n\n", p);
1462 /* delete all devices and partitions */
1463 if (mtd_devices_init() != 0) {
1464 printf("could not initialise device list\n");
1468 /* re-read 'mtdparts' variable, mtd_devices_init may be updating env */
1469 p = getenv("mtdparts");
1471 if (strncmp(p, "mtdparts=", 9) != 0) {
1472 printf("mtdparts variable doesn't start with 'mtdparts='\n");
1477 while (p && (*p != '\0')) {
1479 if ((device_parse(p, &p, &dev) != 0) || (!dev))
1482 DEBUGF("+ device: %s\t%d\t%s\n", MTD_DEV_TYPE(dev->id->type),
1483 dev->id->num, dev->id->mtd_id);
1485 /* check if parsed device is already on the list */
1486 if (device_find(dev->id->type, dev->id->num) != NULL) {
1487 printf("device %s%d redefined, please correct mtdparts variable\n",
1488 MTD_DEV_TYPE(dev->id->type), dev->id->num);
1492 list_add_tail(&dev->link, &devices);
1496 device_delall(&devices);
1504 * Parse provided string describing mtdids mapping (see file header for mtdids
1505 * variable format). Allocate memory for each entry and add all found entries
1506 * to the global mtdids list.
1508 * @param ids mapping string
1509 * @return 0 on success, 1 otherwise
1511 static int parse_mtdids(const char *const ids)
1513 const char *p = ids;
1517 struct list_head *entry, *n;
1518 struct mtdids *id_tmp;
1523 DEBUGF("\n---parse_mtdids---\nmtdids = %s\n\n", ids);
1525 /* clean global mtdids list */
1526 list_for_each_safe(entry, n, &mtdids) {
1527 id_tmp = list_entry(entry, struct mtdids, link);
1528 DEBUGF("mtdids del: %d %d\n", id_tmp->type, id_tmp->num);
1533 INIT_LIST_HEAD(&mtdids);
1535 while(p && (*p != '\0')) {
1538 /* parse 'nor'|'nand'|'onenand'<dev-num> */
1539 if (mtd_id_parse(p, &p, &type, &num) != 0)
1543 printf("mtdids: incorrect <dev-num>\n");
1548 /* check if requested device exists */
1549 if (mtd_device_validate(type, num, &size) != 0)
1552 /* locate <mtd-id> */
1554 if ((p = strchr(mtd_id, ',')) != NULL) {
1555 mtd_id_len = p - mtd_id + 1;
1558 mtd_id_len = strlen(mtd_id) + 1;
1560 if (mtd_id_len == 0) {
1561 printf("mtdids: no <mtd-id> identifier\n");
1565 /* check if this id is already on the list */
1566 int double_entry = 0;
1567 list_for_each(entry, &mtdids) {
1568 id_tmp = list_entry(entry, struct mtdids, link);
1569 if ((id_tmp->type == type) && (id_tmp->num == num)) {
1575 printf("device id %s%d redefined, please correct mtdids variable\n",
1576 MTD_DEV_TYPE(type), num);
1580 /* allocate mtdids structure */
1581 if (!(id = (struct mtdids *)malloc(sizeof(struct mtdids) + mtd_id_len))) {
1582 printf("out of memory\n");
1585 memset(id, 0, sizeof(struct mtdids) + mtd_id_len);
1589 id->mtd_id = (char *)(id + 1);
1590 strncpy(id->mtd_id, mtd_id, mtd_id_len - 1);
1591 id->mtd_id[mtd_id_len - 1] = '\0';
1592 INIT_LIST_HEAD(&id->link);
1594 DEBUGF("+ id %s%d\t%16d bytes\t%s\n",
1595 MTD_DEV_TYPE(id->type), id->num,
1596 id->size, id->mtd_id);
1598 list_add_tail(&id->link, &mtdids);
1602 /* clean mtdids list and free allocated memory */
1603 list_for_each_safe(entry, n, &mtdids) {
1604 id_tmp = list_entry(entry, struct mtdids, link);
1615 * Parse and initialize global mtdids mapping and create global
1616 * device/partition list.
1618 * @return 0 on success, 1 otherwise
1620 int mtdparts_init(void)
1622 static int initialized = 0;
1623 const char *ids, *parts;
1624 const char *current_partition;
1626 char tmp_ep[PARTITION_MAXLEN];
1628 DEBUGF("\n---mtdparts_init---\n");
1630 INIT_LIST_HEAD(&mtdids);
1631 INIT_LIST_HEAD(&devices);
1632 memset(last_ids, 0, MTDIDS_MAXLEN);
1633 memset(last_parts, 0, MTDPARTS_MAXLEN);
1634 memset(last_partition, 0, PARTITION_MAXLEN);
1639 ids = getenv("mtdids");
1640 parts = getenv("mtdparts");
1641 current_partition = getenv("partition");
1643 /* save it for later parsing, cannot rely on current partition pointer
1644 * as 'partition' variable may be updated during init */
1646 if (current_partition)
1647 strncpy(tmp_ep, current_partition, PARTITION_MAXLEN);
1649 DEBUGF("last_ids : %s\n", last_ids);
1650 DEBUGF("env_ids : %s\n", ids);
1651 DEBUGF("last_parts: %s\n", last_parts);
1652 DEBUGF("env_parts : %s\n\n", parts);
1654 DEBUGF("last_partition : %s\n", last_partition);
1655 DEBUGF("env_partition : %s\n", current_partition);
1657 /* if mtdids varible is empty try to use defaults */
1659 if (mtdids_default) {
1660 DEBUGF("mtdids variable not defined, using default\n");
1661 ids = mtdids_default;
1662 setenv("mtdids", (char *)ids);
1664 printf("mtdids not defined, no default present\n");
1668 if (strlen(ids) > MTDIDS_MAXLEN - 1) {
1669 printf("mtdids too long (> %d)\n", MTDIDS_MAXLEN);
1673 /* do no try to use defaults when mtdparts variable is not defined,
1674 * just check the length */
1676 printf("mtdparts variable not set, see 'help mtdparts'\n");
1678 if (parts && (strlen(parts) > MTDPARTS_MAXLEN - 1)) {
1679 printf("mtdparts too long (> %d)\n", MTDPARTS_MAXLEN);
1683 /* check if we have already parsed those mtdids */
1684 if ((last_ids[0] != '\0') && (strcmp(last_ids, ids) == 0)) {
1689 if (parse_mtdids(ids) != 0) {
1694 /* ok it's good, save new ids */
1695 strncpy(last_ids, ids, MTDIDS_MAXLEN);
1698 /* parse partitions if either mtdparts or mtdids were updated */
1699 if (parts && ((last_parts[0] == '\0') || ((strcmp(last_parts, parts) != 0)) || ids_changed)) {
1700 if (parse_mtdparts(parts) != 0)
1703 if (list_empty(&devices)) {
1704 printf("mtdparts_init: no valid partitions\n");
1708 /* ok it's good, save new parts */
1709 strncpy(last_parts, parts, MTDPARTS_MAXLEN);
1711 /* reset first partition from first dev from the list as current */
1712 current_dev = list_entry(devices.next, struct mtd_device, link);
1713 current_partnum = 0;
1716 DEBUGF("mtdparts_init: current_dev = %s%d, current_partnum = %d\n",
1717 MTD_DEV_TYPE(current_dev->id->type),
1718 current_dev->id->num, current_partnum);
1721 /* mtdparts variable was reset to NULL, delete all devices/partitions */
1722 if (!parts && (last_parts[0] != '\0'))
1723 return mtd_devices_init();
1725 /* do not process current partition if mtdparts variable is null */
1729 /* is current partition set in environment? if so, use it */
1730 if ((tmp_ep[0] != '\0') && (strcmp(tmp_ep, last_partition) != 0)) {
1731 struct part_info *p;
1732 struct mtd_device *cdev;
1735 DEBUGF("--- getting current partition: %s\n", tmp_ep);
1737 if (find_dev_and_part(tmp_ep, &cdev, &pnum, &p) == 0) {
1739 current_partnum = pnum;
1742 } else if (getenv("partition") == NULL) {
1743 DEBUGF("no partition variable set, setting...\n");
1751 * Return pointer to the partition of a requested number from a requested
1754 * @param dev device that is to be searched for a partition
1755 * @param part_num requested partition number
1756 * @return pointer to the part_info, NULL otherwise
1758 static struct part_info* mtd_part_info(struct mtd_device *dev, unsigned int part_num)
1760 struct list_head *entry;
1761 struct part_info *part;
1767 DEBUGF("\n--- mtd_part_info: partition number %d for device %s%d (%s)\n",
1768 part_num, MTD_DEV_TYPE(dev->id->type),
1769 dev->id->num, dev->id->mtd_id);
1771 if (part_num >= dev->num_parts) {
1772 printf("invalid partition number %d for device %s%d (%s)\n",
1773 part_num, MTD_DEV_TYPE(dev->id->type),
1774 dev->id->num, dev->id->mtd_id);
1778 /* locate partition number, return it */
1780 list_for_each(entry, &dev->parts) {
1781 part = list_entry(entry, struct part_info, link);
1783 if (part_num == num++) {
1791 /***************************************************/
1792 /* U-boot commands */
1793 /***************************************************/
1794 /* command line only */
1796 * Routine implementing u-boot chpart command. Sets new current partition based
1797 * on the user supplied partition id. For partition id format see find_dev_and_part().
1799 * @param cmdtp command internal data
1800 * @param flag command flag
1801 * @param argc number of arguments supplied to the command
1802 * @param argv arguments list
1803 * @return 0 on success, 1 otherwise
1805 int do_chpart(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
1807 /* command line only */
1808 struct mtd_device *dev;
1809 struct part_info *part;
1812 if (mtdparts_init() !=0)
1816 printf("no partition id specified\n");
1820 if (find_dev_and_part(argv[1], &dev, &pnum, &part) != 0)
1824 current_partnum = pnum;
1827 printf("partition changed to %s%d,%d\n",
1828 MTD_DEV_TYPE(dev->id->type), dev->id->num, pnum);
1834 * Routine implementing u-boot mtdparts command. Initialize/update default global
1835 * partition list and process user partition request (list, add, del).
1837 * @param cmdtp command internal data
1838 * @param flag command flag
1839 * @param argc number of arguments supplied to the command
1840 * @param argv arguments list
1841 * @return 0 on success, 1 otherwise
1843 int do_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
1846 if (strcmp(argv[1], "default") == 0) {
1847 setenv("mtdids", (char *)mtdids_default);
1848 setenv("mtdparts", (char *)mtdparts_default);
1849 setenv("partition", NULL);
1853 } else if (strcmp(argv[1], "delall") == 0) {
1854 /* this may be the first run, initialize lists if needed */
1857 setenv("mtdparts", NULL);
1859 /* mtd_devices_init() calls current_save() */
1860 return mtd_devices_init();
1864 /* make sure we are in sync with env variables */
1865 if (mtdparts_init() != 0)
1873 /* mtdparts add <mtd-dev> <size>[@<offset>] <name> [ro] */
1874 if (((argc == 5) || (argc == 6)) && (strcmp(argv[1], "add") == 0)) {
1875 #define PART_ADD_DESC_MAXLEN 64
1876 char tmpbuf[PART_ADD_DESC_MAXLEN];
1878 struct mtd_device *dev;
1879 struct mtd_device *dev_tmp;
1881 struct part_info *p;
1883 if (mtd_id_parse(argv[2], NULL, &type, &num) != 0)
1886 if ((id = id_find(type, num)) == NULL) {
1887 printf("no such device %s defined in mtdids variable\n", argv[2]);
1891 len = strlen(id->mtd_id) + 1; /* 'mtd_id:' */
1892 len += strlen(argv[3]); /* size@offset */
1893 len += strlen(argv[4]) + 2; /* '(' name ')' */
1894 if (argv[5] && (strlen(argv[5]) == 2))
1895 len += 2; /* 'ro' */
1897 if (len >= PART_ADD_DESC_MAXLEN) {
1898 printf("too long partition description\n");
1901 sprintf(tmpbuf, "%s:%s(%s)%s",
1902 id->mtd_id, argv[3], argv[4], argv[5] ? argv[5] : "");
1903 DEBUGF("add tmpbuf: %s\n", tmpbuf);
1905 if ((device_parse(tmpbuf, NULL, &dev) != 0) || (!dev))
1908 DEBUGF("+ %s\t%d\t%s\n", MTD_DEV_TYPE(dev->id->type),
1909 dev->id->num, dev->id->mtd_id);
1911 if ((dev_tmp = device_find(dev->id->type, dev->id->num)) == NULL) {
1914 /* merge new partition with existing ones*/
1915 p = list_entry(dev->parts.next, struct part_info, link);
1916 if (part_add(dev_tmp, p) != 0) {
1922 if (generate_mtdparts_save(last_parts, MTDPARTS_MAXLEN) != 0) {
1923 printf("generated mtdparts too long, reseting to null\n");
1930 /* mtdparts del part-id */
1931 if ((argc == 3) && (strcmp(argv[1], "del") == 0)) {
1932 DEBUGF("del: part-id = %s\n", argv[2]);
1934 return delete_partition(argv[2]);
1941 /***************************************************/
1943 chpart, 2, 0, do_chpart,
1944 "change active partition",
1946 " - change active partition (e.g. part-id = nand0,1)\n"
1950 mtdparts, 6, 0, do_mtdparts,
1951 "define flash/nand partitions",
1953 " - list partition table\n"
1955 " - delete all partitions\n"
1956 "mtdparts del part-id\n"
1957 " - delete partition (e.g. part-id = nand0,1)\n"
1958 "mtdparts add <mtd-dev> <size>[@<offset>] [<name>] [ro]\n"
1959 " - add partition\n"
1960 "mtdparts default\n"
1961 " - reset partition table to defaults\n\n"
1963 "this command uses three environment variables:\n\n"
1964 "'partition' - keeps current partition identifier\n\n"
1965 "partition := <part-id>\n"
1966 "<part-id> := <dev-id>,part_num\n\n"
1967 "'mtdids' - linux kernel mtd device id <-> u-boot device id mapping\n\n"
1968 "mtdids=<idmap>[,<idmap>,...]\n\n"
1969 "<idmap> := <dev-id>=<mtd-id>\n"
1970 "<dev-id> := 'nand'|'nor'|'onenand'<dev-num>\n"
1971 "<dev-num> := mtd device number, 0...\n"
1972 "<mtd-id> := unique device tag used by linux kernel to find mtd device (mtd->name)\n\n"
1973 "'mtdparts' - partition list\n\n"
1974 "mtdparts=mtdparts=<mtd-def>[;<mtd-def>...]\n\n"
1975 "<mtd-def> := <mtd-id>:<part-def>[,<part-def>...]\n"
1976 "<mtd-id> := unique device tag used by linux kernel to find mtd device (mtd->name)\n"
1977 "<part-def> := <size>[@<offset>][<name>][<ro-flag>]\n"
1978 "<size> := standard linux memsize OR '-' to denote all remaining space\n"
1979 "<offset> := partition start offset within the device\n"
1980 "<name> := '(' NAME ')'\n"
1981 "<ro-flag> := when set to 'ro' makes partition read-only (not used, passed to kernel)\n"
1983 /***************************************************/