Message ID | 20211108171251.25382-7-kabel@kernel.org |
---|---|
State | Accepted |
Commit | 188099ed7ff4f606a2a74ac82350a78c26bdfe2c |
Delegated to: | Stefan Roese |
Headers | show |
Series | Another kwbimage series | expand |
On 08.11.21 18:12, Marek Behún wrote: > From: Pali Rohár <pali@kernel.org> > > xmodem block size is 128 bytes, therefore it is possible to transfer only > images with size multiple of 128 bytes. kwboot automatically pads image > with zero bytes at the end to align it to 128 bytes boundary. > > Do this padding when generating image to allow uploading with other xmodem > tools or older kwboot versions. > > Signed-off-by: Pali Rohár <pali@kernel.org> > Signed-off-by: Marek Behún <marek.behun@nic.cz> Minor comment below. Other than this: Reviewed-by: Stefan Roese <sr@denx.de> Thanks, Stefan > --- > tools/kwbimage.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/tools/kwbimage.c b/tools/kwbimage.c > index 864625d788..b939b4cb49 100644 > --- a/tools/kwbimage.c > +++ b/tools/kwbimage.c > @@ -1847,6 +1847,7 @@ static int kwbimage_generate(struct image_tool_params *params, > * The resulting image needs to be 4-byte aligned. At least > * the Marvell hdrparser tool complains if its unaligned. > * After the image data is stored 4-byte checksum. > + * Final UART image must be aligned to 128 bytes. > * Final SPI and NAND images must be aligned to 256 bytes. > * Final SATA and SDIO images must be aligned to 512 bytes. > */ > @@ -1854,6 +1855,8 @@ static int kwbimage_generate(struct image_tool_params *params, > return 4 + (256 - (alloc_len + s.st_size + 4) % 256) % 256; > else if (bootfrom == IBR_HDR_SATA_ID || bootfrom == IBR_HDR_SDIO_ID) > return 4 + (512 - (alloc_len + s.st_size + 4) % 512) % 512; > + else if (bootfrom == IBR_HDR_UART_ID) > + return 4 + (128 - (alloc_len + s.st_size + 4) % 128) % 128; > else > return 4 + (4 - s.st_size % 4) % 4; The lines above are pretty similar - perhaps some function / macro could be used to simplify these lines? Thanks, Stefan
diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 864625d788..b939b4cb49 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -1847,6 +1847,7 @@ static int kwbimage_generate(struct image_tool_params *params, * The resulting image needs to be 4-byte aligned. At least * the Marvell hdrparser tool complains if its unaligned. * After the image data is stored 4-byte checksum. + * Final UART image must be aligned to 128 bytes. * Final SPI and NAND images must be aligned to 256 bytes. * Final SATA and SDIO images must be aligned to 512 bytes. */ @@ -1854,6 +1855,8 @@ static int kwbimage_generate(struct image_tool_params *params, return 4 + (256 - (alloc_len + s.st_size + 4) % 256) % 256; else if (bootfrom == IBR_HDR_SATA_ID || bootfrom == IBR_HDR_SDIO_ID) return 4 + (512 - (alloc_len + s.st_size + 4) % 512) % 512; + else if (bootfrom == IBR_HDR_UART_ID) + return 4 + (128 - (alloc_len + s.st_size + 4) % 128) % 128; else return 4 + (4 - s.st_size % 4) % 4; }