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.
This commit is contained in:
Thomas Jarosch 2020-08-23 01:21:35 +02:00 committed by UweBonnes
parent b51c9367fc
commit 2641291874
1 changed files with 7 additions and 6 deletions

View File

@ -18,6 +18,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from time import sleep from time import sleep
import struct import struct
import os import os
@ -27,9 +28,9 @@ import argparse
import usb import usb
import dfu import dfu
CMD_GETCOMMANDS = 0x00 CMD_GETCOMMANDS = 0x00
CMD_SETADDRESSPOINTER = 0x21 CMD_SETADDRESSPOINTER = 0x21
CMD_ERASE = 0x41 CMD_ERASE = 0x41
def stm32_erase(dev, addr): def stm32_erase(dev, addr):
erase_cmd = struct.pack("<BL", CMD_ERASE, addr) erase_cmd = struct.pack("<BL", CMD_ERASE, addr)
@ -196,7 +197,7 @@ if __name__ == "__main__":
exit(0) exit(0)
dfudev.make_idle() dfudev.make_idle()
file = open(args.progfile, "rb") file = open(args.progfile, "rb")
if (os.path.getsize(args.progfile) > 0x1f800): if (os.path.getsize(args.progfile) > 0x1f800):
print("File too large") print("File too large")
exit(0) exit(0)
@ -212,7 +213,7 @@ if __name__ == "__main__":
start = 0x8002000 start = 0x8002000
addr = start addr = start
while bin: while bin:
print ("Programming memory at 0x%08X\r" % addr), print ("Programming memory at 0x%08X" % addr, end="\r")
stdout.flush() stdout.flush()
try: try:
# STM DFU bootloader erases always. # STM DFU bootloader erases always.
@ -243,7 +244,7 @@ if __name__ == "__main__":
except: except:
# Abort silent if bootloader does not support upload # Abort silent if bootloader does not support upload
break break
print ("Verifying memory at 0x%08X\r" % addr), print ("Verifying memory at 0x%08X" % addr, end="\r")
stdout.flush() stdout.flush()
if len > 1024 : if len > 1024 :
size = 1024 size = 1024