[U-Boot] [PATCH] cmd_nand/cmd_ubi/cmd_nboot: Set environment variable 'filesize'

Rostislav Lisovy lisovy at gmail.com
Wed Jul 16 10:48:51 CEST 2014


The environment variable 'filesize' is commonly used for
storing information about the size of the last read/retrieved
file. The variable is essential when writing U-boot scripts.
This patch adds the capability of storing the information about
the size of read data into the 'filesize' variable for other
commands (nand read/ubi read/nboot) as well.

Signed-off-by: Rostislav Lisovy <lisovy at merica.cz>
---
 common/cmd_nand.c | 2 ++
 common/cmd_ubi.c  | 1 +
 2 files changed, 3 insertions(+)

diff --git a/common/cmd_nand.c b/common/cmd_nand.c
index f9ced9d..8368f5f 100644
--- a/common/cmd_nand.c
+++ b/common/cmd_nand.c
@@ -730,6 +730,7 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 		printf(" %zu bytes %s: %s\n", rwsize,
 		       read ? "read" : "written", ret ? "ERROR" : "OK");
+		setenv_hex("filesize", rwsize);
 
 		return ret == 0 ? 0 : 1;
 	}
@@ -959,6 +960,7 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand,
 		return 1;
 	}
 	bootstage_mark(BOOTSTAGE_ID_NAND_READ);
+	setenv_hex("filesize", cnt);
 
 #if defined(CONFIG_FIT)
 	/* This cannot be done earlier, we need complete FIT image in RAM first */
diff --git a/common/cmd_ubi.c b/common/cmd_ubi.c
index 7c4d950..a9207c9 100644
--- a/common/cmd_ubi.c
+++ b/common/cmd_ubi.c
@@ -675,6 +675,7 @@ static int do_ubi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		if (argc == 3) {
 			printf("Read %lld bytes from volume %s to %lx\n", size,
 			       argv[3], addr);
+			setenv_hex("filesize", size);
 
 			return ubi_volume_read(argv[3], (char *)addr, size);
 		}
-- 
1.9.1



More information about the U-Boot mailing list