本文整理汇总了Python中pyOCD.board.MbedBoard.listConnectedBoards方法的典型用法代码示例。如果您正苦于以下问题:Python MbedBoard.listConnectedBoards方法的具体用法?Python MbedBoard.listConnectedBoards怎么用?Python MbedBoard.listConnectedBoards使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyOCD.board.MbedBoard
的用法示例。
在下文中一共展示了MbedBoard.listConnectedBoards方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from pyOCD.board import MbedBoard [as 别名]
# 或者: from pyOCD.board.MbedBoard import listConnectedBoards [as 别名]
def main():
args = parser.parse_args()
setup_logging(args)
# Sanity checks before attaching to board
if args.format == 'hex' and not intelhex_available:
print("Unable to program hex file")
print("Module 'intelhex' must be installed first")
exit()
if args.list_all:
MbedBoard.listConnectedBoards()
else:
board_selected = MbedBoard.chooseBoard(board_id=args.board_id, target_override=args.target_override,
frequency=args.frequency)
with board_selected as board:
flash = board.flash
transport = board.transport
# Boost speed with deferred transfers
transport.setDeferredTransfer(True)
progress = print_progress
if args.hide_progress:
progress = None
chip_erase = None
if args.chip_erase:
chip_erase = True
elif args.sector_erase:
chip_erase = False
# Binary file format
if args.format == 'bin':
# If no address is specified use the start of rom
if args.address is None:
args.address = board.flash.getFlashInfo().rom_start
with open(args.file, "rb") as f:
f.seek(args.skip, 0)
data = f.read()
args.address += args.skip
data = unpack(str(len(data)) + 'B', data)
flash.flashBlock(args.address, data, chip_erase=chip_erase, progress_cb=progress,
fast_verify=args.fast_program)
# Intel hex file format
if args.format == 'hex':
hex = IntelHex(args.file)
addresses = hex.addresses()
addresses.sort()
flash_builder = flash.getFlashBuilder()
data_list = list(ranges(addresses))
for start, end in data_list:
size = end - start + 1
data = list(hex.tobinarray(start=start, size=size))
flash_builder.addData(start, data)
flash_builder.program(chip_erase=chip_erase, progress_cb=progress, fast_verify=args.fast_program)
示例2: main
# 需要导入模块: from pyOCD.board import MbedBoard [as 别名]
# 或者: from pyOCD.board.MbedBoard import listConnectedBoards [as 别名]
def main():
args = parser.parse_args()
gdb_server_settings = get_gdb_server_settings(args)
setup_logging(args)
gdb = None
if args.list_all == True:
MbedBoard.listConnectedBoards()
else:
try:
board_selected = MbedBoard.chooseBoard(
board_id=args.board_id,
target_override=args.target_override,
frequency=args.frequency)
with board_selected as board:
# Boost speed with deferred transfers
board.transport.setDeferredTransfer(True)
gdb = GDBServer(board, args.port_number, gdb_server_settings)
while gdb.isAlive():
gdb.join(timeout=0.5)
except KeyboardInterrupt:
if gdb != None:
gdb.stop()
except Exception as e:
print "uncaught exception: %s" % e
traceback.print_exc()
if gdb != None:
gdb.stop()
示例3: run
# 需要导入模块: from pyOCD.board import MbedBoard [as 别名]
# 或者: from pyOCD.board.MbedBoard import listConnectedBoards [as 别名]
def run(self):
self.args = self.build_parser().parse_args()
self.gdb_server_settings = self.get_gdb_server_settings(self.args)
self.setup_logging(self.args)
self.process_commands(self.args.commands)
gdb = None
if self.args.list_all == True:
MbedBoard.listConnectedBoards()
else:
try:
board_selected = MbedBoard.chooseBoard(
board_id=self.args.board_id,
target_override=self.args.target_override,
frequency=self.args.frequency)
with board_selected as board:
# Boost speed with deferred transfers
board.transport.setDeferredTransfer(True)
gdb = GDBServer(board, self.args.port_number, self.gdb_server_settings)
while gdb.isAlive():
gdb.join(timeout=0.5)
except KeyboardInterrupt:
if gdb != None:
gdb.stop()
except Exception as e:
print "uncaught exception: %s" % e
traceback.print_exc()
if gdb != None:
gdb.stop()
return 1
# Successful exit.
return 0
示例4: main
# 需要导入模块: from pyOCD.board import MbedBoard [as 别名]
# 或者: from pyOCD.board.MbedBoard import listConnectedBoards [as 别名]
def main():
args = parser.parse_args()
setup_logging(args)
# Sanity checks before attaching to board
if args.format == 'hex' and not intelhex_available:
print("Unable to program hex file")
print("Module 'intelhex' must be installed first")
exit()
if args.list_all:
MbedBoard.listConnectedBoards()
else:
board_selected = MbedBoard.chooseBoard(board_id=args.board_id, target_override=args.target_override,
frequency=args.frequency)
with board_selected as board:
flash = board.flash
transport = board.transport
# Boost speed with deferred transfers
transport.setDeferredTransfer(True)
progress = print_progress
if args.hide_progress:
progress = None
has_file = args.file is not None
chip_erase = None
if args.chip_erase:
chip_erase = True
elif args.sector_erase:
chip_erase = False
if not has_file:
if chip_erase:
print("Erasing chip...")
flash.init()
flash.eraseAll()
print("Done")
elif args.sector_erase and args.address is not None:
flash.init()
page_addr = args.address
for i in range(args.count):
page_info = flash.getPageInfo(page_addr)
if not page_info:
break
# Align page address on first time through.
if i == 0:
delta = page_addr % page_info.size
if delta:
print("Warning: sector address 0x%08x is unaligned" % page_addr)
page_addr -= delta
print("Erasing sector 0x%08x" % page_addr)
flash.erasePage(page_addr)
page_addr += page_info.size
else:
print("No operation performed")
return
# If no format provided, use the file's extension.
if not args.format:
args.format = os.path.splitext(args.file)[1][1:]
# Binary file format
if args.format == 'bin':
# If no address is specified use the start of rom
if args.address is None:
args.address = board.flash.getFlashInfo().rom_start
with open(args.file, "rb") as f:
f.seek(args.skip, 0)
data = f.read()
args.address += args.skip
data = unpack(str(len(data)) + 'B', data)
flash.flashBlock(args.address, data, chip_erase=chip_erase, progress_cb=progress,
fast_verify=args.fast_program)
# Intel hex file format
elif args.format == 'hex':
hex = IntelHex(args.file)
addresses = hex.addresses()
addresses.sort()
flash_builder = flash.getFlashBuilder()
data_list = list(ranges(addresses))
for start, end in data_list:
size = end - start + 1
data = list(hex.tobinarray(start=start, size=size))
flash_builder.addData(start, data)
flash_builder.program(chip_erase=chip_erase, progress_cb=progress, fast_verify=args.fast_program)
else:
print("Unknown file format '%s'" % args.format)
示例5: run
# 需要导入模块: from pyOCD.board import MbedBoard [as 别名]
# 或者: from pyOCD.board.MbedBoard import listConnectedBoards [as 别名]
def run(self):
board = None
exitCode = 0
try:
# Read command-line arguments.
args = self.get_args()
if args.verbose:
logging.basicConfig(level=logging.INFO)
# Print a list of all connected boards.
if args.action == ACTION_LIST:
MbedBoard.listConnectedBoards()
sys.exit(0)
board = MbedBoard.chooseBoard(board_id=args.board, target_override=args.target, init_board=False)
board.target.setAutoUnlock(False)
try:
board.init()
except Exception, e:
print "Exception:", e
target = board.target
transport = board.transport
flash = board.flash
# Set specified SWD clock.
if args.clock > 0:
print "Setting SWD clock to %d kHz" % args.clock
transport.setClock(args.clock * 1000)
# Handle reset action first
if args.action == ACTION_RESET:
print "Resetting target"
target.reset()
sys.exit(0)
# Handle a device with flash security enabled.
didErase = False
if target.isLocked() and args.action != ACTION_UNLOCK:
print "Target is locked, cannot complete operation. Use --unlock to mass erase and unlock."
# Handle actions.
if args.action == ACTION_INFO:
print "Unique ID: %s" % board.getUniqueID()
print "Core ID: 0x%08x" % target.readIDCode()
if isinstance(target, pyOCD.target.target_kinetis.Kinetis):
print "MDM-AP Control: 0x%08x" % transport.readAP(target_kinetis.MDM_CTRL)
print "MDM-AP Status: 0x%08x" % transport.readAP(target_kinetis.MDM_STATUS)
status = target.getState()
if status == pyOCD.target.cortex_m.TARGET_HALTED:
print "Core status: Halted"
self.dumpRegisters(target)
elif status == pyOCD.target.cortex_m.TARGET_RUNNING:
print "Core status: Running"
elif args.action == ACTION_READ:
if args.width == 8:
data = target.readBlockMemoryUnaligned8(args.read, args.len)
elif args.width == 16:
if args.read & 0x1:
raise ToolError("read address 0x%08x is not 16-bit aligned" % args.read)
byteData = target.readBlockMemoryUnaligned8(args.read, args.len * 2)
i = 0
data = []
while i < len(byteData):
data.append(byteData[i] | (byteData[i + 1] << 8))
i += 2
elif args.width == 32:
if args.read & 0x3:
raise ToolError("read address 0x%08x is not 32-bit aligned" % args.read)
data = target.readBlockMemoryAligned32(args.read, args.len / 4)
# Either print disasm or hex dump of output
if args.disasm:
if args.width == 8:
code = bytearray(data)
elif args.width == 16:
code = bytearray(byteData)
elif args.width == 32:
byteData = []
for v in data:
byteData.extend([(v >> 24) & 0xff, (v >> 16) & 0xff, (v >> 8) & 0xff, v & 0xff])
code = bytearray(byteData)
self.disasm(str(code), args.read)
else:
dumpHexData(data, args.read, width=args.width)
elif args.action == ACTION_WRITE:
if args.width == 8:
target.writeBlockMemoryUnaligned8(args.write, args.data)
elif args.width == 16:
if args.write & 0x1:
raise ToolError("write address 0x%08x is not 16-bit aligned" % args.write)
print "16-bit writes are currently not supported"
elif args.width == 32:
if args.write & 0x3:
#.........这里部分代码省略.........
示例6: N
# 需要导入模块: from pyOCD.board import MbedBoard [as 别名]
# 或者: from pyOCD.board.MbedBoard import listConnectedBoards [as 别名]
parser.add_option("-c", "--cmd-port", dest = "cmd_port", default = 4444, help = "Command port number. pyOCD doesn't open command port but it's required to be compatible with OpenOCD and Eclipse.")
parser.add_option("-b", "--board", dest = "board_id", default = None, help = "Write the board id you want to connect")
parser.add_option("-l", "--list", action = "store_true", dest = "list_all", default = False, help = "List all the connected board")
parser.add_option("-d", "--debug", dest = "debug_level", default = 'info', help = "Set the level of system logging output, the available value for DEBUG_LEVEL: debug, info, warning, error, critical" )
parser.add_option("-t", "--target", dest = "target_override", default = None, help = "Override target to debug" )
parser.add_option("-n", "--nobreak", dest = "break_at_hardfault", default = True, action="store_false", help = "Disable breakpoint at hardfault handler. Required for nrf51 chip with SoftDevice based application." )
parser.add_option("-s", "--skip", dest = "skip_bytes", default = False, help = "Skip N (hexidecimal) first bytes of flash (for example SoftDevice on nrf51 chip). " )
(option, args) = parser.parse_args()
if (option.skip_bytes):
option.skip_bytes = int(option.skip_bytes, 16)
gdb = None
level = LEVELS.get(option.debug_level, logging.NOTSET)
logging.basicConfig(level=level)
if option.list_all == True:
MbedBoard.listConnectedBoards()
else:
try:
board_selected = MbedBoard.chooseBoard(board_id = option.board_id, target_override = option.target_override)
if board_selected != None:
try:
gdb = GDBServer(board_selected, int(option.port_number), {'skip_bytes' : option.skip_bytes, 'break_at_hardfault' : option.break_at_hardfault})
while gdb.isAlive():
gdb.join(timeout = 0.5)
except ValueError:
logging.error("Port number error!")
except KeyboardInterrupt:
if gdb != None:
gdb.stop()
except Exception as e:
print "uncaught exception: %s" % e
示例7: handle_list
# 需要导入模块: from pyOCD.board import MbedBoard [as 别名]
# 或者: from pyOCD.board.MbedBoard import listConnectedBoards [as 别名]
def handle_list(self, args):
MbedBoard.listConnectedBoards()
示例8: ids
# 需要导入模块: from pyOCD.board import MbedBoard [as 别名]
# 或者: from pyOCD.board.MbedBoard import listConnectedBoards [as 别名]
def ids(self, args):
MbedBoard.listConnectedBoards()
示例9: offset
# 需要导入模块: from pyOCD.board import MbedBoard [as 别名]
# 或者: from pyOCD.board.MbedBoard import listConnectedBoards [as 别名]
parser.add_argument("-e", "--erase", action="count", help="erase flash before write")
parser.add_argument("-b", "--bin", help="a binary file")
parser.add_argument("-o", "--offset", help="with -b option, a binary will be flashed with an offset (default: 0x16000)")
parser.add_argument("-s", "--skip", help="with -b option skip first N bytes")
parser.add_argument("-id", "--board_id", help="connect to board by board id, use -l to list all connected boards")
parser.add_argument("-l", "--list", action="count", help="list all connected boards")
args = parser.parse_args()
if args.verbose == 2:
logging.basicConfig(level=logging.DEBUG)
elif args.verbose == 1:
logging.basicConfig(level=logging.INFO)
if (args.list):
print MbedBoard.listConnectedBoards()
sys.exit(0)
adapter = None
try:
adapter = None
if (args.board_id):
adapter = MbedBoard.chooseBoard(board_id = args.board_id)
else:
interfaces = INTERFACE[usb_backend].getAllConnectedInterface(VID, PID)
if interfaces == None:
print "Not find a mbed interface"
sys.exit(1)
# Use the first one
first_interface = interfaces[0]