diff mbox

[U-Boot] tools: fw_printenv supports mmc device

Message ID 1292462439-32492-1-git-send-email-y@samsung.com
State Superseded
Headers show

Commit Message

y@samsung.com Dec. 16, 2010, 1:20 a.m. UTC
From: Donghwa Lee <dh09.lee@samsung.com>

I modified fw_printenv tools to use /dev/mmcblk0 node. Original fw_printenv tool
can be access MTD devices, but, in some cases, environment variables can be stored
other memory devices, for example, mmc devices.
So, I modified a few code to use /dev/mmcblk0.

Signed-off-by: Donghwa Lee <dh09.lee@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>

---
 tools/env/fw_env.c      |   13 ++++++++++---
 tools/env/fw_env.config |    7 +++++--
 2 files changed, 15 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index 8ff7052..5a707f6 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -855,6 +855,7 @@  static int flash_write_buf (int dev, int fd, void *buf, size_t count,
 		}
 
 		erase.start = blockstart;
+#ifndef CONFIG_ENV_IS_IN_MMC
 		ioctl (fd, MEMUNLOCK, &erase);
 
 		if (ioctl (fd, MEMERASE, &erase) != 0) {
@@ -863,7 +864,7 @@  static int flash_write_buf (int dev, int fd, void *buf, size_t count,
 				 strerror (errno));
 			return -1;
 		}
-
+#endif
 		if (lseek (fd, blockstart, SEEK_SET) == -1) {
 			fprintf (stderr,
 				 "Seek error on %s: %s\n",
@@ -880,8 +881,9 @@  static int flash_write_buf (int dev, int fd, void *buf, size_t count,
 			return -1;
 		}
 
+#ifndef CONFIG_ENV_IS_IN_MMC
 		ioctl (fd, MEMLOCK, &erase);
-
+#endif
 		processed  += blocklen;
 		block_seek = 0;
 		blockstart += blocklen;
@@ -964,9 +966,10 @@  static int flash_write (int fd_current, int fd_target, int dev_target)
 
 static int flash_read (int fd)
 {
-	struct mtd_info_user mtdinfo;
 	int rc;
 
+#ifndef CONFIG_ENV_IS_IN_MMC
+	struct mtd_info_user mtdinfo;
 	rc = ioctl (fd, MEMGETINFO, &mtdinfo);
 	if (rc < 0) {
 		perror ("Cannot get MTD information");
@@ -982,6 +985,10 @@  static int flash_read (int fd)
 
 	rc = flash_read_buf (dev_current, fd, environment.image, CONFIG_ENV_SIZE,
 			     DEVOFFSET (dev_current), mtdinfo.type);
+#else
+	rc = flash_read_buf (dev_current, fd, environment.image, CONFIG_ENV_SIZE,
+			     DEVOFFSET (dev_current), 0);
+#endif
 
 	return (rc != CONFIG_ENV_SIZE) ? -1 : 0;
 }
diff --git a/tools/env/fw_env.config b/tools/env/fw_env.config
index c8f12cf..228ded8 100644
--- a/tools/env/fw_env.config
+++ b/tools/env/fw_env.config
@@ -4,8 +4,11 @@ 
 # Notice, that the "Number of sectors" is ignored on NOR.
 
 # MTD device name	Device offset	Env. size	Flash sector size	Number of sectors
-/dev/mtd1		0x0000		0x4000		0x4000
-/dev/mtd2		0x0000		0x4000		0x4000
+#/dev/mtd1		0x0000		0x4000		0x4000
+#/dev/mtd2		0x0000		0x4000		0x4000
 
 # NAND example
 #/dev/mtd0		0x4000		0x4000		0x20000			2
+
+# MMC device name	Device offset	Env. size	Flash sector size	Number of sectors
+/dev/mmcblk0		0x7000		0x1000		0x1000