[PATCH 0/3] arm: mvebu: nandpagesize support for kwbimage v1

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(-)

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 */

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)
e = image_find_option(IMAGE_CFG_NAND_BADBLK_LOCATION); if (e) main_hdr->nandbadblklocation = e->nandbadblklocation;main_hdr->nandpagesize = cpu_to_le16(e->nandpagesz);
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

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;

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

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 */

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

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
participants (2)
-
Pali Rohár
-
Stefan Roese