All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: Stefan Roese <sr@denx.de>
Cc: "Marek Behún" <marek.behun@nic.cz>,
	"Tony Dinh" <mibodhi@gmail.com>,
	u-boot@lists.denx.de
Subject: [PATCH] tools: kwbimage: Fix dumping DATA registers for v0 images
Date: Sun, 13 Feb 2022 01:04:33 +0100	[thread overview]
Message-ID: <20220213000433.16131-1-pali@kernel.org> (raw)

End of DATA register section is indicated by zero value in both raddr and
rdata.

So do not stop dumping registers with non-zero address and zero value.
And also print end of DATA registers section.

Fixes: 1a8e6b63e24f ("tools: kwbimage: Dump kwbimage config file on '-p -1' option")
Signed-off-by: Pali Rohár <pali@kernel.org>
Reported-by: Tony Dinh <mibodhi@gmail.com>
Tested-by: Tony Dinh <mibodhi@gmail.com>
---
 tools/kwbimage.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/kwbimage.c b/tools/kwbimage.c
index 9b63ce80ff4e..99d38cd1cfb2 100644
--- a/tools/kwbimage.c
+++ b/tools/kwbimage.c
@@ -2226,11 +2226,13 @@ static int kwbimage_generate_config(void *ptr, struct image_tool_params *params)
 		ehdr0 = (struct ext_hdr_v0 *)(mhdr0 + 1);
 		if (ehdr0->offset) {
 			for (regdata = (struct ext_hdr_v0_reg *)((uint8_t *)ptr + ehdr0->offset);
-			     (uint8_t *)regdata < (uint8_t *)ptr + header_size && regdata->raddr &&
-			     regdata->rdata;
+			     (uint8_t *)regdata < (uint8_t *)ptr + header_size &&
+			     (regdata->raddr || regdata->rdata);
 			     regdata++)
 				fprintf(f, "DATA 0x%08x 0x%08x\n", le32_to_cpu(regdata->raddr),
 					le32_to_cpu(regdata->rdata));
+			if ((uint8_t *)regdata != (uint8_t *)ptr + ehdr0->offset)
+				fprintf(f, "DATA 0x0 0x0\n");
 		}
 	}
 
-- 
2.20.1


             reply	other threads:[~2022-02-13  0:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-13  0:04 Pali Rohár [this message]
2022-02-15 11:07 ` [PATCH] tools: kwbimage: Fix dumping DATA registers for v0 images Stefan Roese
2022-02-17 15:36 ` 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=20220213000433.16131-1-pali@kernel.org \
    --to=pali@kernel.org \
    --cc=marek.behun@nic.cz \
    --cc=mibodhi@gmail.com \
    --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 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.