On most SoCs the IVT header is not at the beginning of the image but at offset 0x400. As we skip the leading 0x400 bytes while uploading we can substract that offset from the image size we upload. This shouldn't make a difference now, but in future we might change the two-staged upload process: Now we upload the PBL once and afterwards the full image incuding the same PBL again. It would be more elegant to upload the PBL only once and only the rest of the image afterwards. If we do so, it it important to exactly upload the first stage so that barebox on the other end receives exactly the second stage at the offset it expects it to be. Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx> --- scripts/imx/imx-usb-loader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/imx/imx-usb-loader.c b/scripts/imx/imx-usb-loader.c index b2c835225c..f4f13d5cc7 100644 --- a/scripts/imx/imx-usb-loader.c +++ b/scripts/imx/imx-usb-loader.c @@ -1271,7 +1271,7 @@ static int get_dl_start(const unsigned char *p, const unsigned char *file_start, bd = (void *)_bd; - *firststage_len = bd->size; + *firststage_len = bd->size - (hdr->self - bd->start); *plugin = bd->plugin; bd->plugin = 0; -- 2.30.2