Skip to content

Commit 309ab3d

Browse files
committed
read_flash: Error immediately if an invalid length frame is received
Fix for dropped bytes on high baud rate reading of data (signal integrity issue, probably). See #342
1 parent 96e277d commit 309ab3d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

esptool.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,8 @@ def read_flash(self, offset, length, progress_fn=None):
683683
while len(data) < length:
684684
p = self.read()
685685
data += p
686+
if len(data) < length and len(p) < self.FLASH_SECTOR_SIZE:
687+
raise FatalError('Corrupt data, expected 0x%x bytes but received 0x%x bytes' % (self.FLASH_SECTOR_SIZE, len(p)))
686688
self.write(struct.pack('<I', len(data)))
687689
if progress_fn and (len(data) % 1024 == 0 or len(data) == length):
688690
progress_fn(len(data), length)

0 commit comments

Comments
 (0)