All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mtd: bcm47xxpart: find NVRAM partitions in middle blocks
@ 2014-08-14  8:22 Rafał Miłecki
  2014-08-18 18:20 ` [PATCH V2] " Rafał Miłecki
  0 siblings, 1 reply; 3+ messages in thread
From: Rafał Miłecki @ 2014-08-14  8:22 UTC (permalink / raw)
  To: linux-mtd, David Woodhouse, Artem Bityutskiy, Brian Norris
  Cc: Hauke Mehrtens, Rafał Miłecki

Old devices used to have NVRAM at the very end of flash and they could
be unaligned (starting at some offset in a block).
In new devices NVRAM can be located quite randomly, however it seems to
always start at the beginning of a block. For example Netgear R6250 has
NVRAM located right after the bootloader, before the kernel partition.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
 drivers/mtd/bcm47xxpart.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/mtd/bcm47xxpart.c b/drivers/mtd/bcm47xxpart.c
index adfa74c..407a444 100644
--- a/drivers/mtd/bcm47xxpart.c
+++ b/drivers/mtd/bcm47xxpart.c
@@ -199,6 +199,13 @@ static int bcm47xxpart_parse(struct mtd_info *master,
 			continue;
 		}
 
+		/* New (ARM?) devices may have NVRAM in some middle block */
+		if (buf[0x000 / 4] == NVRAM_HEADER) {
+			bcm47xxpart_add_part(&parts[curr_part++], "nvram",
+					     offset, 0);
+			continue;
+		}
+
 		/* Read middle of the block */
 		if (mtd_read(master, offset + 0x8000, 0x4,
 			     &bytes_read, (uint8_t *)buf) < 0) {
-- 
1.8.4.5

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

* [PATCH V2] mtd: bcm47xxpart: find NVRAM partitions in middle blocks
  2014-08-14  8:22 [PATCH] mtd: bcm47xxpart: find NVRAM partitions in middle blocks Rafał Miłecki
@ 2014-08-18 18:20 ` Rafał Miłecki
  2014-09-18  6:16   ` Brian Norris
  0 siblings, 1 reply; 3+ messages in thread
From: Rafał Miłecki @ 2014-08-18 18:20 UTC (permalink / raw)
  To: linux-mtd, David Woodhouse, Artem Bityutskiy, Brian Norris
  Cc: Hauke Mehrtens, Rafał Miłecki

Old devices used to have NVRAM at the very end of flash and they could
be unaligned (starting at some offset in a block).
In new devices NVRAM can be located quite randomly, however it seems to
always start at the beginning of a block. For example Netgear R6250 has
NVRAM located right after the bootloader, before the kernel partition.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
V2: Ignore last block to avoid having two "nvram" partitions.
---
 drivers/mtd/bcm47xxpart.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/mtd/bcm47xxpart.c b/drivers/mtd/bcm47xxpart.c
index 035690e..da641ac 100644
--- a/drivers/mtd/bcm47xxpart.c
+++ b/drivers/mtd/bcm47xxpart.c
@@ -224,6 +224,16 @@ static int bcm47xxpart_parse(struct mtd_info *master,
 			continue;
 		}
 
+		/* New (ARM?) devices may have NVRAM in some middle block. Last
+		 * block will be checked later, so skip it.
+		 */
+		if (offset != master->size - blocksize &&
+		    buf[0x000 / 4] == NVRAM_HEADER) {
+			bcm47xxpart_add_part(&parts[curr_part++], "nvram",
+					     offset, 0);
+			continue;
+		}
+
 		/* Read middle of the block */
 		if (mtd_read(master, offset + 0x8000, 0x4,
 			     &bytes_read, (uint8_t *)buf) < 0) {
-- 
1.8.4.5

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

* Re: [PATCH V2] mtd: bcm47xxpart: find NVRAM partitions in middle blocks
  2014-08-18 18:20 ` [PATCH V2] " Rafał Miłecki
@ 2014-09-18  6:16   ` Brian Norris
  0 siblings, 0 replies; 3+ messages in thread
From: Brian Norris @ 2014-09-18  6:16 UTC (permalink / raw)
  To: Rafał Miłecki
  Cc: Hauke Mehrtens, linux-mtd, David Woodhouse, Artem Bityutskiy

On Mon, Aug 18, 2014 at 08:20:27PM +0200, Rafał Miłecki wrote:
> Old devices used to have NVRAM at the very end of flash and they could
> be unaligned (starting at some offset in a block).
> In new devices NVRAM can be located quite randomly, however it seems to
> always start at the beginning of a block. For example Netgear R6250 has
> NVRAM located right after the bootloader, before the kernel partition.
> 
> Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
> ---
> V2: Ignore last block to avoid having two "nvram" partitions.

Tweaked the multi-line comment style and pushed to l2-mtd.git. Thanks!

> ---
>  drivers/mtd/bcm47xxpart.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/mtd/bcm47xxpart.c b/drivers/mtd/bcm47xxpart.c
> index 035690e..da641ac 100644
> --- a/drivers/mtd/bcm47xxpart.c
> +++ b/drivers/mtd/bcm47xxpart.c
> @@ -224,6 +224,16 @@ static int bcm47xxpart_parse(struct mtd_info *master,
>  			continue;
>  		}
>  
> +		/* New (ARM?) devices may have NVRAM in some middle block. Last
> +		 * block will be checked later, so skip it.
> +		 */
> +		if (offset != master->size - blocksize &&
> +		    buf[0x000 / 4] == NVRAM_HEADER) {
> +			bcm47xxpart_add_part(&parts[curr_part++], "nvram",
> +					     offset, 0);
> +			continue;
> +		}
> +
>  		/* Read middle of the block */
>  		if (mtd_read(master, offset + 0x8000, 0x4,
>  			     &bytes_read, (uint8_t *)buf) < 0) {

Brian

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

end of thread, other threads:[~2014-09-18  6:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-14  8:22 [PATCH] mtd: bcm47xxpart: find NVRAM partitions in middle blocks Rafał Miłecki
2014-08-18 18:20 ` [PATCH V2] " Rafał Miłecki
2014-09-18  6:16   ` Brian Norris

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.