Message ID | 20230111151540.1196468-1-michael.adler@siemens.com |
---|---|
State | Accepted |
Delegated to: | Stefano Babic |
Headers | show |
Series | [v2] flash_handler: fix flashing compressed/encrypted images | expand |
On 11.01.23 16:15, Michael Adler wrote: > An optimization introduced in 07d30be is incompatible with > compressed/encrypted images: img->size is *not* the size of the > decompressed/decrypted image, thus the memory region erased by SWUpdate > is too small. > > Signed-off-by: Michael Adler <michael.adler@siemens.com> > Signed-off-by: Christian Storm <christian.storm@siemens.com> > --- > handlers/flash_handler.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/handlers/flash_handler.c b/handlers/flash_handler.c > index 135eaee..4fa60e6 100644 > --- a/handlers/flash_handler.c > +++ b/handlers/flash_handler.c > @@ -308,9 +308,14 @@ static int flash_write_nor(int mtdnum, struct img_type *img) > return -ENODEV; > } > > - if(flash_erase_sector(mtdnum, img->seek, img->size)) { > - ERROR("I cannot erasing %s", > - img->device); > + long long size = get_output_size(img, true); > + if (size < 0) { > + ERROR("Failed to determine output size, bailing out."); > + return -1; > + } > + if (flash_erase_sector(mtdnum, img->seek, size)) { > + ERROR("Failed to erase sectors on /dev/mtd%d (start: %llu, size: %lld)", > + mtdnum, img->seek, size); > return -1; > } > Reviewed-by: Stefano Babic <sbabic@denx.de> Best regards, Stefano Babic
> An optimization introduced in 07d30be is incompatible with > compressed/encrypted images: img->size is *not* the size of the > decompressed/decrypted image, thus the memory region erased by SWUpdate > is too small. > Signed-off-by: Michael Adler <michael.adler@siemens.com> > Signed-off-by: Christian Storm <christian.storm@siemens.com> > Reviewed-by: Stefano Babic <sbabic@denx.de> Applied to swupdate, master, thanks ! Best regards, Stefano Babic
diff --git a/handlers/flash_handler.c b/handlers/flash_handler.c index 135eaee..4fa60e6 100644 --- a/handlers/flash_handler.c +++ b/handlers/flash_handler.c @@ -308,9 +308,14 @@ static int flash_write_nor(int mtdnum, struct img_type *img) return -ENODEV; } - if(flash_erase_sector(mtdnum, img->seek, img->size)) { - ERROR("I cannot erasing %s", - img->device); + long long size = get_output_size(img, true); + if (size < 0) { + ERROR("Failed to determine output size, bailing out."); + return -1; + } + if (flash_erase_sector(mtdnum, img->seek, size)) { + ERROR("Failed to erase sectors on /dev/mtd%d (start: %llu, size: %lld)", + mtdnum, img->seek, size); return -1; }