Skip to contentSkip to conversation

imls: Add support to list images in NAND device

PATCH Superseded Vipin Kumar 2 participants 5 messages Dec 17, 2012 – Feb 22, 2013

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 imls: Add support to list images in NAND device

This patch adds support to list images in NAND flash through imls

---
Changes in v4
- Keep stdout dumps in one line
- Continue even after read errors for all the blocks

 README             |   3 +-
 common/cmd_bootm.c | 167 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 166 insertions(+), 4 deletions(-)
README +2 -1
index 2077c3b..46fd21d 100644
@@ -831,7 +831,8 @@ The following options need to be configured:
 		CONFIG_CMD_I2C		* I2C serial bus support
 		CONFIG_CMD_IDE		* IDE harddisk support
 		CONFIG_CMD_IMI		  iminfo
-		CONFIG_CMD_IMLS		  List all found images
+		CONFIG_CMD_IMLS		  List all images found in NOR flash
+		CONFIG_CMD_IMLS_NAND	  List all images found in NAND flash
 		CONFIG_CMD_IMMAP	* IMMR dump support
 		CONFIG_CMD_IMPORTENV	* import an environment
 		CONFIG_CMD_INI		* import data from an ini file into the env
common/cmd_bootm.c +164 -3

194 lines not on this page · raw message

Signature · 1 line
1.8.0
#1 lore raw

PATCH v4 1/1 imls: Add support to list images in NAND device

Quoted 76 lines · Vipin Kumar

This patch adds support to list images in NAND flash through imls

---
Changes in v4
- Keep stdout dumps in one line
- Continue even after read errors for all the blocks

 README             |   3 +-
 common/cmd_bootm.c | 167  
++++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 166 insertions(+), 4 deletions(-)
README +1 -1
index 2077c3b..46fd21d 100644
@@ -831,7 +831,8 @@ The following options need to be configured:
 		CONFIG_CMD_I2C		* I2C serial bus support
 		CONFIG_CMD_IDE		* IDE harddisk support
 		CONFIG_CMD_IMI		  iminfo
-		CONFIG_CMD_IMLS		  List all found images
+		CONFIG_CMD_IMLS		  List all images found in NOR  

flash

README +1 -0
+		CONFIG_CMD_IMLS_NAND	  List all images found in NAND  

flash

README +0 -0
 		CONFIG_CMD_IMMAP	* IMMR dump support
 		CONFIG_CMD_IMPORTENV	* import an environment
 		CONFIG_CMD_INI		* import data from an ini file  

into the env

common/cmd_bootm.c +6 -0
index d256ddf..938e500 100644
@@ -80,9 +80,15 @@ static int image_info(unsigned long addr);
 #include <flash.h>
 #include <mtd/cfi_flash.h>
 extern flash_info_t flash_info[]; /* info for FLASH chips */
+#endif
+
+#if defined(CONFIG_CMD_IMLS) || defined(CONFIG_CMD_IMLS_NAND)
 static int do_imls(cmd_tbl_t *cmdtp, int flag, int argc, char *  
 const argv[]);
 #endif
 
+#include <linux/err.h>
+#include <nand.h>
+
 #ifdef CONFIG_SILENT_CONSOLE
 static void fixup_silent_linux(void);

#endif

common/cmd_bootm.c +1 -1
@@ -1175,7 +1181,7 @@ U_BOOT_CMD(
 /* imls - list all images found in flash */
 /*******************************************************************/
 #if defined(CONFIG_CMD_IMLS)
-static int do_imls(cmd_tbl_t *cmdtp, int flag, int argc, char *  
 const argv[])
+static int do_imls_nor(void)
 {
 	flash_info_t *info;
common/cmd_bootm.c +10 -0
 	int i, j;
@@ -1224,6 +1230,161 @@ next_sector:		;
 		}
 next_bank:	;
 	}
+	return 0;
+}
+#endif
+
+#if defined(CONFIG_CMD_IMLS_NAND)
+static int nand_imls_legacyimage(nand_info_t *nand, int nand_dev,  
 loff_t off,
+		size_t len)
+{
+	void *imgdata;
+	int ret;

common/cmd_bootm.c next_sector: ; · line 1253

Quoted 10 lines
common/cmd_bootm.c +8 -0
+
+	imgdata = malloc(len);
+	if (!imgdata) {
+		printf("May be a Legacy Image at NAND device %d offset  
 %08llX:\n",
+				nand_dev, off);
+		printf("   Low memory(cannot allocate memory for  
 image)\n");
+		return -ENOMEM;
+	}

So, it looks like any reasonably-sized kernel image is going to hit this out-of-memory condition given how unreasonably small U-Boot malloc heaps generally are.

As a side note, running this showed U-Boot itself as "may be a legacy image"... it seems that for some reason all the ppc arches start with the uImage header, but otherwise aren't valid uImages.

-Scott

#2 lore raw

PATCH v4 1/1 imls: Add support to list images in NAND device

Quoted 83 lines · Scott Wood
Quoted 82 lines · Vipin Kumar

This patch adds support to list images in NAND flash through imls

---
Changes in v4
- Keep stdout dumps in one line
- Continue even after read errors for all the blocks

  README             |   3 +-
  common/cmd_bootm.c | 167
++++++++++++++++++++++++++++++++++++++++++++++++++++-
  2 files changed, 166 insertions(+), 4 deletions(-)
README +1 -1
index 2077c3b..46fd21d 100644
@@ -831,7 +831,8 @@ The following options need to be configured:
  		CONFIG_CMD_I2C		* I2C serial bus support
  		CONFIG_CMD_IDE		* IDE harddisk support
  		CONFIG_CMD_IMI		  iminfo
-		CONFIG_CMD_IMLS		  List all found images
+		CONFIG_CMD_IMLS		  List all images found in NOR

flash

README +1 -0
+		CONFIG_CMD_IMLS_NAND	  List all images found in NAND

flash
CONFIG_CMD_IMMAP * IMMR dump support
CONFIG_CMD_IMPORTENV * import an environment
CONFIG_CMD_INI * import data from an ini file
into the env

common/cmd_bootm.c +6 -0
index d256ddf..938e500 100644
@@ -80,9 +80,15 @@ static int image_info(unsigned long addr);
  #include<flash.h>
  #include<mtd/cfi_flash.h>
  extern flash_info_t flash_info[]; /* info for FLASH chips */
+#endif
+
+#if defined(CONFIG_CMD_IMLS) || defined(CONFIG_CMD_IMLS_NAND)
  static int do_imls(cmd_tbl_t *cmdtp, int flag, int argc, char *
 const argv[]);
  #endif
 
+#include<linux/err.h>
+#include<nand.h>
+
  #ifdef CONFIG_SILENT_CONSOLE
  static void fixup_silent_linux(void);
  #endif
common/cmd_bootm.c +1 -1
@@ -1175,7 +1181,7 @@ U_BOOT_CMD(
  /* imls - list all images found in flash */
  /*******************************************************************/
  #if defined(CONFIG_CMD_IMLS)
-static int do_imls(cmd_tbl_t *cmdtp, int flag, int argc, char *
 const argv[])
+static int do_imls_nor(void)
  {
  	flash_info_t *info;

int i, j;

common/cmd_bootm.c +15 -0
@@ -1224,6 +1230,161 @@ next_sector:		;
  		}
  next_bank:	;
  	}
+	return 0;
+}
+#endif
+
+#if defined(CONFIG_CMD_IMLS_NAND)
+static int nand_imls_legacyimage(nand_info_t *nand, int nand_dev,
 loff_t off,
+		size_t len)
+{
+	void *imgdata;
+	int ret;
+
+	imgdata = malloc(len);
+	if (!imgdata) {
+		printf("May be a Legacy Image at NAND device %d offset
 %08llX:\n",
+				nand_dev, off);
Quoted 9 lines

common/cmd_bootm.c next_sector: ; · line 1250

Quoted 4 lines
common/cmd_bootm.c +3 -0
+		printf("   Low memory(cannot allocate memory for
 image)\n");
+		return -ENOMEM;
+	}

So, it looks like any reasonably-sized kernel image is going to hit this out-of-memory condition given how unreasonably small U-Boot malloc heaps generally are.

Yes, that's right. And it is a pity

Quoted 3 lines

As a side note, running this showed U-Boot itself as "may be a legacy image"... it seems that for some reason all the ppc arches start with the uImage header, but otherwise aren't valid uImages.

This "may be a legacy image" print is when we have successfully copied and validated the 64 byte mkimage header and are not able to allocate the memory from heap for the image data. What it means is that although the whole image might be a good "Legacy image" but we can not guarantee because we have not yet validated the dcrc.

Thats why this print "May be a legacy image"

-Vipin

Quoted 4 lines

-Scott
.

#3 lore raw

PATCH v4 1/1 imls: Add support to list images in NAND device

Quoted 26 lines · Vipin Kumar
Quoted 15 lines · Scott Wood
Quoted 14 lines · Vipin Kumar
(quoted diff) +2 -0
+#if defined(CONFIG_CMD_IMLS_NAND)
+static int nand_imls_legacyimage(nand_info_t *nand, int nand_dev,

loff_t off,

common/cmd_bootm.c +8 -0
+		size_t len)
+{
+	void *imgdata;
+	int ret;
+
+	imgdata = malloc(len);
+	if (!imgdata) {
+		printf("May be a Legacy Image at NAND device %d offset

%08llX:\n",

(quoted diff) +2 -0
+				nand_dev, off);
+		printf("   Low memory(cannot allocate memory for
Quoted 9 lines

Review

Quoted 3 lines

image)\n");

(quoted diff) +2 -0
+		return -ENOMEM;
+	}

So, it looks like any reasonably-sized kernel image is going to hit this out-of-memory condition given how unreasonably small U-Boot malloc
heaps generally are.

Quoted 1 line

Yes, that's right. And it is a pity

I think I'll apply this anyway, as it is still helpful, but a future enhancement could be to do a streaming read of the image to verify the CRC.

Quoted 11 lines
Quoted 3 lines

As a side note, running this showed U-Boot itself as "may be a legacy image"... it seems that for some reason all the ppc arches start with the uImage header, but otherwise aren't valid uImages.

This "may be a legacy image" print is when we have successfully copied and validated the 64 byte mkimage header and are not able to allocate the memory from heap for the image data. What it means is that although the whole image might be a good "Legacy image" but we can not guarantee because we have not yet validated the dcrc.

Thats why this print "May be a legacy image"

Sure, that comment was meant as "hmm, powerpc is doing something weird" rather than anything wrong with this patch.

-Scott

#4 lore raw

PATCH v4 1/1 imls: Add support to list images in NAND device

In reply to Vipin Kumar
Quoted 4 lines · Vipin Kumar

This patch adds support to list images in NAND flash through imls

Quoted 8 lines

---
Changes in v4
- Keep stdout dumps in one line
- Continue even after read errors for all the blocks

 README             |   3 +-
 common/cmd_bootm.c | 167 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 166 insertions(+), 4 deletions(-)

Applied to u-boot-nand-flash, but please follow up by enabling this in at least one board so that it continues to get build-tested.

-Scott