Lines Matching refs:self

78     def __init__(self, cfg, family, softreset, dev_id, erase=False,  argument
81 self.hex_ = cfg.hex_file
84 self.family = family
85 self.softreset = softreset
86 self.dev_id = dev_id
87 self.erase = bool(erase)
88 self.reset = bool(reset)
89 self.force = force
90 self.recover = bool(recover)
93 self.suit_starter = False
95 self.tool_opt = []
98 self.tool_opt += opts
140 def ensure_snr(self): argument
141 if not self.dev_id or "*" in self.dev_id:
142 self.dev_id = self.get_board_snr(self.dev_id or "*")
143 self.dev_id = self.dev_id.lstrip("0")
146 def do_get_boards(self): argument
149 def get_boards(self): argument
150 snrs = self.do_get_boards()
162 def get_board_snr(self, glob): argument
171 snrs = [snr for snr in self.get_boards() if fullmatch(re_glob, snr)]
179 self.verify_snr(board_snr)
210 def ensure_family(self): argument
213 if self.family is not None:
216 if self.build_conf.getboolean('CONFIG_SOC_SERIES_NRF51X'):
217 self.family = 'NRF51_FAMILY'
218 elif self.build_conf.getboolean('CONFIG_SOC_SERIES_NRF52X'):
219 self.family = 'NRF52_FAMILY'
220 elif self.build_conf.getboolean('CONFIG_SOC_SERIES_NRF53X'):
221 self.family = 'NRF53_FAMILY'
222 elif self.build_conf.getboolean('CONFIG_SOC_SERIES_NRF54LX'):
223 self.family = 'NRF54L_FAMILY'
224 elif self.build_conf.getboolean('CONFIG_SOC_SERIES_NRF54HX'):
225 self.family = 'NRF54H_FAMILY'
226 elif self.build_conf.getboolean('CONFIG_SOC_SERIES_NRF91X'):
227 self.family = 'NRF91_FAMILY'
228 elif self.build_conf.getboolean('CONFIG_SOC_SERIES_NRF92X'):
229 self.family = 'NRF92_FAMILY'
233 def hex_refers_region(self, region_start, region_end): argument
234 for segment_start, _ in self.hex_contents.segments():
239 def hex_get_uicrs(self): argument
242 if self.family in UICR_RANGES:
243 for uicr_core, uicr_range in UICR_RANGES[self.family].items():
244 if self.hex_refers_region(*uicr_range):
249 def flush(self, force=False): argument
251 self.flush_ops(force=force)
254 if self.family == 'NRF53_FAMILY':
263 self.logger.error(
268 if cpe.returncode == ErrVerify and self.hex_get_uicrs():
272 self.logger.warning(
280 def recover_target(self): argument
281 if self.family in ('NRF53_FAMILY', 'NRF54H_FAMILY', 'NRF92_FAMILY'):
282 self.logger.info(
286 self.logger.info('Recovering and erasing all flash memory.')
294 if self.family in ('NRF53_FAMILY', 'NRF54H_FAMILY', 'NRF92_FAMILY'):
295 self.exec_op('recover', core='NRFDL_DEVICE_CORE_NETWORK')
297 self.exec_op('recover')
299 def program_hex(self): argument
301 self.logger.info(f'Flashing file: {self.hex_}')
306 if self.family in ('NRF54H_FAMILY', 'NRF92_FAMILY'):
310 self.build_conf.getboolean('CONFIG_SOC_NRF54H20_CPUAPP') or
311 self.build_conf.getboolean('CONFIG_SOC_NRF9280_CPUAPP')
314 self.build_conf.getboolean('CONFIG_SOC_NRF54H20_CPURAD') or
315 self.build_conf.getboolean('CONFIG_SOC_NRF9280_CPURAD')
317 generated_uicr = self.build_conf.getboolean('CONFIG_NRF_REGTOOL_GENERATE_UICR')
324 if generated_uicr and not self.hex_get_uicrs().get(core):
331 if self.erase:
332 self.exec_op('erase', core='NRFDL_DEVICE_CORE_APPLICATION')
333 self.exec_op('erase', core='NRFDL_DEVICE_CORE_NETWORK')
339 if self.build_conf.get('CONFIG_BOARD_QUALIFIERS') == self.sysbuild_conf.get(
342 mpi_hex_dir = Path(os.path.join(self.cfg.build_dir, 'zephyr'))
345 if self.sysbuild_conf.getboolean('SB_CONFIG_SUIT_MPI_GENERATE'):
347 mpi_hex_dir / self.sysbuild_conf.get('SB_CONFIG_SUIT_MPI_APP_AREA_PATH'))
349 mpi_hex_dir / self.sysbuild_conf.get('SB_CONFIG_SUIT_MPI_RAD_AREA_PATH')
352 self.op_program(
360 self.op_program(
371 if not cpuapp and self.sysbuild_conf.get('SB_CONFIG_SUIT_ENVELOPE'):
376 self.op_program(
384 if not self.erase and generated_uicr:
385 self.exec_op('erase', core=core, option={'chip_erase_mode': 'ERASE_UICR',
388 if self.erase:
391 if self.family == 'NRF52_FAMILY':
401 if self.family in xip_ranges:
402 xip_start, xip_end = xip_ranges[self.family]
403 if self.hex_refers_region(xip_start, xip_end):
407 if self.family == 'NRF53_FAMILY':
409 self.program_hex_nrf53(erase_arg, qspi_erase_opt)
411 self.op_program(self.hex_, erase_arg, qspi_erase_opt, defer=True, core=core)
413 self.flush(force=False)
415 def program_hex_nrf53(self, erase_arg, qspi_erase_opt): argument
444 if not self.hex_refers_region(net_flash_start, net_flash_end):
445 self.op_program(self.hex_, erase_arg, qspi_erase_opt, defer=True,
450 elif self.hex_contents.minaddr() < net_flash_start or \
451 self.hex_contents.maxaddr() > net_flash_end:
454 for start, end in self.hex_contents.segments():
456 net_hex.merge(self.hex_contents[start:end])
458 app_hex.merge(self.hex_contents[start:end])
460 hex_path = Path(self.hex_)
468 self.logger.info(
475 self.op_program(net_hex_file, erase_arg, None, defer=True,
477 self.op_program(app_hex_file, erase_arg, qspi_erase_opt, defer=True,
481 self.op_program(self.hex_, erase_arg, None, defer=True,
484 def reset_target(self): argument
485 if self.family == 'NRF52_FAMILY' and not self.softreset:
486 self.exec_op('pinreset-enable')
488 if self.softreset:
489 self.exec_op('reset', option="RESET_SYSTEM")
491 self.exec_op('reset', option="RESET_PIN")
494 def do_require(self): argument
497 def _check_suit_starter(self, op): argument
505 self.logger.debug(f'suit starter: {file}')
509 def op_program(self, hex_file, erase, qspi_erase, defer=False, core=None): argument
510 args = self._op_program(hex_file, erase, qspi_erase)
511 self.exec_op('program', defer, core, **args)
513 def _op_program(self, hex_file, erase, qspi_erase): argument
521 def exec_op(self, op, defer=False, core=None, **kwargs): argument
529 self.logger.debug(f'defer: {defer} op: {op}')
530 if defer or not self.do_exec_op(op, force=False):
531 self.ops.append(op)
536 if self.suit_starter and self.family == 'NRF54H_FAMILY':
537 file = self._check_suit_starter(_op)
539 args = self._op_program(file, 'ERASE_NONE', None)
543 def do_exec_op(self, op, force=False): argument
548 def flush_ops(self, force=True): argument
554 self.logger.debug('Flushing ops')
555 while self.ops:
556 self.do_exec_op(self.ops.popleft(), force)
558 def do_run(self, command, **kwargs): argument
559 self.do_require()
561 self.ensure_output('hex')
566 self.hex_contents = IntelHex()
568 self.hex_contents.loadfile(self.hex_, format='hex')
570 self.ensure_snr()
571 self.ensure_family()
573 self.ops = deque()
575 if self.recover:
576 self.recover_target()
577 self.program_hex()
578 if self.reset:
579 self.reset_target()
581 self.flush(force=True)
583 self.logger.info(f'Board with serial number {self.dev_id} '