scripts: more conversion to Python 3, change the shebang line
This commit is contained in:
parent
d9cce4d5e8
commit
eafc634eba
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# dfu.py: Access USB DFU class devices
|
# dfu.py: Access USB DFU class devices
|
||||||
# Copyright (C) 2009 Black Sphere Technologies
|
# Copyright (C) 2009 Black Sphere Technologies
|
||||||
|
@ -62,7 +62,7 @@ DFU_STATUS_ERROR_POR = 0x0d
|
||||||
DFU_STATUS_ERROR_UNKNOWN = 0x0e
|
DFU_STATUS_ERROR_UNKNOWN = 0x0e
|
||||||
DFU_STATUS_ERROR_STALLEDPKT = 0x0f
|
DFU_STATUS_ERROR_STALLEDPKT = 0x0f
|
||||||
|
|
||||||
class dfu_status(object):
|
class dfu_status:
|
||||||
def __init__(self, buf):
|
def __init__(self, buf):
|
||||||
self.bStatus = buf[0]
|
self.bStatus = buf[0]
|
||||||
self.bwPollTimeout = buf[1] + (buf[2]<<8) + (buf[3]<<16)
|
self.bwPollTimeout = buf[1] + (buf[2]<<8) + (buf[3]<<16)
|
||||||
|
@ -70,7 +70,7 @@ class dfu_status(object):
|
||||||
self.iString = buf[5]
|
self.iString = buf[5]
|
||||||
|
|
||||||
|
|
||||||
class dfu_device(object):
|
class dfu_device:
|
||||||
def __init__(self, dev, conf, iface):
|
def __init__(self, dev, conf, iface):
|
||||||
self.dev = dev
|
self.dev = dev
|
||||||
self.conf = conf
|
self.conf = conf
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# gdb.py: Python module for low level GDB protocol implementation
|
# gdb.py: Python module for low level GDB protocol implementation
|
||||||
# Copyright (C) 2009 Black Sphere Technologies
|
# Copyright (C) 2009 Black Sphere Technologies
|
||||||
|
@ -152,7 +152,7 @@ class Target:
|
||||||
"""Read length bytes from target at address addr"""
|
"""Read length bytes from target at address addr"""
|
||||||
ret = b''
|
ret = b''
|
||||||
while length:
|
while length:
|
||||||
# print "Read"
|
# print("Read")
|
||||||
packlen = min(length,self.PacketSize//2)
|
packlen = min(length,self.PacketSize//2)
|
||||||
self.putpacket(b"m%08X,%08X" % (addr, packlen))
|
self.putpacket(b"m%08X,%08X" % (addr, packlen))
|
||||||
reply = self.getpacket()
|
reply = self.getpacket()
|
||||||
|
@ -292,7 +292,7 @@ class Target:
|
||||||
addr = self.offset + self.blocksize * i
|
addr = self.offset + self.blocksize * i
|
||||||
if data is None:
|
if data is None:
|
||||||
continue
|
continue
|
||||||
#print "Erasing flash at 0x%X" % (self.offset + self.blocksize*i)
|
#print("Erasing flash at 0x%X" % (self.offset + self.blocksize*i))
|
||||||
self.target.putpacket(b"vFlashErase:%08X,%08X" %
|
self.target.putpacket(b"vFlashErase:%08X,%08X" %
|
||||||
(self.offset + self.blocksize*i, self.blocksize))
|
(self.offset + self.blocksize*i, self.blocksize))
|
||||||
if self.target.getpacket() != b'OK':
|
if self.target.getpacket() != b'OK':
|
||||||
|
@ -301,7 +301,7 @@ class Target:
|
||||||
while data:
|
while data:
|
||||||
d = data[0:980]
|
d = data[0:980]
|
||||||
data = data[len(d):]
|
data = data[len(d):]
|
||||||
#print "Writing %d bytes at 0x%X" % (len(d), addr)
|
#print("Writing %d bytes at 0x%X" % (len(d), addr))
|
||||||
self.target.putpacket(b"vFlashWrite:%08X:%s" % (addr, d))
|
self.target.putpacket(b"vFlashWrite:%08X:%s" % (addr, d))
|
||||||
addr += len(d)
|
addr += len(d)
|
||||||
if self.target.getpacket() != b'OK':
|
if self.target.getpacket() != b'OK':
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
"""Pulls nRF51 IDs from openocd's nrf51.c in a form suitable for
|
"""Pulls nRF51 IDs from openocd's nrf51.c in a form suitable for
|
||||||
pasting into blackmagic's nrf51.c
|
pasting into blackmagic's nrf51.c
|
||||||
|
@ -21,11 +21,11 @@ specdict = {}
|
||||||
specs = []
|
specs = []
|
||||||
spec = Spec()
|
spec = Spec()
|
||||||
for line in io.TextIOWrapper(proc.stdout, encoding="utf-8"):
|
for line in io.TextIOWrapper(proc.stdout, encoding="utf-8"):
|
||||||
m = re.search('/\*(.*)\*/',line)
|
m = re.search(r'/\*(.*)\*/',line)
|
||||||
if m:
|
if m:
|
||||||
lastcomment=m.group(1)
|
lastcomment=m.group(1)
|
||||||
|
|
||||||
m = re.search('NRF51_DEVICE_DEF\((0x[0-9A-F]*),\s*"(.*)",\s*"(.*)",\s*"(.*)",\s*([0-9]*)\s*\),', line)
|
m = re.search(r'NRF51_DEVICE_DEF\((0x[0-9A-F]*),\s*"(.*)",\s*"(.*)",\s*"(.*)",\s*([0-9]*)\s*\),', line)
|
||||||
if m:
|
if m:
|
||||||
spec.hwid = int(m.group(1), base=0)
|
spec.hwid = int(m.group(1), base=0)
|
||||||
spec.variant = m.group(3)
|
spec.variant = m.group(3)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
# hexprog.py: Python application to flash a target with an Intel hex file
|
# hexprog.py: Python application to flash a target with an Intel hex file
|
||||||
# Copyright (C) 2011 Black Sphere Technologies
|
# Copyright (C) 2011 Black Sphere Technologies
|
||||||
|
@ -65,8 +65,8 @@ if __name__ == "__main__":
|
||||||
from sys import argv, platform, stdout
|
from sys import argv, platform, stdout
|
||||||
from getopt import getopt
|
from getopt import getopt
|
||||||
|
|
||||||
if platform == "linux2":
|
if platform == "linux":
|
||||||
print ("\x1b\x5b\x48\x1b\x5b\x32\x4a") # clear terminal screen
|
print("\x1b\x5b\x48\x1b\x5b\x32\x4a") # clear terminal screen
|
||||||
print("Black Magic Probe -- Target Production Programming Tool -- version 1.0")
|
print("Black Magic Probe -- Target Production Programming Tool -- version 1.0")
|
||||||
print("Copyright (C) 2011 Black Sphere Technologies")
|
print("Copyright (C) 2011 Black Sphere Technologies")
|
||||||
print("License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>")
|
print("License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>")
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# stm32_mem.py: STM32 memory access using USB DFU class
|
# stm32_mem.py: STM32 memory access using USB DFU class
|
||||||
# Copyright (C) 2011 Black Sphere Technologies
|
# Copyright (C) 2011 Black Sphere Technologies
|
||||||
|
|
Loading…
Reference in New Issue