From patchwork Thu Dec 16 01:22:26 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donghwa Lee X-Patchwork-Id: 75714 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 92DC41007D8 for ; Thu, 16 Dec 2010 12:32:24 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D6EA828082; Thu, 16 Dec 2010 02:32:22 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WBqwq-aMAOox; Thu, 16 Dec 2010 02:32:22 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 919E628086; Thu, 16 Dec 2010 02:32:20 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 323CF28086 for ; Thu, 16 Dec 2010 02:32:18 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fw2sLcN-156L for ; Thu, 16 Dec 2010 02:32:16 +0100 (CET) X-Greylist: delayed 604 seconds by postgrey-1.27 at theia; Thu, 16 Dec 2010 02:32:14 CET X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by theia.denx.de (Postfix) with ESMTP id 09E1928082 for ; Thu, 16 Dec 2010 02:32:14 +0100 (CET) Received: from epmmp1 (mailout3.samsung.com [203.254.224.33]) by mailout3.samsung.com (Oracle Communications Messaging Exchange Server 7u4-19.01 64bit (built Sep 7 2010)) with ESMTP id <0LDH004F6YGW4S40@mailout3.samsung.com> for u-boot@lists.denx.de; Thu, 16 Dec 2010 10:22:08 +0900 (KST) Received: from TNRNDGASPAPP1.tn.corp.samsungelectronics.net ([165.213.149.150]) by mmp1.samsung.com (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTPA id <0LDH00GEGYGW6K@mmp1.samsung.com> for u-boot@lists.denx.de; Thu, 16 Dec 2010 10:22:08 +0900 (KST) Received: from localhost.localdomain ([10.89.53.118]) by TNRNDGASPAPP1.tn.corp.samsungelectronics.net with Microsoft SMTPSVC(6.0.3790.4675); Thu, 16 Dec 2010 10:22:08 +0900 Date: Thu, 16 Dec 2010 10:22:26 +0900 From: Donghwa Lee To: u-boot@lists.denx.de, dh09.lee@samsung.com Message-id: <1292462546-32516-1-git-send-email-dh09.lee@samsung.com> X-Mailer: git-send-email 1.6.0.4 X-OriginalArrivalTime: 16 Dec 2010 01:22:08.0617 (UTC) FILETIME=[A8480590:01CB9CBF] Subject: [U-Boot] [PATCH] tools: fw_printenv supports mmc device X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 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 Signed-off-by: Kyungmin Park --- tools/env/fw_env.c | 13 ++++++++++--- tools/env/fw_env.config | 7 +++++-- 2 files changed, 15 insertions(+), 5 deletions(-) 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