diff options
author | Pali Rohár <pali@kernel.org> | 2023-03-23 20:57:55 +0100 |
---|---|---|
committer | Stefan Roese <sr@denx.de> | 2023-03-24 13:13:52 +0100 |
commit | c2b9edacb8ce30f57f8f560d991dd69d6c0ab779 (patch) | |
tree | 21b0bec5b0de4c6139271c42eae87f3e97dbb747 /tools | |
parent | bb949e1da02b1744645e0c3a46fe9c2a67197fe8 (diff) | |
download | u-boot-c2b9edacb8ce30f57f8f560d991dd69d6c0ab779.zip u-boot-c2b9edacb8ce30f57f8f560d991dd69d6c0ab779.tar.gz u-boot-c2b9edacb8ce30f57f8f560d991dd69d6c0ab779.tar.bz2 |
tools: kwboot: Workaround A38x BootROM bug for images with a gap
A38x BootROM has a bug which cause that BootROM loads data part of UART
image into RAM target address increased by one byte when source address
and header size stored in the image header are not same.
Workaround this bug by completely removing a gap between header and data
part of the UART image. Without gap, this BootROM bug is not triggered.
This gap can be present in SDIO or SATA image types which have aligned
start of the data part to the media sector size. With this workaround
kwboot should be able to convert and send SDIO or SATA images for UART
booting.
Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/kwboot.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/kwboot.c b/tools/kwboot.c index dc69063..548b091 100644 --- a/tools/kwboot.c +++ b/tools/kwboot.c @@ -78,6 +78,17 @@ * * - IBR_HDR_UART_ID (0x69): * UART image can be transfered via xmodem protocol over first UART. + * Unlike all other image types, header size stored in the image must be + * multiply of the 128 bytes (for all other image types it can be any size) + * and data part of the image does not have to contain 32-bit checksum + * (all other image types must have valid 32-bit checksum in its data part). + * And data size stored in the image is ignored. A38x BootROM determinates + * size of the data part implicitly by the end of the xmodem transfer. + * A38x BootROM has a bug which cause that BootROM loads data part of UART + * image into RAM target address increased by one byte when source address + * and header size stored in the image header are not same. So UART image + * should be constructed in a way that there is no gap between header and + * data part. * * - IBR_HDR_I2C_ID (0x4D): * It is unknown for what kind of storage is used this image. It is not @@ -2185,6 +2196,18 @@ kwboot_img_patch(void *img, size_t *size, int baudrate) } } + /* Header size and source address must be same for UART type due to A38x BootROM bug */ + if (hdrsz != le32_to_cpu(hdr->srcaddr)) { + if (is_secure) { + fprintf(stderr, "Cannot align image with secure header\n"); + goto err; + } + + kwboot_printv("Removing gap between image header and data\n"); + memmove(img + hdrsz, img + le32_to_cpu(hdr->srcaddr), le32_to_cpu(hdr->blocksize)); + hdr->srcaddr = cpu_to_le32(hdrsz); + } + hdr->checksum = kwboot_hdr_csum8(hdr) - csum; *size = le32_to_cpu(hdr->srcaddr) + le32_to_cpu(hdr->blocksize); |