diff mbox series

[RFC,u-boot-mvebu,01/59] tools: kwbimage: Fix generating, verifying and extracting SDIO kwbimage

Message ID 20230221201925.9644-2-pali@kernel.org
State Accepted
Commit 14b866e6d650645881cac041db64f67158ced24e
Delegated to: Stefan Roese
Headers show
Series arm: mvebu: Various fixes | expand

Commit Message

Pali Rohár Feb. 21, 2023, 8:18 p.m. UTC
Despite the official specification, Marvell BootROM does not interpret
srcaddr from SDIO image as offset in number of sectors (like for SATA
image), but as offset in bytes (like for all other images except SATA).

To generate SDIO kwbimage compatible with Marvell BootROM, it is needed to
have srcaddr in bytes. This change fixes SDIO images for Armada 38x SoCs.

Fixes: 501a54a29cc2 ("tools: kwbimage: Fix generation of SATA, SDIO and PCIe images")
Fixes: 5c61710c9880 ("tools: kwbimage: Properly set srcaddr in kwbimage v0")
Fixes: e0c243c398a7 ("tools: kwbimage: Validate data checksum of v1 images")
Fixes: aa6943ca3122 ("kwbimage: Add support for extracting images via dumpimage tool")
Signed-off-by: Pali Rohár <pali@kernel.org>
---
 tools/kwbimage.c | 29 -----------------------------
 1 file changed, 29 deletions(-)
diff mbox series

Patch

diff --git a/tools/kwbimage.c b/tools/kwbimage.c
index 6abb9f2d5c01..09d52d47652f 100644
--- a/tools/kwbimage.c
+++ b/tools/kwbimage.c
@@ -1021,15 +1021,6 @@  static void *image_create_v0(size_t *imagesz, struct image_tool_params *params,
 	if (main_hdr->blockid == IBR_HDR_SATA_ID)
 		main_hdr->srcaddr = cpu_to_le32(headersz / 512 + 1);
 
-	/*
-	 * For SDIO srcaddr is specified in number of sectors starting from
-	 * sector 0. The main header is stored at sector number 0.
-	 * This expects sector size to be 512 bytes.
-	 * Header size is already aligned.
-	 */
-	if (main_hdr->blockid == IBR_HDR_SDIO_ID)
-		main_hdr->srcaddr = cpu_to_le32(headersz / 512);
-
 	/* For PCIe srcaddr is not used and must be set to 0xFFFFFFFF. */
 	if (main_hdr->blockid == IBR_HDR_PEX_ID)
 		main_hdr->srcaddr = cpu_to_le32(0xFFFFFFFF);
@@ -1478,15 +1469,6 @@  static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,
 	if (main_hdr->blockid == IBR_HDR_SATA_ID)
 		main_hdr->srcaddr = cpu_to_le32(headersz / 512 + 1);
 
-	/*
-	 * For SDIO srcaddr is specified in number of sectors starting from
-	 * sector 0. The main header is stored at sector number 0.
-	 * This expects sector size to be 512 bytes.
-	 * Header size is already aligned.
-	 */
-	if (main_hdr->blockid == IBR_HDR_SDIO_ID)
-		main_hdr->srcaddr = cpu_to_le32(headersz / 512);
-
 	/* For PCIe srcaddr is not used and must be set to 0xFFFFFFFF. */
 	if (main_hdr->blockid == IBR_HDR_PEX_ID)
 		main_hdr->srcaddr = cpu_to_le32(0xFFFFFFFF);
@@ -2039,14 +2021,6 @@  static int kwbimage_verify_header(unsigned char *ptr, int image_size,
 		offset *= 512;
 	}
 
-	/*
-	 * For SDIO srcaddr is specified in number of sectors.
-	 * This expects that sector size is 512 bytes and recalculates
-	 * data offset to bytes.
-	 */
-	if (blockid == IBR_HDR_SDIO_ID)
-		offset *= 512;
-
 	/*
 	 * For PCIe srcaddr is always set to 0xFFFFFFFF.
 	 * This expects that data starts after all headers.
@@ -2408,9 +2382,6 @@  static int kwbimage_extract_subimage(void *ptr, struct image_tool_params *params
 			offset *= 512;
 		}
 
-		if (mhdr->blockid == IBR_HDR_SDIO_ID)
-			offset *= 512;
-
 		if (mhdr->blockid == IBR_HDR_PEX_ID && offset == 0xFFFFFFFF)
 			offset = header_size;