Skip to contentSkip to conversation

tools: kwboot: patch destaddr only for SoCs with header version 1

PATCH Superseded Simon Baatz 2 participants 2 messages Aug 8, 2016 – Aug 9, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools: kwboot: patch destaddr only for SoCs with header version 1

Commit f4db6c976cf ("arm: mvebu: Add runtime detection of UART (xmodem) boot-mode") added a change to hdr->destaddr when dynamically patching an image for UART boot mode. With this change, kwboot ceases to work on Kirkwood.

Thus, let's change hdr->destaddr only when we are patching an image with header version 1 (Orion and Kirkwood use header version 0).

Fixes f4db6c976cf ("arm: mvebu: Add runtime detection of UART (xmodem) boot-mode")
Cc Stefan Roese <[email protected]>
Cc Luka Perkov <[email protected]>
Cc Kevin Smith <[email protected]>

---

Hi,

this patch makes kwboot work again on Kirkwood for me. However, I could not verify whether Armada XP / 38x still works, since I don't have such hardware.

- Simon

 tools/kwboot.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
tools/kwboot.c +8 -8
index e00958a..4160e5b 100644
@@ -655,14 +655,6 @@ kwboot_img_patch_hdr(void *img, size_t size)
 
 	hdr->blockid = IBR_HDR_UART_ID;
 
-	/*
-	 * Subtract mkimage header size from destination address
-	 * as this header is not expected by the Marvell BootROM.
-	 * This way, the execution address is identical to the
-	 * one the image is compiled for (TEXT_BASE).
-	 */
-	hdr->destaddr = hdr->destaddr - sizeof(struct image_header);
-
 	if (image_ver == 0) {
 		struct main_hdr_v0 *hdr_v0 = img;
 
@@ -672,6 +664,14 @@ kwboot_img_patch_hdr(void *img, size_t size)
 		hdr_v0->srcaddr = hdr_v0->ext
 			? sizeof(struct kwb_header)
 			: sizeof(*hdr_v0);
+	} else {
+	  /*
+	   * Subtract mkimage header size from destination address
+	   * as this header is not expected by the Marvell BootROM.
+	   * This way, the execution address is identical to the
+	   * one the image is compiled for (TEXT_BASE).
+	   */
+	  hdr->destaddr = hdr->destaddr - sizeof(struct image_header);
 	}
 
 	hdr->checksum = kwboot_img_csum8(hdr, hdrsz) - csum;
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 tools: kwboot: patch destaddr only for SoCs with header version 1

Hi Simon,

Quoted 13 lines · Simon Baatz

Commit f4db6c976cf ("arm: mvebu: Add runtime detection of UART (xmodem) boot-mode") added a change to hdr->destaddr when dynamically patching an image for UART boot mode. With this change, kwboot ceases to work on Kirkwood.

Thus, let's change hdr->destaddr only when we are patching an image with header version 1 (Orion and Kirkwood use header version 0).

Fixes f4db6c976cf ("arm: mvebu: Add runtime detection of UART (xmodem) boot-mode")
Cc Stefan Roese <[email protected]>
Cc Luka Perkov <[email protected]>
Cc Kevin Smith <[email protected]>
Quoted 7 lines

---

Hi,

this patch makes kwboot work again on Kirkwood for me. However, I could not verify whether Armada XP / 38x still works, since I don't have such hardware.

Thanks for the patch. I'll test it AXP / A38x next week. One comment below.

Quoted 26 lines

- Simon

 tools/kwboot.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
tools/kwboot.c +0 -8
index e00958a..4160e5b 100644
@@ -655,14 +655,6 @@ kwboot_img_patch_hdr(void *img, size_t size)
 
 	hdr->blockid = IBR_HDR_UART_ID;
 
-	/*
-	 * Subtract mkimage header size from destination address
-	 * as this header is not expected by the Marvell BootROM.
-	 * This way, the execution address is identical to the
-	 * one the image is compiled for (TEXT_BASE).
-	 */
-	hdr->destaddr = hdr->destaddr - sizeof(struct image_header);
-
 	if (image_ver == 0) {
 		struct main_hdr_v0 *hdr_v0 = img;
 
@@ -672,6 +664,14 @@ kwboot_img_patch_hdr(void *img, size_t size)
 		hdr_v0->srcaddr = hdr_v0->ext

tools/kwboot.c kwboot_img_patch_hdr(void *img, size_t size) · line 674

Quoted 10 lines
tools/kwboot.c +8 -0
 			? sizeof(struct kwb_header)
 			: sizeof(*hdr_v0);
+	} else {
+	  /*
+	   * Subtract mkimage header size from destination address
+	   * as this header is not expected by the Marvell BootROM.
+	   * This way, the execution address is identical to the
+	   * one the image is compiled for (TEXT_BASE).
+	   */
+	  hdr->destaddr = hdr->destaddr - sizeof(struct image_header);

Indentation looks incorrect here. Please change and send v2. I'll apply it next after I return from my short vacation.

Thanks,
Stefan