From: Pali Rohár Date: Sat, 21 Jan 2023 12:45:36 +0000 (+0100) Subject: tools: kwboot: Fix parsing SATA kwbimage X-Git-Tag: v2025.01-rc5-pxa1908~1023^2~41^2~53 X-Git-Url: http://git.dujemihanovic.xyz/html/static/%7B%7B%20.RelPermalink%20%7D%7D?a=commitdiff_plain;h=e1c4ed57d5190e3064ae10ae3a87cdc75d2786fc;p=u-boot.git tools: kwboot: Fix parsing SATA kwbimage Despite the official specification, Marvell BootROM does not interpret srcaddr from SATA image as number of sectors the beginning of the hard drive, but as number of sectors relative to the main header. To parse SATA kwbimage in the same way as Marvell BootROM, it is needed to interpret srcaddr as relative offset to the main header. This change fixes loading of SATA images via kwboot over UART. Fixes: 792e42355083 ("tools: kwboot: Patch source address in image header") Signed-off-by: Pali Rohár --- diff --git a/tools/kwboot.c b/tools/kwboot.c index 188f944263..bf410520de 100644 --- a/tools/kwboot.c +++ b/tools/kwboot.c @@ -1888,10 +1888,7 @@ kwboot_img_patch(void *img, size_t *size, int baudrate) switch (hdr->blockid) { case IBR_HDR_SATA_ID: - if (srcaddr < 1) - goto err; - - hdr->srcaddr = cpu_to_le32((srcaddr - 1) * 512); + hdr->srcaddr = cpu_to_le32(srcaddr * 512); break; case IBR_HDR_PEX_ID: