summaryrefslogtreecommitdiffstats
path: root/common/cmd_ubi.c
diff options
context:
space:
mode:
authorAndreas Huber <andreas.huber@keymile.com>2009-04-02 17:15:34 +0200
committerWolfgang Denk <wd@denx.de>2009-04-04 23:25:40 +0200
commitc203ef5db0476a8c4f6dd86b2e9e9db0ea973f84 (patch)
tree6f9801c677d06f6bdb76f4698d847798f41b2c9d /common/cmd_ubi.c
parent6b6bb02f27fcabfb37ea717fb7e243248e1e2acf (diff)
downloadbootable_bootloader_goldelico_gta04-c203ef5db0476a8c4f6dd86b2e9e9db0ea973f84.zip
bootable_bootloader_goldelico_gta04-c203ef5db0476a8c4f6dd86b2e9e9db0ea973f84.tar.gz
bootable_bootloader_goldelico_gta04-c203ef5db0476a8c4f6dd86b2e9e9db0ea973f84.tar.bz2
UBI/cfi-mtd: Fix mtd name for multiple chips
On platforms with multiple NOR chips, currently only the first one can be selected using the "ubi part" command. This patch fixes this problem by using different names for the NOR "mtd devices". It also changes the name of the NOR MTD device from "cfi-mtd" to "norX" (X indexing the device numer) to better match the mtdparts defaults. Signed-off-by: Stefan Roese <sr@denx.de> Signed-off-by: Andreas Huber <andreas.huber@keymile.com>
Diffstat (limited to 'common/cmd_ubi.c')
-rw-r--r--common/cmd_ubi.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/common/cmd_ubi.c b/common/cmd_ubi.c
index b99fd58..9c17d71 100644
--- a/common/cmd_ubi.c
+++ b/common/cmd_ubi.c
@@ -404,9 +404,6 @@ static int ubi_dev_scan(struct mtd_info *info, char *ubidev)
u8 pnum;
int err;
- if (mtdparts_init() != 0)
- return 1;
-
if (find_dev_and_part(ubidev, &dev, &pnum, &part) != 0)
return 1;
@@ -445,6 +442,11 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
return 1;
}
+ if (mtdparts_init() != 0) {
+ printf("Error initializing mtdparts!\n");
+ return 1;
+ }
+
if (strcmp(argv[1], "part") == 0) {
/* Print current partition */
if (argc == 2) {
@@ -475,7 +477,7 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
}
/*
- * Check for nand|onenand selection
+ * Check for nor|nand|onenand selection
*/
#if defined(CONFIG_CMD_NAND)
if (strcmp(argv[2], "nand") == 0) {
@@ -486,9 +488,23 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
#endif
#if defined(CONFIG_FLASH_CFI_MTD)
if (strcmp(argv[2], "nor") == 0) {
+ char mtd_dev[16];
+ struct mtd_device *dev;
+ struct part_info *part;
+ u8 pnum;
+
+ /*
+ * Search the mtd device number where this partition
+ * is located
+ */
+ if (find_dev_and_part(argv[3], &dev, &pnum, &part)) {
+ printf("Partition %s not found!\n", argv[3]);
+ return 1;
+ }
+ sprintf(mtd_dev, "nor%d", dev->id->num);
+ ubi_dev.mtd_info = get_mtd_device_nm(mtd_dev);
strcpy(ubi_dev.dev_name, "NOR");
ubi_dev.type = DEV_TYPE_NOR;
- ubi_dev.mtd_info = get_mtd_device_nm(CFI_MTD_DEV_NAME);
}
#endif
#if defined(CONFIG_CMD_ONENAND)