• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python board.MbedBoard类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyOCD.board.MbedBoard的典型用法代码示例。如果您正苦于以下问题:Python MbedBoard类的具体用法?Python MbedBoard怎么用?Python MbedBoard使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了MbedBoard类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: main

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()
开发者ID:arunpersaud,项目名称:pyOCD,代码行数:28,代码来源:gdb_server.py


示例2: run

    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
开发者ID:ARMmbed,项目名称:yotta_osx_installer,代码行数:34,代码来源:gdb_server.py


示例3: main

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)
开发者ID:geky,项目名称:pyOCD,代码行数:60,代码来源:flash_tool.py


示例4: getAdapter

def getAdapter():
    '''
    Get a CMSIS DAP debug adapter
    '''
    interfaces = INTERFACE[usb_backend].getAllConnectedInterface(VID, PID)
    if interfaces == None:
        print "Not find a mbed interface"
        sys.exit(1)

    first_interface = interfaces[0]
    adapter = MbedBoard("target_lpc1768", "flash_lpc1768", first_interface)
    adapter.init()
    return adapter
开发者ID:DonMorr,项目名称:pyOCD,代码行数:13,代码来源:flash_nrf51822.py


示例5: _launchPyOCDGDBServer

def _launchPyOCDGDBServer(msg_queue):
    logger.info('starting PyOCD gdbserver...')
    # ignore Ctrl-C, so we don't interrupt the GDB server when the
    # being-debugged program is being stopped:
    signal.signal(signal.SIGINT, _ignoreSignal);
    from pyOCD.gdbserver import GDBServer
    from pyOCD.board import MbedBoard
    gdb = None
    try:
        board_selected = MbedBoard.chooseBoard()
        with board_selected as board:
            gdb = GDBServer(
                board, 3333, {
                     'break_at_hardfault': True,
                    'step_into_interrupt': False,
                         'break_on_reset': False,
                }
            )
            if gdb.isAlive():
                msg_queue.put('alive')
                while gdb.isAlive():
                    gdb.join(timeout = 0.5)
                    # check for a "kill" message from the parent process:
                    try:
                        msg = msg_queue.get(False)
                        if msg == 'kill':
                            gdb.stop()
                            break
                    except Queue.Empty:
                        pass
    except Exception as e:
        if gdb != None:
            gdb.stop()
        raise
    msg_queue.put('dead')
开发者ID:ARMmbed,项目名称:yotta_osx_installer,代码行数:35,代码来源:gdb.py


示例6: search_and_lock

def search_and_lock(board_id):
    """Repeatedly lock a board with the given ID"""
    for _ in range(0, 20):
        device = DAPAccess.get_device(board_id)
        device.open()
        device.close()
        with MbedBoard.chooseBoard(board_id=board_id):
            pass
开发者ID:0xc0170,项目名称:pyOCD,代码行数:8,代码来源:parallel_test.py


示例7: list_boards

    def list_boards(self):
        self.disable_logging()

        try:
            all_mbeds = MbedBoard.getAllConnectedBoards(close=True, blocking=False)
            status = 0
            error = ""
        except Exception as e:
            all_mbeds = []
            status = 1
            error = str(e)
            if not self.args.output_json:
                raise

        if self.args.output_json:
            boards = []
            obj = {
                'pyocd_version' : __version__,
                'version' : { 'major' : 1, 'minor' : 0 },
                'status' : status,
                'boards' : boards,
                }

            if status != 0:
                obj['error'] = error

            for mbed in all_mbeds:
                d = {
                    'unique_id' : mbed.unique_id,
                    'info' : mbed.getInfo(),
                    'board_name' : mbed.getBoardName(),
                    'target' : mbed.getTargetType(),
                    'vendor_name' : '',
                    'product_name' : '',
                    }

                # Reopen the link so we can access the USB vendor and product names from the inteface.
                # If it's not a USB based link, then we don't attempt this.
                if isinstance(mbed.link, DAPAccessUSB):
                    try:
                        mbed.link.open()
                        d['vendor_name'] = mbed.link._interface.vendor_name
                        d['product_name'] = mbed.link._interface.product_name
                        mbed.link.close()
                    except Exception:
                        pass
                boards.append(d)

            print json.dumps(obj, indent=4) #, sys.stdout)
        else:
            index = 0
            if len(all_mbeds) > 0:
                for mbed in all_mbeds:
                    print("%d => %s boardId => %s" % (index, mbed.getInfo().encode('ascii', 'ignore'), mbed.unique_id))
                    index += 1
            else:
                print("No available boards are connected")
开发者ID:CobooGuo,项目名称:pyOCD,代码行数:57,代码来源:gdb_server.py


示例8: main

def main():
    log_file = "automated_test_result.txt"
    summary_file = "automated_test_summary.txt"

    parser = argparse.ArgumentParser(description='pyOCD automated testing')
    parser.add_argument('-d', '--debug',
                        action="store_true", help='Enable debug logging')
    args = parser.parse_args()

    # Setup logging
    if os.path.exists(log_file):
        os.remove(log_file)
    level = logging.DEBUG if args.debug else logging.INFO
    logging.basicConfig(level=level)
    logger = Logger(log_file)
    sys.stdout = logger
    sys.stderr = logger

    test_list = []
    board_list = []
    result_list = []

    # Put together list of tests
    test = Test("Basic Test", lambda board: basic_test(board, None))
    test_list.append(test)
    test_list.append(GdbServerJsonTest())
    test_list.append(SpeedTest())
    test_list.append(CortexTest())
    test_list.append(FlashTest())
    test_list.append(GdbTest())

    # Put together list of boards to test
    board_list = MbedBoard.getAllConnectedBoards(close=True, blocking=False)

    start = time()
    for board in board_list:
        print("--------------------------")
        print("TESTING BOARD %s" % board.getUniqueID())
        print("--------------------------")
        for test in test_list:
            test_start = time()
            result = test.run(board)
            test_stop = time()
            result.time = test_stop - test_start
            result_list.append(result)
    stop = time()
    test_time = (stop - start)

    print_summary(test_list, result_list, test_time)
    with open(summary_file, "wb") as output_file:
        print_summary(test_list, result_list, test_time, output_file)

    exit_val = 0 if Test.all_tests_pass(result_list) else -1
    exit(exit_val)
开发者ID:0xc0170,项目名称:pyOCD,代码行数:54,代码来源:automated_test.py


示例9: list_boards

    def list_boards(self):
        self.disable_logging()

        try:
            all_mbeds = MbedBoard.getAllConnectedBoards(close=True, blocking=False)
            status = 0
            error = ""
        except Exception as e:
            all_mbeds = []
            status = 1
            error = str(e)
            if not self.args.output_json:
                raise

        if self.args.output_json:
            boards = []
            obj = {
                'pyocd_version' : __version__,
                'version' : { 'major' : 1, 'minor' : 0 },
                'status' : status,
                'boards' : boards,
                }

            if status != 0:
                obj['error'] = error

            for mbed in all_mbeds:
                d = {
                    'unique_id' : mbed.unique_id,
                    'info' : mbed.getInfo(),
                    'board_name' : mbed.getBoardName(),
                    'target' : mbed.getTargetType(),
                    'vendor_name' : mbed.interface.vendor_name,
                    'product_name' : mbed.interface.product_name,
                    }
                boards.append(d)

            print json.dumps(obj, indent=4) #, sys.stdout)
        else:
            index = 0
            if len(all_mbeds) > 0:
                for mbed in all_mbeds:
                    print("%d => %s boardId => %s" % (index, mbed.getInfo().encode('ascii', 'ignore'), mbed.unique_id))
                    index += 1
            else:
                print("No available boards are connected")
开发者ID:oliviermartin,项目名称:pyOCD,代码行数:46,代码来源:gdb_server.py


示例10: run

    def run(self, args=None):
        try:
            self.args = self.build_parser().parse_args(args)
            self.gdb_server_settings = self.get_gdb_server_settings(self.args)
            self.setup_logging(self.args)
            DAPAccess.set_args(self.args.daparg)

            self.process_commands(self.args.commands)

            gdb = None
            if self.args.list_all == True:
                self.list_boards()
            elif self.args.list_targets == True:
                self.list_targets()
            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:
                        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
        except InvalidArgumentError as e:
            self.parser.error(e)
            return 1
开发者ID:matthewelse,项目名称:pyOCD,代码行数:39,代码来源:gdb_server.py


示例11: validate_boards

    def validate_boards(data):
        did_pass = True

        print 'boards',
        p = data.has_key('boards') and type(data['boards']) is list
        if p:
            b = data['boards']
        if p:
            print "PASSED"
        else:
            did_pass = False
            print"FAILED"

        try:
            all_mbeds = MbedBoard.getAllConnectedBoards(close=True, blocking=False)
            p = len(all_mbeds) == len(b)
            matching_boards = 0
            if p:
                for mbed in all_mbeds:
                    for brd in b:
                        if mbed.unique_id == brd['unique_id']:
                            matching_boards += 1
                            p = brd.has_key('info') and brd.has_key('target') and brd.has_key('board_name')
                            if not p:
                                break
                    if not p:
                        break
                p = matching_boards == len(all_mbeds)
            if p:
                print "PASSED"
            else:
                did_pass = False
                print"FAILED"
        except Exception:
            print "FAILED"
            did_pass = False

        return did_pass
开发者ID:0xc0170,项目名称:pyOCD,代码行数:38,代码来源:gdb_server_json_test.py


示例12: _launchPyOCDGDBServer

def _launchPyOCDGDBServer(msg_queue):
    logger.info('preparing PyOCD gdbserver...')
    from pyOCD.gdbserver import GDBServer
    from pyOCD.board import MbedBoard
    gdb = None
    try:
        logger.info('finding connected board...')
        board_selected = MbedBoard.chooseBoard(blocking=False)
        if board_selected is not None:
            with board_selected as board:
                logger.info('starting PyOCD gdbserver...')
                gdb = GDBServer(
                    board, 3333, {
                         'break_at_hardfault': True,
                        'step_into_interrupt': False,
                             'break_on_reset': False,
                    }
                )
                if gdb.isAlive():
                    msg_queue.put('alive')
                    while gdb.isAlive():
                        gdb.join(timeout = 0.5)
                        # check for a "kill" message from the parent process:
                        try:
                            msg = msg_queue.get(False)
                            if msg == 'kill':
                                gdb.stop()
                                break
                        except Queue.Empty:
                            pass
        else:
            logger.error('failed to find a connected board')
    except Exception as e:
        logger.error('exception in GDB server thread: %s', e)
        if gdb != None:
            gdb.stop()
        raise
    msg_queue.put('dead')
开发者ID:pombredanne,项目名称:valinor,代码行数:38,代码来源:gdb.py


示例13: Exception

build_type = build_types[0].strip().split("=")[1]
if build_type != "Debug":
    raise Exception("CMAKE_BUILD_TYPE was '%s', expected 'Debug'. Rebuild with `yt build -d`." % build_type)

# create crashdump folder
mkdir_p("crashdump")

# copy over AXF file
potential_axf = [f for f in os.listdir(yotta_build_path) if isfile(join(yotta_build_path, f)) and "." not in f]
if len(potential_axf) != 1:
    raise Exception("Found %d files without extension in %s, expected 1" % (len(potential_axf), yotta_build_path))
copyfile(join(yotta_build_path, potential_axf[0]), "crashdump/" + potential_axf[0] + ".axf")

print "[2/6] Build verified. Connecting to board..."

with MbedBoard.chooseBoard(frequency=10000000) as board:

    memory_map = board.target.getMemoryMap()
    ram_regions = [region for region in memory_map if region.type == 'ram']
    ram_region = ram_regions[0]
    rom_region = memory_map.getBootMemory()
    target_type = board.getTargetType()

    print "[3/6] Board recognized as %s. Downloading ROM..." % target_type

    addr = rom_region.start
    size = rom_region.length
    data = board.target.readBlockMemoryUnaligned8(addr, size)
    data = bytearray(data)
    with open("crashdump/rom.bin", 'wb') as f:
        f.write(data)
开发者ID:ARMmbed,项目名称:post-mortem-debugging,代码行数:31,代码来源:dump_firmware.py


示例14: speed_test

def speed_test(board_id):
    with MbedBoard.chooseBoard(board_id=board_id, frequency=1000000) as board:
        target_type = board.getTargetType()

        test_clock = 10000000
        if target_type == "nrf51":
            # Override clock since 10MHz is too fast
            test_clock = 1000000

        memory_map = board.target.getMemoryMap()
        ram_regions = [region for region in memory_map if region.type == "ram"]
        ram_region = ram_regions[0]
        rom_region = memory_map.getBootMemory()

        ram_start = ram_region.start
        ram_size = ram_region.length
        rom_start = rom_region.start
        rom_size = rom_region.length

        target = board.target
        link = board.link

        test_pass_count = 0
        test_count = 0
        result = SpeedTestResult()

        link.set_clock(test_clock)
        link.set_deferred_transfer(True)

        print("\r\n\r\n------ TEST RAM READ / WRITE SPEED ------")
        test_addr = ram_start
        test_size = ram_size
        data = [randrange(1, 50) for x in range(test_size)]
        start = time()
        target.writeBlockMemoryUnaligned8(test_addr, data)
        target.flush()
        stop = time()
        diff = stop - start
        result.write_speed = test_size / diff
        print("Writing %i byte took %s seconds: %s B/s" % (test_size, diff, result.write_speed))
        start = time()
        block = target.readBlockMemoryUnaligned8(test_addr, test_size)
        target.flush()
        stop = time()
        diff = stop - start
        result.read_speed = test_size / diff
        print("Reading %i byte took %s seconds: %s B/s" % (test_size, diff, result.read_speed))
        error = False
        for i in range(len(block)):
            if block[i] != data[i]:
                error = True
                print("ERROR: 0x%X, 0x%X, 0x%X!!!" % ((addr + i), block[i], data[i]))
        if error:
            print("TEST FAILED")
        else:
            print("TEST PASSED")
            test_pass_count += 1
        test_count += 1

        print("\r\n\r\n------ TEST ROM READ SPEED ------")
        test_addr = rom_start
        test_size = rom_size
        start = time()
        block = target.readBlockMemoryUnaligned8(test_addr, test_size)
        target.flush()
        stop = time()
        diff = stop - start
        print("Reading %i byte took %s seconds: %s B/s" % (test_size, diff, test_size / diff))
        print("TEST PASSED")
        test_pass_count += 1
        test_count += 1

        target.reset()

        result.passed = test_count == test_pass_count
        return result
开发者ID:arekzaluski,项目名称:pyOCD,代码行数:76,代码来源:speed_test.py


示例15: run

    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:
#.........这里部分代码省略.........
开发者ID:kaizen8501,项目名称:pyOCD,代码行数:101,代码来源:pyocd.py


示例16: cortex_test

def cortex_test(board_id):
    with MbedBoard.chooseBoard(board_id=board_id, frequency=1000000) as board:
        target_type = board.getTargetType()

        binary_file = os.path.join(parentdir, 'binaries', board.getTestBinary())

        test_clock = 10000000
        addr_invalid = 0x3E000000 # Last 16MB of ARM SRAM region - typically empty
        if target_type == "nrf51":
            # Override clock since 10MHz is too fast
            test_clock = 1000000
        if target_type == "ncs36510":
            # Override clock since 10MHz is too fast
            test_clock = 1000000

        memory_map = board.target.getMemoryMap()
        ram_regions = [region for region in memory_map if region.type == 'ram']
        ram_region = ram_regions[0]
        rom_region = memory_map.getBootMemory()

        addr = ram_region.start + 1
        size = 0x502
        addr_bin = rom_region.start

        target = board.target
        link = board.link
        flash = board.flash

        link.set_clock(test_clock)
        link.set_deferred_transfer(True)

        test_pass_count = 0
        test_count = 0
        result = CortexTestResult()

        print "\r\n\r\n----- FLASH NEW BINARY BEFORE TEST -----"
        flash.flashBinary(binary_file, addr_bin)
        # Let the target run for a bit so it
        # can initialize the watchdog if it needs to
        target.resume()
        sleep(0.2)
        target.halt()

        print "PROGRAMMING COMPLETE"


        print "\r\n\r\n----- TESTING CORTEX-M PERFORMANCE -----"
        test_time = test_function(board, target.getTResponse)
        print("Function getTResponse time: %f" % test_time)

        # Step
        test_time = test_function(board, target.step)
        print("Function step time: %f" % test_time)

        # Breakpoint
        def set_remove_breakpoint():
            target.setBreakpoint(0)
            target.removeBreakpoint(0)
        test_time = test_function(board, set_remove_breakpoint)
        print("Add and remove breakpoint: %f" % test_time)

        # getRegisterContext
        test_time = test_function(board, target.getRegisterContext)
        print("Function getRegisterContext: %f" % test_time)

        # setRegisterContext
        context = target.getRegisterContext()
        def set_register_context():
            target.setRegisterContext(context)
        test_time = test_function(board, set_register_context)
        print("Function setRegisterContext: %f" % test_time)

        # Run / Halt
        def run_halt():
            target.resume()
            target.halt()
        test_time = test_function(board, run_halt)
        print("Resume and halt: %f" % test_time)

        # GDB stepping
        def simulate_step():
            target.step()
            target.getTResponse()
            target.setBreakpoint(0)
            target.resume()
            target.halt()
            target.getTResponse()
            target.removeBreakpoint(0)
        test_time = test_function(board, simulate_step)
        print("Simulated GDB step: %f" % test_time)

        # Test passes if there are no exceptions
        test_pass_count += 1
        test_count += 1
        print("TEST PASSED")


        print "\r\n\r\n------ Testing Invalid Memory Access Recovery ------"
        memory_access_pass = True
        try:
#.........这里部分代码省略.........
开发者ID:cerevo,项目名称:pyOCD,代码行数:101,代码来源:cortex_test.py


示例17: speed_test

def speed_test(board_id):
    with MbedBoard.chooseBoard(board_id=board_id, frequency=1000000) as board:
        target_type = board.getTargetType()

        test_clock = 10000000
        if target_type == "kl25z":
            ram_start = 0x1ffff000
            ram_size = 0x4000
            rom_start = 0x00000000
            rom_size = 0x20000
        elif target_type == "kl28z":
            ram_start = 0x1fffa000
            ram_size = 96 * 1024
            rom_start = 0x00000000
            rom_size = 512 * 1024
        elif target_type == "kl46z":
            ram_start = 0x1fffe000
            ram_size = 0x8000
            rom_start = 0x00000000
            rom_size = 0x40000
        elif target_type == "k22f":
            ram_start = 0x1fff0000
            ram_size = 0x20000
            rom_start = 0x00000000
            rom_size = 0x80000
        elif target_type == "k64f":
            ram_start = 0x1FFF0000
            ram_size = 0x40000
            rom_start = 0x00000000
            rom_size = 0x100000
        elif target_type == "lpc11u24":
            ram_start = 0x10000000
            ram_size = 0x2000
            rom_start = 0x00000000
            rom_size = 0x8000
        elif target_type == "lpc1768":
            ram_start = 0x10000000
            ram_size = 0x8000
            rom_start = 0x00000000
            rom_size = 0x80000
        elif target_type == "lpc800":
            ram_start = 0x10000000
            ram_size = 0x1000
            rom_start = 0x00000000
            rom_size = 0x4000
        elif target_type == "lpc4330":
            ram_start = 0x10000000
            ram_size = 0x20000
            rom_start = 0x14000000
            rom_size = 0x100000
        elif target_type == "nrf51":
            ram_start = 0x20000000
            ram_size = 0x4000
            rom_start = 0x00000000
            rom_size = 0x40000
            # Override clock since 10MHz is too fast
            test_clock = 1000000
        elif target_type == "maxwsnenv":
            ram_start = 0x20000000
            ram_size = 0x8000
            rom_start = 0x00000000
            rom_size = 0x40000
        elif target_type == "max32600mbed":
            ram_start = 0x20000000
            ram_size = 0x8000
            rom_start = 0x00000000
            rom_size = 0x40000
        elif target_type == "w7500":
            ram_start = 0x20000000
            ram_size = 0x4000
            rom_start = 0x00000000
            rom_size = 0x20000
        else:
            raise Exception("The board is not supported by this test script.")

        target = board.target
        link = board.link

        test_pass_count = 0
        test_count = 0
        result = SpeedTestResult()

        link.set_clock(test_clock)
        link.set_deferred_transfer(True)

        print "\r\n\r\n------ TEST RAM READ / WRITE SPEED ------"
        test_addr = ram_start
        test_size = ram_size
        data = [randrange(1, 50) for x in range(test_size)]
        start = time()
        target.writeBlockMemoryUnaligned8(test_addr, data)
        target.flush()
        stop = time()
        diff = stop - start
        result.write_speed = test_size / diff
        print("Writing %i byte took %s seconds: %s B/s" % (test_size, diff, result.write_speed))
        start = time()
        block = target.readBlockMemoryUnaligned8(test_addr, test_size)
        target.flush()
        stop = time()
#.........这里部分代码省略.........
开发者ID:oliviermartin,项目名称:pyOCD,代码行数:101,代码来源:speed_test.py


示例18: main

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)
开发者ID:JohannesBauer,项目名称:yotta_osx_installer,代码行数:95,代码来源:flash_tool.py


示例19: range

from time import sleep
from random import randrange
import math

parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, parentdir)

import pyOCD
from pyOCD.board import MbedBoard
import logging

logging.basicConfig(level=logging.INFO)

print "\r\n\r\n------ Test attaching to locked board ------"
for i in range(0, 10):
    with MbedBoard.chooseBoard() as board:
        # Erase and then reset - This locks Kinetis devices
        board.flash.init()
        board.flash.eraseAll()
        board.target.reset()

print "\r\n\r\n------ Testing Attaching to board ------"
for i in range(0, 100):
    with MbedBoard.chooseBoard() as board:
        board.target.halt()
        sleep(0.01)
        board.target.resume()
        sleep(0.01)

print "\r\n\r\n------ Flashing new code ------"
with MbedBoard.chooseBoard() as board:
开发者ID:dbrobins,项目名称:pyOCD,代码行数:31,代码来源:blank_test.py


示例20:


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pyOpt.Optimizer类代码示例发布时间:2022-05-25
下一篇:
Python log.get_logger函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap