[fix] fix flash_download when first byte is not 0x55 in shakehand
This commit is contained in:
parent
962b2e6e85
commit
d4f8b101bd
@ -67,8 +67,8 @@ class FlashDownloader:
|
||||
# time.sleep(0.5) # 等待500ms
|
||||
print("Pre-erase signals set")
|
||||
shakehand = self.ser.read(4)
|
||||
print("shakehand=", shakehand)
|
||||
return shakehand == b'\x55\x55\x55\x55'
|
||||
print("shakehand=", shakehand.hex(' ').upper())
|
||||
return len(shakehand) == 4 and shakehand[3] == 0x55
|
||||
|
||||
def control_signals_post_download(self):
|
||||
"""下载完成后的信号控制"""
|
||||
@ -76,7 +76,7 @@ class FlashDownloader:
|
||||
self.ser.rts = True # RTS拉低
|
||||
self.ser.dtr = True # DTR拉低
|
||||
time.sleep(0.1) # 等待100ms
|
||||
self.ser.rts = False # RTS拉高
|
||||
# self.ser.rts = False # RTS拉高
|
||||
print("Post-download signals set")
|
||||
|
||||
def calculate_checksum(self, data):
|
||||
@ -243,6 +243,9 @@ class FlashDownloader:
|
||||
print("shake hands failed")
|
||||
sys.exit(1)
|
||||
|
||||
# 清除 RX Buffer
|
||||
self.ser.reset_input_buffer()
|
||||
|
||||
# 擦除Flash (擦除足够的空间)
|
||||
erase_size = ((len(file_data) + 4095) // 4096) * 4096 # 假设擦除块大小为4KB
|
||||
if not self.erase_flash(self.address, erase_size):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user