Skip to content

Commit

Permalink
firmware flashing fix
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Brzyk <jan.brzyk@husarion.com>
  • Loading branch information
JanBrzyk committed Nov 23, 2023
1 parent f5744f8 commit 5ac9bfc
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions flash-firmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,24 @@ def flash_firmware(self):
try:
sh.stm32flash(self.port, "-u", _out=sys.stdout)
time.sleep(0.2)
break
except Exception:
print("Write-UnProtection error! Trying again.")
pass
else:
print("WARNING! Disabling the flash write-protection went wrong.")
print("WARNING! Disabling the flash Write-Protection went wrong.")

# Disable the flash read-protection
for i in range(self.max_approach_no):
try:
sh.stm32flash(self.port, "-k", _out=sys.stdout)
time.sleep(0.2)
break
except Exception:
print("Read-UnProtection error! Trying again.")
pass
else:
print("WARNING! Disabling the flash read-protection went wrong.")
print("WARNING! Disabling the flash Read-Protection went wrong.")

# Flashing the firmware
for i in range(self.max_approach_no):
Expand All @@ -87,6 +91,7 @@ def flash_firmware(self):
time.sleep(0.2)
break
except Exception:
print("Flashing error! Trying again.")
pass
else:
print("ERROR! Flashing the firmware went wrong. Try again.")
Expand All @@ -111,7 +116,7 @@ def main():

flasher = FirmwareFlasher(sys_arch, binary_file)
flasher.flash_firmware()
print("Done.")
print("Done!")


if __name__ == "__main__":
Expand Down

0 comments on commit 5ac9bfc

Please sign in to comment.