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. Rasmus