Hi Rasmus On Wed, 2023-10-25 at 20:35 +0200, Rasmus Villemoes wrote: > On 25/10/2023 18.01, Marcel Ziswiler wrote: > > Hi Rasmus > > > > On Tue, 2023-10-24 at 16:32 +0200, Rasmus Villemoes wrote: > > > > What am I missing? > > > > Good question. Some more debugging revealed that we are missing 464 bytes > > at the beginning of the buffer. > > Why > > would that be? > > [slaps forehead] > > bytes = end - ss->end; > bytes += ss->pagesize - 1; > bytes /= ss->pagesize; > bytes *= ss->pagesize; > > ret = rom_api_download_image(ss->end, 0, bytes); > ... > ss->end = end; > > So I figure out how many bytes must at least be fetched to honor the > current read, round that up to the ss->pagesize [which is a no-op in the > usb download case because that has ->pagesize==1, so I even considered > leaving that rounding-up out], fetch that many bytes, but then record > the original upper bound as the new end of the valid data. That can > certainly account for losing something 0 < foo < pagesize number of bytes. > > So let's try if changing that last line to > > ss->end += bytes; > > works better.
Yes, that cuts it. Please find the fix here [1]. > Rasmus Thanks again for all your help! [1] https://lore.kernel.org/all/20231026073220.244387-1-mar...@ziswiler.com Cheers Marcel