]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
tools: kwboot: Fix patching of SPI/NOR XIP images
authorPali Rohár <pali@kernel.org>
Sat, 21 Jan 2023 11:59:20 +0000 (12:59 +0100)
committerStefan Roese <sr@denx.de>
Wed, 1 Mar 2023 05:39:17 +0000 (06:39 +0100)
Marvell BootROM interprets execaddr of SPI/NOR XIP images as relative byte
offset from the from the beginning of the flash device. So if data image
offset and execute offset are not same then it is needed to adjust them
also in DDR RAM.

Fixes: f2c644e0b8bc ("tools: kwboot: Patch destination address to DDR area for SPI image")
Signed-off-by: Pali Rohár <pali@kernel.org>
tools/kwboot.c

index f624edc7798f278f06f9b9defcc0ca8fb28b6501..cb31d5b858cef819d92e09b5c49ac0964411bbcb 100644 (file)
@@ -2022,8 +2022,8 @@ kwboot_img_patch(void *img, size_t *size, int baudrate)
        case IBR_HDR_SPI_ID:
                if (hdr->destaddr == cpu_to_le32(0xFFFFFFFF)) {
                        kwboot_printv("Patching destination and execution addresses from SPI/NOR XIP area to DDR area 0x00800000\n");
-                       hdr->destaddr = cpu_to_le32(0x00800000);
-                       hdr->execaddr = cpu_to_le32(0x00800000);
+                       hdr->destaddr = cpu_to_le32(0x00800000 + le32_to_cpu(hdr->srcaddr));
+                       hdr->execaddr = cpu_to_le32(0x00800000 + le32_to_cpu(hdr->execaddr));
                }
                break;
        }