From 26412918741f18601dfe85fbdaca38c7a6779f48 Mon Sep 17 00:00:00 2001 From: Thomas Jarosch Date: Sun, 23 Aug 2020 01:21:35 +0200 Subject: [PATCH] stm32_mem: Fix python3 crash due to mix of tabs and spaces Fixes this issue: $ python3 ./stm32_mem.py blackmagic.bin File "./stm32_mem.py", line 199 if (os.path.getsize(args.progfile) > 0x1f800): ^ TabError: inconsistent use of tabs and spaces in indentation and allows to run with python2 too. --- scripts/stm32_mem.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scripts/stm32_mem.py b/scripts/stm32_mem.py index ae99402..c6feed9 100755 --- a/scripts/stm32_mem.py +++ b/scripts/stm32_mem.py @@ -18,6 +18,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +from __future__ import print_function from time import sleep import struct import os @@ -27,9 +28,9 @@ import argparse import usb import dfu -CMD_GETCOMMANDS = 0x00 -CMD_SETADDRESSPOINTER = 0x21 -CMD_ERASE = 0x41 +CMD_GETCOMMANDS = 0x00 +CMD_SETADDRESSPOINTER = 0x21 +CMD_ERASE = 0x41 def stm32_erase(dev, addr): erase_cmd = struct.pack(" 0x1f800): + if (os.path.getsize(args.progfile) > 0x1f800): print("File too large") exit(0) @@ -212,7 +213,7 @@ if __name__ == "__main__": start = 0x8002000 addr = start while bin: - print ("Programming memory at 0x%08X\r" % addr), + print ("Programming memory at 0x%08X" % addr, end="\r") stdout.flush() try: # STM DFU bootloader erases always. @@ -243,7 +244,7 @@ if __name__ == "__main__": except: # Abort silent if bootloader does not support upload break - print ("Verifying memory at 0x%08X\r" % addr), + print ("Verifying memory at 0x%08X" % addr, end="\r") stdout.flush() if len > 1024 : size = 1024