def west_flash(self, outdir, app, board, board_id=None): app_outdir = find_app_outdir(outdir, app, board) bcfg = BuildConfiguration(app_outdir) west_args = ['flash'] if board_id is not None: west_args.extend(['--board-id', board_id]) bootloader_mcuboot = bool(bcfg.get('CONFIG_BOOTLOADER_MCUBOOT')) if 'mcuboot' in self.arguments.outputs: if bootloader_mcuboot: mcuboot_outdir = find_mcuboot_outdir(outdir, app, board) args_extra = ['--build-dir', mcuboot_outdir] self.check_west_call(west_args + args_extra) else: msg = ( 'Warning:\n' '\tFlash of MCUboot requested, but the application is not compiled for MCUboot\n' # noqa: E501 '\t. Ignoring request; not attempting MCUboot flash. You can run this command\n' # noqa: E501 '\twith "-o app" to disable this message.') self.wrn(msg) if 'app' in self.arguments.outputs: args_extra = ['--build-dir', app_outdir] if bootloader_mcuboot: signed_bin = signed_app_name(app, board, app_outdir, 'bin') signed_hex = signed_app_name(app, board, app_outdir, 'hex') # Prefer hex to bin. (Some of the runners that take a hex don't # understand --dt-flash for a bin yet). if os.path.isfile(signed_hex): args_extra.extend(['--kernel-hex', signed_hex]) elif os.path.isfile(signed_bin): args_extra.extend( ['--dt-flash=y', '--kernel-bin', signed_bin]) self.check_west_call(west_args + args_extra)
def create(cls, cfg, args): daparg = os.environ.get('PYOCD_DAPARG') if daparg: log.wrn('Setting PYOCD_DAPARG in the environment is', 'deprecated; use the --daparg option instead.') if args.daparg is None: log.dbg('Missing --daparg set to {} from environment'.format( daparg), level=log.VERBOSE_VERY) args.daparg = daparg build_conf = BuildConfiguration(cfg.build_dir) flash_addr = cls.get_flash_address(args, build_conf) return PyOcdBinaryRunner(cfg, args.target, flashtool=args.flashtool, flash_addr=flash_addr, flashtool_opts=args.flashtool_opt, gdbserver=args.gdbserver, gdb_port=args.gdb_port, tui=args.tui, board_id=args.board_id, daparg=args.daparg, frequency=args.frequency)
def sign_commands(self, app, board, outdir): ret = [] bcfg = BuildConfiguration(outdir) align = str(bcfg['FLASH_WRITE_BLOCK_SIZE']) vtoff = str(bcfg['CONFIG_TEXT_SECTION_OFFSET']) version = self.arguments.imgtool_version slot_size = str(bcfg['FLASH_AREA_IMAGE_0_SIZE']) # Always produce a signed binary. unsigned_bin = os.path.join(outdir, 'zephyr', 'zephyr.bin') signed_bin = signed_app_name(app, board, outdir, 'bin') ret.append( self.sign_command(align, vtoff, version, unsigned_bin, signed_bin, slot_size)) # If there's a .hex file, sign that too. (Some Zephyr runners # can only flash hex files, e.g. the nrfjprog runner). unsigned_hex = os.path.join(outdir, 'zephyr', 'zephyr.hex') if os.path.isfile(unsigned_hex): signed_hex = signed_app_name(app, board, outdir, 'hex') ret.append( self.sign_command(align, vtoff, version, unsigned_hex, signed_hex, slot_size)) return ret
def create(cls, cfg, args): build_conf = BuildConfiguration(cfg.build_dir) flash_addr = cls.get_flash_address(args, build_conf) return JLinkBinaryRunner(cfg, args.device, commander=args.commander, flash_addr=flash_addr, erase=args.erase, iface=args.iface, speed=args.speed, gdbserver=args.gdbserver, gdb_port=args.gdb_port, tui=args.tui)
def create(cls, cfg, args): if args.img is None: args.img = cfg.bin_file if args.dfuse: args.dt_flash = True # --dfuse implies --dt-flash. build_conf = BuildConfiguration(cfg.build_dir) dcfg = DfuSeConfig(address=cls.get_flash_address(args, build_conf), options=args.dfuse_modifiers) else: dcfg = None return DfuUtilBinaryRunner(cfg, args.pid, args.alt, args.img, exe=args.dfu_util, dfuse_config=dcfg)