public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Marek Behún" <kabel@kernel.org>
To: Stefan Roese <sr@denx.de>
Cc: u-boot@lists.denx.de, "Pali Rohár" <pali@kernel.org>,
	"Marek Behún" <marek.behun@nic.cz>
Subject: [PATCH u-boot-marvell 03/11] tools: kwbimage: Set BOOT_FROM by default to SPI
Date: Mon,  8 Nov 2021 18:12:43 +0100	[thread overview]
Message-ID: <20211108171251.25382-4-kabel@kernel.org> (raw)
In-Reply-To: <20211108171251.25382-1-kabel@kernel.org>

From: Pali Rohár <pali@kernel.org>

kwbimage must have valid blockid member instead of zero value. Thus if
config file does not contain BOOT_FROM command, use by default the value
for SPI booting (which is probably the most common).

Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 tools/kwbimage.c | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)

diff --git a/tools/kwbimage.c b/tools/kwbimage.c
index d29f2cfcce..38b6e2fed2 100644
--- a/tools/kwbimage.c
+++ b/tools/kwbimage.c
@@ -266,6 +266,18 @@ static bool image_get_spezialized_img(void)
 	return e->sec_specialized_img;
 }
 
+static int image_get_bootfrom(void)
+{
+	struct image_cfg_element *e;
+
+	e = image_find_option(IMAGE_CFG_BOOT_FROM);
+	if (!e)
+		/* fallback to SPI if no BOOT_FROM is not provided */
+		return IBR_HDR_SPI_ID;
+
+	return e->bootfrom;
+}
+
 /*
  * Compute a 8-bit checksum of a memory area. This algorithm follows
  * the requirements of the Marvell SoC BootROM specifications.
@@ -884,10 +896,8 @@ static void *image_create_v0(size_t *imagesz, struct image_tool_params *params,
 	main_hdr->version   = 0;
 	main_hdr->destaddr  = cpu_to_le32(params->addr);
 	main_hdr->execaddr  = cpu_to_le32(params->ep);
+	main_hdr->blockid   = image_get_bootfrom();
 
-	e = image_find_option(IMAGE_CFG_BOOT_FROM);
-	if (e)
-		main_hdr->blockid = e->bootfrom;
 	e = image_find_option(IMAGE_CFG_NAND_ECC_MODE);
 	if (e)
 		main_hdr->nandeccmode = e->nandeccmode;
@@ -1232,9 +1242,8 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,
 	main_hdr->srcaddr      = cpu_to_le32(headersz);
 	main_hdr->ext          = hasext;
 	main_hdr->version      = 1;
-	e = image_find_option(IMAGE_CFG_BOOT_FROM);
-	if (e)
-		main_hdr->blockid = e->bootfrom;
+	main_hdr->blockid      = image_get_bootfrom();
+
 	e = image_find_option(IMAGE_CFG_NAND_BLKSZ);
 	if (e)
 		main_hdr->nandblocksize = e->nandblksz / (64 * 1024);
@@ -1559,17 +1568,6 @@ static int image_get_version(void)
 	return e->version;
 }
 
-static int image_get_bootfrom(void)
-{
-	struct image_cfg_element *e;
-
-	e = image_find_option(IMAGE_CFG_BOOT_FROM);
-	if (!e)
-		return -1;
-
-	return e->bootfrom;
-}
-
 static void kwbimage_set_header(void *ptr, struct stat *sbuf, int ifd,
 				struct image_tool_params *params)
 {
-- 
2.32.0


  parent reply	other threads:[~2021-11-08 17:13 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-08 17:12 [PATCH u-boot-marvell 00/11] Another kwbimage series Marek Behún
2021-11-08 17:12 ` [PATCH u-boot-marvell 01/11] tools: kwbimage: Add support for new commands UART_PORT and UART_MPP Marek Behún
2021-11-10  8:23   ` Stefan Roese
2021-11-08 17:12 ` [PATCH u-boot-marvell 02/11] tools: kwbimage: Explicitly set version also for kwbimage v0 Marek Behún
2021-11-10  8:23   ` Stefan Roese
2021-11-08 17:12 ` Marek Behún [this message]
2021-11-10  8:23   ` [PATCH u-boot-marvell 03/11] tools: kwbimage: Set BOOT_FROM by default to SPI Stefan Roese
2021-11-08 17:12 ` [PATCH u-boot-marvell 04/11] tools: kwbimage: Fix validation of kwbimage v0 Marek Behún
2021-11-10  8:24   ` Stefan Roese
2021-11-08 17:12 ` [PATCH u-boot-marvell 05/11] tools: kwbimage: Remove unused enums and prototypes Marek Behún
2021-11-10  8:25   ` Stefan Roese
2021-11-08 17:12 ` [PATCH u-boot-marvell 06/11] tools: kwbimage: Align final UART image to 128 bytes Marek Behún
2021-11-10  8:28   ` Stefan Roese
2021-11-08 17:12 ` [PATCH u-boot-marvell 07/11] tools: kwbimage: Do not put final image padding to the image data size Marek Behún
2021-11-10  8:28   ` Stefan Roese
2021-11-08 17:12 ` [PATCH u-boot-marvell 08/11] tools: kwbimage: Align kwbimage header to proper size Marek Behún
2021-11-10  8:28   ` Stefan Roese
2021-11-08 17:12 ` [PATCH u-boot-marvell 09/11] tools: kwbimage: Fill the real header size into the main header Marek Behún
2021-11-10  8:29   ` Stefan Roese
2021-12-25 17:48   ` Pierre Bourdon
2021-12-25 17:57     ` Pali Rohár
2021-12-25 18:06       ` Pierre Bourdon
2021-12-25 18:10         ` Pali Rohár
2021-12-25 18:18           ` Pierre Bourdon
2021-12-25 19:11             ` Pali Rohár
2021-12-25 19:48               ` Pierre Bourdon
2021-12-25 20:01                 ` Pali Rohár
2021-12-25 20:15                   ` Pierre Bourdon
2021-12-25 20:42                     ` Pali Rohár
2021-11-08 17:12 ` [PATCH u-boot-marvell 10/11] tools: kwbimage: Properly calculate and align kwbimage v0 header size Marek Behún
2021-11-10  8:30   ` Stefan Roese
2021-11-08 17:12 ` [PATCH u-boot-marvell 11/11] tools: kwbimage: Properly set srcaddr in kwbimage v0 Marek Behún
2021-11-10  8:30   ` Stefan Roese
2021-11-10  5:41 ` [PATCH u-boot-marvell 00/11] Another kwbimage series Stefan Roese
2021-11-10  8:19   ` Pali Rohár
2021-11-10 13:52 ` Stefan Roese

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211108171251.25382-4-kabel@kernel.org \
    --to=kabel@kernel.org \
    --cc=marek.behun@nic.cz \
    --cc=pali@kernel.org \
    --cc=sr@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox