Skip to content

Commit

Permalink
snagflash: interactive: correct file offset computations in flash_mmc()
Browse files Browse the repository at this point in the history
The offsets for huge file chunks are incorrectly calculated in flash_mmc(),
resulting in incorrect data being written to the backend device.

Correct these file offset computations.

Signed-off-by: Romain Gantois <[email protected]>
  • Loading branch information
rgantois committed Dec 19, 2024
1 parent d48222c commit 097bf60
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/snagflash/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,14 @@ def flash_mmc(self, path: str, offset: int, device_num: int, file_size: int, fil
for i in range(nchunks):
logger.info(f"flashing section {i + 1}/{nchunks}")
target_offset = part_start + offset_lba + i * fb_size_lba
fast.download_section(path, file_offset + i * fb_size_lba, fb_size_aligned)
fast.download_section(path, file_offset + i * fb_size_aligned, fb_size_aligned)

fast.oem_run(f"mmc write 0x{fb_addr:x} 0x{target_offset:x} 0x{fb_size_lba:x}")

if remainder > 0:
logger.info("flashing remainder")
target_offset = part_start + offset_lba + nchunks * fb_size_lba
fast.download_section(path, file_offset + nchunks * fb_size_lba, remainder)
fast.download_section(path, file_offset + nchunks * fb_size_aligned, remainder)

fast.oem_run(f"mmc write 0x{fb_addr:x} 0x{target_offset:x} 0x{remainder_lba:x}")

Expand Down

0 comments on commit 097bf60

Please sign in to comment.