From a2389213f2877967d2108dee61b86327048d0e18 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pali=20Roh=C3=A1r?= Date: Sun, 13 Feb 2022 01:04:33 +0100 Subject: [PATCH] tools: kwbimage: Fix dumping DATA registers for v0 images MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reported-by: Tony Dinh Tested-by: Tony Dinh Reviewed-by: Stefan Roese --- tools/kwbimage.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 9b63ce8..99d38cd 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.7.4