On Tue, Nov 14, 2023 at 02:33:58PM +0100, Marco Felsch wrote: > If the padding was required the follwing error may appear: > > | found i.MX8MP USB device [1fc9:0146] > | No dcd table in this ivt > | dl_command err=-1, last_trans=-1 > | 4 in err=-4, last_trans=0 00 00 00 00 > > The error is triggered since the target request only the required size > of bytes and move on as soon as all bytes are received while, on the other > hand, host tools like imx-usb-loader and uuu try to send the complete > file size. > > The alignment was introduced long time ago by commit 7cb4778e7f49 > ("imx-image: pad generated image to 4k") and may be required for HAB > boot on older SoCs like i.MX6/7. On these SoCs the CSF data is placed > behind the whole barebox image including the optional padding. On newer > SoCs like the i.MX8M* this isn't the case anymore. On these SoCs the CSF > is placed behind the barebox-pbl (aligned to 0x1000). So the final padding > isn't required anymore on these SoCs. > > Signed-off-by: Marco Felsch <m.felsch@xxxxxxxxxxxxxx> > --- > scripts/imx/imx-image.c | 19 ++++++++++++++----- > 1 file changed, 14 insertions(+), 5 deletions(-) Applied, thanks Sascha > > diff --git a/scripts/imx/imx-image.c b/scripts/imx/imx-image.c > index 1f96b383901f..a5639d696931 100644 > --- a/scripts/imx/imx-image.c > +++ b/scripts/imx/imx-image.c > @@ -1100,12 +1100,21 @@ int main(int argc, char *argv[]) > > xwrite(outfd, infile, insize); > > - /* pad until next 4k boundary */ > - now = 4096 - (insize % 4096); > - if (data.csf && now) { > - memset(buf, 0x5a, now); > + /* > + * The alignment may be required on ARMv7 SoCs like i.MX6/7 for HAB > + * boot. On newer SoCs like i.MX8MP/N this cause libusb communication > + * errors while uploading images because these machines request the > + * exact amount of required bytes and move on afterwards while the host > + * tool still try to send the whole (padded) file size. > + */ > + if (!cpu_is_mx8m(&data)) { > + /* pad until next 4k boundary */ > + now = 4096 - (insize % 4096); > + if (data.csf && now) { > + memset(buf, 0x5a, now); > > - xwrite(outfd, buf, now); > + xwrite(outfd, buf, now); > + } > } > > ret = close(outfd); > -- > 2.39.2 > > > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |