All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] arm: mvebu: nandpagesize support for kwbimage v1
@ 2021-10-22 10:37 Pali Rohár
  2021-10-22 10:37 ` [PATCH 1/3] tools: kwbimage: Add support for NAND_PAGE_SIZE command also for v1 images Pali Rohár
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Pali Rohár @ 2021-10-22 10:37 UTC (permalink / raw)
  To: Stefan Roese; +Cc: Marek Behún, u-boot

This patch series updates mvebu code which handles nandpagesize in kwbimage v1.

Pali Rohár (3):
  tools: kwbimage: Add support for NAND_PAGE_SIZE command also for v1
    images
  tools: kwboot: Patch nandpagesize to zero also for v1 image
  arm: mvebu: Update name of kwbimage v1 field at offset 0x2-0x3

 arch/arm/mach-mvebu/spl.c |  2 +-
 cmd/mvebu/bubt.c          |  2 +-
 tools/kwbimage.c          |  3 +++
 tools/kwbimage.h          |  2 +-
 tools/kwboot.c            | 13 ++++++-------
 5 files changed, 12 insertions(+), 10 deletions(-)

-- 
2.20.1


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

* [PATCH 1/3] tools: kwbimage: Add support for NAND_PAGE_SIZE command also for v1 images
  2021-10-22 10:37 [PATCH 0/3] arm: mvebu: nandpagesize support for kwbimage v1 Pali Rohár
@ 2021-10-22 10:37 ` Pali Rohár
  2021-10-26  4:46   ` Stefan Roese
  2021-10-22 10:37 ` [PATCH 2/3] tools: kwboot: Patch nandpagesize to zero also for v1 image Pali Rohár
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Pali Rohár @ 2021-10-22 10:37 UTC (permalink / raw)
  To: Stefan Roese; +Cc: Marek Behún, u-boot

The NAND_PAGE_SIZE command is already supported by mkimage for v0 images,
but not for v1 images.

A38x and A39x BootROM supports reading NAND flash page size from v1 image
in the same way as Kirkwood BootROM from v0 image. It it documented in A38x
and A39x Functional Specification.

Signed-off-by: Pali Rohár <pali@kernel.org>
---
 tools/kwbimage.c | 3 +++
 tools/kwbimage.h | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/kwbimage.c b/tools/kwbimage.c
index e9324baddba4..67c0c628ae9f 100644
--- a/tools/kwbimage.c
+++ b/tools/kwbimage.c
@@ -1231,6 +1231,9 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,
 	e = image_find_option(IMAGE_CFG_NAND_BLKSZ);
 	if (e)
 		main_hdr->nandblocksize = e->nandblksz / (64 * 1024);
+	e = image_find_option(IMAGE_CFG_NAND_PAGESZ);
+	if (e)
+		main_hdr->nandpagesize = cpu_to_le16(e->nandpagesz);
 	e = image_find_option(IMAGE_CFG_NAND_BADBLK_LOCATION);
 	if (e)
 		main_hdr->nandbadblklocation = e->nandbadblklocation;
diff --git a/tools/kwbimage.h b/tools/kwbimage.h
index 126d482fe722..f1ba95c2fa5b 100644
--- a/tools/kwbimage.h
+++ b/tools/kwbimage.h
@@ -73,7 +73,7 @@ struct ext_hdr_v0 {
 struct main_hdr_v1 {
 	uint8_t  blockid;               /* 0x0       */
 	uint8_t  flags;                 /* 0x1       */
-	uint16_t reserved2;             /* 0x2-0x3   */
+	uint16_t nandpagesize;          /* 0x2-0x3   */
 	uint32_t blocksize;             /* 0x4-0x7   */
 	uint8_t  version;               /* 0x8       */
 	uint8_t  headersz_msb;          /* 0x9       */
-- 
2.20.1


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

* [PATCH 2/3] tools: kwboot: Patch nandpagesize to zero also for v1 image
  2021-10-22 10:37 [PATCH 0/3] arm: mvebu: nandpagesize support for kwbimage v1 Pali Rohár
  2021-10-22 10:37 ` [PATCH 1/3] tools: kwbimage: Add support for NAND_PAGE_SIZE command also for v1 images Pali Rohár
@ 2021-10-22 10:37 ` Pali Rohár
  2021-10-26  4:47   ` Stefan Roese
  2021-10-22 10:37 ` [PATCH 3/3] arm: mvebu: Update name of kwbimage v1 field at offset 0x2-0x3 Pali Rohár
  2021-10-28 10:49 ` [PATCH 0/3] arm: mvebu: nandpagesize support for kwbimage v1 Stefan Roese
  3 siblings, 1 reply; 8+ messages in thread
From: Pali Rohár @ 2021-10-22 10:37 UTC (permalink / raw)
  To: Stefan Roese; +Cc: Marek Behún, u-boot

kwbimage v1 has also nandpagesize field. So set it to zero for both image
versions when image is not signed.

Signed-off-by: Pali Rohár <pali@kernel.org>
---
 tools/kwboot.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/tools/kwboot.c b/tools/kwboot.c
index eb4f5ab87917..7e1be2962302 100644
--- a/tools/kwboot.c
+++ b/tools/kwboot.c
@@ -1428,13 +1428,6 @@ kwboot_img_patch(void *img, size_t *size, int baudrate)
 	if (csum != hdr->checksum)
 		goto err;
 
-	if (image_ver == 0) {
-		struct main_hdr_v0 *hdr_v0 = img;
-
-		hdr_v0->nandeccmode = IBR_HDR_ECC_DISABLED;
-		hdr_v0->nandpagesize = 0;
-	}
-
 	srcaddr = le32_to_cpu(hdr->srcaddr);
 
 	switch (hdr->blockid) {
@@ -1480,6 +1473,12 @@ kwboot_img_patch(void *img, size_t *size, int baudrate)
 		hdr->blockid = IBR_HDR_UART_ID;
 	}
 
+	if (!is_secure) {
+		if (image_ver == 0)
+			((struct main_hdr_v0 *)img)->nandeccmode = IBR_HDR_ECC_DISABLED;
+		hdr->nandpagesize = 0;
+	}
+
 	if (baudrate) {
 		uint32_t codesz = sizeof(kwboot_baud_code);
 		void *code;
-- 
2.20.1


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

* [PATCH 3/3] arm: mvebu: Update name of kwbimage v1 field at offset 0x2-0x3
  2021-10-22 10:37 [PATCH 0/3] arm: mvebu: nandpagesize support for kwbimage v1 Pali Rohár
  2021-10-22 10:37 ` [PATCH 1/3] tools: kwbimage: Add support for NAND_PAGE_SIZE command also for v1 images Pali Rohár
  2021-10-22 10:37 ` [PATCH 2/3] tools: kwboot: Patch nandpagesize to zero also for v1 image Pali Rohár
@ 2021-10-22 10:37 ` Pali Rohár
  2021-10-26  4:47   ` Stefan Roese
  2021-10-28 10:49 ` [PATCH 0/3] arm: mvebu: nandpagesize support for kwbimage v1 Stefan Roese
  3 siblings, 1 reply; 8+ messages in thread
From: Pali Rohár @ 2021-10-22 10:37 UTC (permalink / raw)
  To: Stefan Roese; +Cc: Marek Behún, u-boot

At this offset is stored nand page size.

Signed-off-by: Pali Rohár <pali@kernel.org>
---
 arch/arm/mach-mvebu/spl.c | 2 +-
 cmd/mvebu/bubt.c          | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c
index 04d9640b142d..cad3f0a48893 100644
--- a/arch/arm/mach-mvebu/spl.c
+++ b/arch/arm/mach-mvebu/spl.c
@@ -76,7 +76,7 @@
 struct kwbimage_main_hdr_v1 {
 	uint8_t  blockid;               /* 0x0       */
 	uint8_t  flags;                 /* 0x1       */
-	uint16_t reserved2;             /* 0x2-0x3   */
+	uint16_t nandpagesize;          /* 0x2-0x3   */
 	uint32_t blocksize;             /* 0x4-0x7   */
 	uint8_t  version;               /* 0x8       */
 	uint8_t  headersz_msb;          /* 0x9       */
diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c
index 470fb0e92097..a7f3ff3c6fc0 100644
--- a/cmd/mvebu/bubt.c
+++ b/cmd/mvebu/bubt.c
@@ -89,7 +89,7 @@ struct mvebu_image_info {
 struct a38x_main_hdr_v1 {
 	u8  blockid;               /* 0x0       */
 	u8  flags;                 /* 0x1       */
-	u16 reserved2;             /* 0x2-0x3   */
+	u16 nandpagesize;          /* 0x2-0x3   */
 	u32 blocksize;             /* 0x4-0x7   */
 	u8  version;               /* 0x8       */
 	u8  headersz_msb;          /* 0x9       */
-- 
2.20.1


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

* Re: [PATCH 1/3] tools: kwbimage: Add support for NAND_PAGE_SIZE command also for v1 images
  2021-10-22 10:37 ` [PATCH 1/3] tools: kwbimage: Add support for NAND_PAGE_SIZE command also for v1 images Pali Rohár
@ 2021-10-26  4:46   ` Stefan Roese
  0 siblings, 0 replies; 8+ messages in thread
From: Stefan Roese @ 2021-10-26  4:46 UTC (permalink / raw)
  To: Pali Rohár; +Cc: Marek Behún, u-boot

On 22.10.21 12:37, Pali Rohár wrote:
> The NAND_PAGE_SIZE command is already supported by mkimage for v0 images,
> but not for v1 images.
> 
> A38x and A39x BootROM supports reading NAND flash page size from v1 image
> in the same way as Kirkwood BootROM from v0 image. It it documented in A38x
> and A39x Functional Specification.
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
>   tools/kwbimage.c | 3 +++
>   tools/kwbimage.h | 2 +-
>   2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/kwbimage.c b/tools/kwbimage.c
> index e9324baddba4..67c0c628ae9f 100644
> --- a/tools/kwbimage.c
> +++ b/tools/kwbimage.c
> @@ -1231,6 +1231,9 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,
>   	e = image_find_option(IMAGE_CFG_NAND_BLKSZ);
>   	if (e)
>   		main_hdr->nandblocksize = e->nandblksz / (64 * 1024);
> +	e = image_find_option(IMAGE_CFG_NAND_PAGESZ);
> +	if (e)
> +		main_hdr->nandpagesize = cpu_to_le16(e->nandpagesz);
>   	e = image_find_option(IMAGE_CFG_NAND_BADBLK_LOCATION);
>   	if (e)
>   		main_hdr->nandbadblklocation = e->nandbadblklocation;
> diff --git a/tools/kwbimage.h b/tools/kwbimage.h
> index 126d482fe722..f1ba95c2fa5b 100644
> --- a/tools/kwbimage.h
> +++ b/tools/kwbimage.h
> @@ -73,7 +73,7 @@ struct ext_hdr_v0 {
>   struct main_hdr_v1 {
>   	uint8_t  blockid;               /* 0x0       */
>   	uint8_t  flags;                 /* 0x1       */
> -	uint16_t reserved2;             /* 0x2-0x3   */
> +	uint16_t nandpagesize;          /* 0x2-0x3   */
>   	uint32_t blocksize;             /* 0x4-0x7   */
>   	uint8_t  version;               /* 0x8       */
>   	uint8_t  headersz_msb;          /* 0x9       */
> 


Viele Grüße,
Stefan

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

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

* Re: [PATCH 2/3] tools: kwboot: Patch nandpagesize to zero also for v1 image
  2021-10-22 10:37 ` [PATCH 2/3] tools: kwboot: Patch nandpagesize to zero also for v1 image Pali Rohár
@ 2021-10-26  4:47   ` Stefan Roese
  0 siblings, 0 replies; 8+ messages in thread
From: Stefan Roese @ 2021-10-26  4:47 UTC (permalink / raw)
  To: Pali Rohár; +Cc: Marek Behún, u-boot

On 22.10.21 12:37, Pali Rohár wrote:
> kwbimage v1 has also nandpagesize field. So set it to zero for both image
> versions when image is not signed.
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
>   tools/kwboot.c | 13 ++++++-------
>   1 file changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/tools/kwboot.c b/tools/kwboot.c
> index eb4f5ab87917..7e1be2962302 100644
> --- a/tools/kwboot.c
> +++ b/tools/kwboot.c
> @@ -1428,13 +1428,6 @@ kwboot_img_patch(void *img, size_t *size, int baudrate)
>   	if (csum != hdr->checksum)
>   		goto err;
>   
> -	if (image_ver == 0) {
> -		struct main_hdr_v0 *hdr_v0 = img;
> -
> -		hdr_v0->nandeccmode = IBR_HDR_ECC_DISABLED;
> -		hdr_v0->nandpagesize = 0;
> -	}
> -
>   	srcaddr = le32_to_cpu(hdr->srcaddr);
>   
>   	switch (hdr->blockid) {
> @@ -1480,6 +1473,12 @@ kwboot_img_patch(void *img, size_t *size, int baudrate)
>   		hdr->blockid = IBR_HDR_UART_ID;
>   	}
>   
> +	if (!is_secure) {
> +		if (image_ver == 0)
> +			((struct main_hdr_v0 *)img)->nandeccmode = IBR_HDR_ECC_DISABLED;
> +		hdr->nandpagesize = 0;
> +	}
> +
>   	if (baudrate) {
>   		uint32_t codesz = sizeof(kwboot_baud_code);
>   		void *code;
> 


Viele Grüße,
Stefan

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

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

* Re: [PATCH 3/3] arm: mvebu: Update name of kwbimage v1 field at offset 0x2-0x3
  2021-10-22 10:37 ` [PATCH 3/3] arm: mvebu: Update name of kwbimage v1 field at offset 0x2-0x3 Pali Rohár
@ 2021-10-26  4:47   ` Stefan Roese
  0 siblings, 0 replies; 8+ messages in thread
From: Stefan Roese @ 2021-10-26  4:47 UTC (permalink / raw)
  To: Pali Rohár; +Cc: Marek Behún, u-boot

On 22.10.21 12:37, Pali Rohár wrote:
> At this offset is stored nand page size.
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
>   arch/arm/mach-mvebu/spl.c | 2 +-
>   cmd/mvebu/bubt.c          | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c
> index 04d9640b142d..cad3f0a48893 100644
> --- a/arch/arm/mach-mvebu/spl.c
> +++ b/arch/arm/mach-mvebu/spl.c
> @@ -76,7 +76,7 @@
>   struct kwbimage_main_hdr_v1 {
>   	uint8_t  blockid;               /* 0x0       */
>   	uint8_t  flags;                 /* 0x1       */
> -	uint16_t reserved2;             /* 0x2-0x3   */
> +	uint16_t nandpagesize;          /* 0x2-0x3   */
>   	uint32_t blocksize;             /* 0x4-0x7   */
>   	uint8_t  version;               /* 0x8       */
>   	uint8_t  headersz_msb;          /* 0x9       */
> diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c
> index 470fb0e92097..a7f3ff3c6fc0 100644
> --- a/cmd/mvebu/bubt.c
> +++ b/cmd/mvebu/bubt.c
> @@ -89,7 +89,7 @@ struct mvebu_image_info {
>   struct a38x_main_hdr_v1 {
>   	u8  blockid;               /* 0x0       */
>   	u8  flags;                 /* 0x1       */
> -	u16 reserved2;             /* 0x2-0x3   */
> +	u16 nandpagesize;          /* 0x2-0x3   */
>   	u32 blocksize;             /* 0x4-0x7   */
>   	u8  version;               /* 0x8       */
>   	u8  headersz_msb;          /* 0x9       */
> 


Viele Grüße,
Stefan

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

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

* Re: [PATCH 0/3] arm: mvebu: nandpagesize support for kwbimage v1
  2021-10-22 10:37 [PATCH 0/3] arm: mvebu: nandpagesize support for kwbimage v1 Pali Rohár
                   ` (2 preceding siblings ...)
  2021-10-22 10:37 ` [PATCH 3/3] arm: mvebu: Update name of kwbimage v1 field at offset 0x2-0x3 Pali Rohár
@ 2021-10-28 10:49 ` Stefan Roese
  3 siblings, 0 replies; 8+ messages in thread
From: Stefan Roese @ 2021-10-28 10:49 UTC (permalink / raw)
  To: Pali Rohár; +Cc: Marek Behún, u-boot

On 22.10.21 12:37, Pali Rohár wrote:
> This patch series updates mvebu code which handles nandpagesize in kwbimage v1.
> 
> Pali Rohár (3):
>    tools: kwbimage: Add support for NAND_PAGE_SIZE command also for v1
>      images
>    tools: kwboot: Patch nandpagesize to zero also for v1 image
>    arm: mvebu: Update name of kwbimage v1 field at offset 0x2-0x3
> 
>   arch/arm/mach-mvebu/spl.c |  2 +-
>   cmd/mvebu/bubt.c          |  2 +-
>   tools/kwbimage.c          |  3 +++
>   tools/kwbimage.h          |  2 +-
>   tools/kwboot.c            | 13 ++++++-------
>   5 files changed, 12 insertions(+), 10 deletions(-)
> 

Applied to u-boot-marvell/master

Thanks,
Stefan

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

end of thread, other threads:[~2021-10-28 10:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-22 10:37 [PATCH 0/3] arm: mvebu: nandpagesize support for kwbimage v1 Pali Rohár
2021-10-22 10:37 ` [PATCH 1/3] tools: kwbimage: Add support for NAND_PAGE_SIZE command also for v1 images Pali Rohár
2021-10-26  4:46   ` Stefan Roese
2021-10-22 10:37 ` [PATCH 2/3] tools: kwboot: Patch nandpagesize to zero also for v1 image Pali Rohár
2021-10-26  4:47   ` Stefan Roese
2021-10-22 10:37 ` [PATCH 3/3] arm: mvebu: Update name of kwbimage v1 field at offset 0x2-0x3 Pali Rohár
2021-10-26  4:47   ` Stefan Roese
2021-10-28 10:49 ` [PATCH 0/3] arm: mvebu: nandpagesize support for kwbimage v1 Stefan Roese

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.