All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] fw_env: add redundand env support for MTD_ABSENT
@ 2013-08-25 12:46 Oliver Metz
  2013-08-25 12:46 ` [U-Boot] [PATCH 2/2] fw_env: fix writing environment for mtd devices Oliver Metz
  2013-08-26 14:25 ` [U-Boot] [PATCH 1/2] fw_env: add redundand env support for MTD_ABSENT Robert P. J. Day
  0 siblings, 2 replies; 5+ messages in thread
From: Oliver Metz @ 2013-08-25 12:46 UTC (permalink / raw
  To: u-boot

Signed-off-by: Oliver Metz <oliver@freetz.org>
---
 tools/env/fw_env.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index 44607b1..65be5f3 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -1136,6 +1136,9 @@ int fw_env_open(void)
 		} else if (DEVTYPE(dev_current) == MTD_UBIVOLUME &&
 			   DEVTYPE(!dev_current) == MTD_UBIVOLUME) {
 			environment.flag_scheme = FLAG_INCREMENTAL;
+		} else if (DEVTYPE(dev_current) == MTD_ABSENT &&
+			   DEVTYPE(!dev_current) == MTD_ABSENT) {
+			environment.flag_scheme = FLAG_INCREMENTAL;
 		} else {
 			fprintf (stderr, "Incompatible flash types!\n");
 			return -1;
-- 
1.8.3.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH 2/2] fw_env: fix writing environment for mtd devices
  2013-08-25 12:46 [U-Boot] [PATCH 1/2] fw_env: add redundand env support for MTD_ABSENT Oliver Metz
@ 2013-08-25 12:46 ` Oliver Metz
  2013-08-26 14:25 ` [U-Boot] [PATCH 1/2] fw_env: add redundand env support for MTD_ABSENT Robert P. J. Day
  1 sibling, 0 replies; 5+ messages in thread
From: Oliver Metz @ 2013-08-25 12:46 UTC (permalink / raw
  To: u-boot

Signed-off-by: Oliver Metz <oliver@freetz.org>
---
 tools/env/fw_env.c | 71 ++++++++++++++++++++++++++++++++----------------------
 1 file changed, 42 insertions(+), 29 deletions(-)

diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index 65be5f3..7454676 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -727,27 +727,39 @@ static int flash_write_buf (int dev, int fd, void *buf, size_t count,
 				   MEMGETBADBLOCK needs 64 bits */
 	int rc;
 
-	blocklen = DEVESIZE (dev);
+	/*
+	 * For mtd devices only offset and size of the environment do matter
+	 */
+	if (mtd_type == MTD_ABSENT) {
+		blocklen = count;
+		top_of_range = offset + count;
+		erase_len = blocklen;
+		blockstart = offset;
+		block_seek = 0;
+		write_total = blocklen;
+	} else {
+		blocklen = DEVESIZE (dev);
 
-	top_of_range = ((DEVOFFSET(dev) / blocklen) +
-					ENVSECTORS (dev)) * blocklen;
+		top_of_range = ((DEVOFFSET(dev) / blocklen) +
+						ENVSECTORS (dev)) * blocklen;
 
-	erase_offset = (offset / blocklen) * blocklen;
+		erase_offset = (offset / blocklen) * blocklen;
 
-	/* Maximum area we may use */
-	erase_len = top_of_range - erase_offset;
+		/* Maximum area we may use */
+		erase_len = top_of_range - erase_offset;
 
-	blockstart = erase_offset;
-	/* Offset inside a block */
-	block_seek = offset - erase_offset;
+		blockstart = erase_offset;
+		/* Offset inside a block */
+		block_seek = offset - erase_offset;
 
-	/*
-	 * Data size we actually have to write: from the start of the block
-	 * to the start of the data, then count bytes of data, and to the
-	 * end of the block
-	 */
-	write_total = ((block_seek + count + blocklen - 1) /
-						blocklen) * blocklen;
+		/*
+		 * Data size we actually write: from the start of the block
+		 * to the start of the data, then count bytes of data, and to the
+		 * end of the block
+		 */
+		write_total = ((block_seek + count + blocklen - 1) /
+							blocklen) * blocklen;
+	}
 
 	/*
 	 * Support data anywhere within erase sectors: read out the complete
@@ -818,17 +830,18 @@ static int flash_write_buf (int dev, int fd, void *buf, size_t count,
 			continue;
 		}
 
-		erase.start = blockstart;
-		ioctl (fd, MEMUNLOCK, &erase);
-		/* These do not need an explicit erase cycle */
-		if (mtd_type != MTD_ABSENT &&
-		    mtd_type != MTD_DATAFLASH)
-			if (ioctl (fd, MEMERASE, &erase) != 0) {
-				fprintf (stderr, "MTD erase error on %s: %s\n",
-					 DEVNAME (dev),
-					 strerror (errno));
-				return -1;
-			}
+		if (mtd_type != MTD_ABSENT) {
+			erase.start = blockstart;
+			ioctl (fd, MEMUNLOCK, &erase);
+			/* These do not need an explicit erase cycle */
+			if (mtd_type != MTD_DATAFLASH)
+				if (ioctl (fd, MEMERASE, &erase) != 0) {
+					fprintf (stderr, "MTD erase error on %s: %s\n",
+						 DEVNAME (dev),
+						 strerror (errno));
+					return -1;
+				}
+		}
 
 		if (lseek (fd, blockstart, SEEK_SET) == -1) {
 			fprintf (stderr,
@@ -846,8 +859,8 @@ static int flash_write_buf (int dev, int fd, void *buf, size_t count,
 				 DEVNAME (dev), strerror (errno));
 			return -1;
 		}
-
-		ioctl (fd, MEMLOCK, &erase);
+		if (mtd_type != MTD_ABSENT)
+			ioctl (fd, MEMLOCK, &erase);
 
 		processed  += blocklen;
 		block_seek = 0;
-- 
1.8.3.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH 1/2] fw_env: add redundand env support for MTD_ABSENT
  2013-08-25 12:46 [U-Boot] [PATCH 1/2] fw_env: add redundand env support for MTD_ABSENT Oliver Metz
  2013-08-25 12:46 ` [U-Boot] [PATCH 2/2] fw_env: fix writing environment for mtd devices Oliver Metz
@ 2013-08-26 14:25 ` Robert P. J. Day
  2013-08-27 17:35   ` Oliver Metz
  1 sibling, 1 reply; 5+ messages in thread
From: Robert P. J. Day @ 2013-08-26 14:25 UTC (permalink / raw
  To: u-boot

On Sun, 25 Aug 2013, Oliver Metz wrote:

> Signed-off-by: Oliver Metz <oliver@freetz.org>
> ---
>  tools/env/fw_env.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
> index 44607b1..65be5f3 100644
> --- a/tools/env/fw_env.c
> +++ b/tools/env/fw_env.c
> @@ -1136,6 +1136,9 @@ int fw_env_open(void)
>  		} else if (DEVTYPE(dev_current) == MTD_UBIVOLUME &&
>  			   DEVTYPE(!dev_current) == MTD_UBIVOLUME) {
>  			environment.flag_scheme = FLAG_INCREMENTAL;
> +		} else if (DEVTYPE(dev_current) == MTD_ABSENT &&
> +			   DEVTYPE(!dev_current) == MTD_ABSENT) {
> +			environment.flag_scheme = FLAG_INCREMENTAL;
>  		} else {
>  			fprintf (stderr, "Incompatible flash types!\n");
>  			return -1;

  pedantically, it's "redundant", not "redundand". and it might be
useful to add some commentary in the sample fw_env.config file that
explains this new feature, as the patch is clearly not adding any
documentation.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH 1/2] fw_env: add redundand env support for MTD_ABSENT
  2013-08-26 14:25 ` [U-Boot] [PATCH 1/2] fw_env: add redundand env support for MTD_ABSENT Robert P. J. Day
@ 2013-08-27 17:35   ` Oliver Metz
  2013-08-27 23:03     ` Luka Perkov
  0 siblings, 1 reply; 5+ messages in thread
From: Oliver Metz @ 2013-08-27 17:35 UTC (permalink / raw
  To: u-boot

Robert P. J. Day schrieb am 26.08.2013 16:25:

> On Sun, 25 Aug 2013, Oliver Metz wrote:
> 
>> Signed-off-by: Oliver Metz <oliver@freetz.org>
>> ---
>>  tools/env/fw_env.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
>> index 44607b1..65be5f3 100644
>> --- a/tools/env/fw_env.c
>> +++ b/tools/env/fw_env.c
>> @@ -1136,6 +1136,9 @@ int fw_env_open(void)
>>  		} else if (DEVTYPE(dev_current) == MTD_UBIVOLUME &&
>>  			   DEVTYPE(!dev_current) == MTD_UBIVOLUME) {
>>  			environment.flag_scheme = FLAG_INCREMENTAL;
>> +		} else if (DEVTYPE(dev_current) == MTD_ABSENT &&
>> +			   DEVTYPE(!dev_current) == MTD_ABSENT) {
>> +			environment.flag_scheme = FLAG_INCREMENTAL;
>>  		} else {
>>  			fprintf (stderr, "Incompatible flash types!\n");
>>  			return -1;
> 
>  pedantically, it's "redundant", not "redundand". and it might be
> useful to add some commentary in the sample fw_env.config file that
> explains this new feature, as the patch is clearly not adding any
> documentation.
> 
> rday
> 
I will send a new version of the patches with the typo fixed.

But I'm unsure how to comment the changes in fw_env.config since redundant
env description is already in the comment at the top.

Is something like this enough?

diff --git a/tools/env/fw_env.config b/tools/env/fw_env.config
index 90e499d..fcaab55 100644
--- a/tools/env/fw_env.config
+++ b/tools/env/fw_env.config
@@ -20,3 +20,4 @@
 
 # Block device example
 #/dev/mmcblk0          0xc0000         0x20000
+#/dev/mmcblk0          0xe0000         0x20000


--
Oliver

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH 1/2] fw_env: add redundand env support for MTD_ABSENT
  2013-08-27 17:35   ` Oliver Metz
@ 2013-08-27 23:03     ` Luka Perkov
  0 siblings, 0 replies; 5+ messages in thread
From: Luka Perkov @ 2013-08-27 23:03 UTC (permalink / raw
  To: u-boot

Hi Oliver,

On Tue, Aug 27, 2013 at 07:35:57PM +0200, Oliver Metz wrote:
> But I'm unsure how to comment the changes in fw_env.config since redundant
> env description is already in the comment at the top.
> 
> Is something like this enough?
> 
> diff --git a/tools/env/fw_env.config b/tools/env/fw_env.config
> index 90e499d..fcaab55 100644
> --- a/tools/env/fw_env.config
> +++ b/tools/env/fw_env.config
> @@ -20,3 +20,4 @@
>  
>  # Block device example
>  #/dev/mmcblk0          0xc0000         0x20000
> +#/dev/mmcblk0          0xe0000         0x20000

I'd say it's unnecessary...

Luka

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-08-27 23:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-25 12:46 [U-Boot] [PATCH 1/2] fw_env: add redundand env support for MTD_ABSENT Oliver Metz
2013-08-25 12:46 ` [U-Boot] [PATCH 2/2] fw_env: fix writing environment for mtd devices Oliver Metz
2013-08-26 14:25 ` [U-Boot] [PATCH 1/2] fw_env: add redundand env support for MTD_ABSENT Robert P. J. Day
2013-08-27 17:35   ` Oliver Metz
2013-08-27 23:03     ` Luka Perkov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.