[PATCH u-boot-marvell 25/29] tools: kwboot: Support higher baudrates when booting via UART

Marek Behún marek.behun at nic.cz
Wed Aug 25 18:49:05 CEST 2021


On Wed, 25 Aug 2021 15:46:30 +0200
Marek Behún <marek.behun at nic.cz> wrote:

> @@ -765,6 +1187,37 @@ kwboot_img_is_secure(void *img)
>  	return 0;
>  }
>  
> +static void *
> +kwboot_img_grow_data_left(void *img, size_t *size, size_t grow)
> +{
> +	uint32_t hdrsz, datasz, srcaddr;
> +	struct main_hdr_v1 *hdr = img;
> +	uint8_t *data;
> +
> +	srcaddr = le32_to_cpu(hdr->srcaddr);
> +
> +	hdrsz = kwbheader_size(hdr);
> +	data = (uint8_t *)img + srcaddr;
> +	datasz = *size - srcaddr;
> +
> +	/* only move data if there is not enough space */
> +	if (hdrsz + grow > srcaddr) {
> +		size_t need = hdrsz + grow - srcaddr;
> +
> +		/* move data by enough bytes */
> +		memmove(data + need, data, datasz);
> +		*size += need;
> +		srcaddr += need;
> +	}
> +
> +	srcaddr -= grow;
> +	hdr->srcaddr = cpu_to_le32(srcaddr);
> +	hdr->destaddr = cpu_to_le32(le32_to_cpu(hdr->destaddr) - grow);
> +	hdr->execaddr = cpu_to_le32(le32_to_cpu(hdr->execaddr) - grow);

Sorry, we need to do one more thing here:
    hdr->blocksize = cpu_to_le32(le32_to_cpu(hdr->blocksize) + grow);

I will fix this in v2, unless Stefan is willing to fix this himself.

Marek


More information about the U-Boot mailing list