def list(opts): path_ = opts.defaults.expand('%%{_configdir}/bsps/*.ini') bsps = path.collect_files(path_) log.notice(' BSP List:') for bsp in bsps: log.notice(' %s' % (path.basename(bsp[:-4]))) raise error.exit()
def list_bsps(opts): path_ = opts.defaults.expand('%%{_configdir}/bsps/*.mc') bsps = path.collect_files(path_) log.notice(' BSP List:') for bsp in bsps: log.notice(' %s' % (path.basename(bsp[:-3]))) raise error.exit()
def help(self): print('%s: [options] [args]' % (self.command_name)) print('RTEMS Tools Project, %s' % (version.string())) print('Options and arguments:') opts = list(self.long_opts_help.keys()) if self.optargs: opts += self.optargs.keys() indent = self._help_indent() for o in sorted(opts): if o in self.long_opts_help: h = self.long_opts_help[o] elif self.optargs: h = self.optargs[o] else: raise error.general('invalid help data: %s' %(o)) print('%-*s : %s' % (indent, o, h)) raise error.exit()
def run(args=sys.argv, command_path=None): ec = 0 notice = None builder = None try: description = 'Provide one path to a u-boot build or provide two ' description += 'paths to the built the first and second stage loaders, ' description += 'for example a first stage loader is \'MLO\' and a second ' description += '\'u-boot.img\'. If converting a kernel only provide the ' description += 'executable\'s path.' argsp = argparse.ArgumentParser(prog='rtems-boot-image', description=description) argsp.add_argument('-l', '--log', help='log file (default: %(default)s).', type=str, default=log_default()) argsp.add_argument('-v', '--trace', help='enable trace logging for debugging.', action='store_true') argsp.add_argument( '-s', '--image-size', help='image size in mega-bytes (default: %(default)s).', type=str, action=valid_si, default='64m') argsp.add_argument( '-F', '--fs-format', help='root file system format (default: %(default)s).', type=str, action=valid_format, default='fat16') argsp.add_argument('-S', '--fs-size', help = 'root file system size in SI units ' + \ '(default: %(default)s).', type = str, action = valid_si, default = 'auto') argsp.add_argument('-A', '--fs-align', help = 'root file system alignment in SI units ' + \ '(default: %(default)s).', type = str, action = valid_si, default = '1m') argsp.add_argument('-k', '--kernel', help='install the kernel (default: %(default)r).', type=str, action=valid_file, default=None) argsp.add_argument( '-d', '--fdt', help='Flat device tree source/blob (default: %(default)r).', type=str, action=valid_file, default=None) argsp.add_argument('-f', '--file', help='install the file (default: None).', type=str, action=valid_file, default=[]) argsp.add_argument('--net-boot', help = 'configure a network boot using TFTP ' + \ '(default: %(default)r).', action = 'store_true') argsp.add_argument( '--net-boot-dhcp', help='network boot using dhcp (default: %(default)r).', action='store_true', default=False) argsp.add_argument( '--net-boot-ip', help='network boot IP address (default: %(default)r).', type=str, action=valid_ip, default=None) argsp.add_argument('--net-boot-server', help = 'network boot server IP address ' + \ '(default: %(default)r).', type = str, action = valid_ip, default = None) argsp.add_argument('--net-boot-file', help='network boot file (default: %(default)r).', type=str, default='rtems.img') argsp.add_argument( '--net-boot-fdt', help='network boot load a fdt file (default: %(default)r).', type=str, default=None) argsp.add_argument('-U', '--custom-uenv', help = 'install the custom uEnv.txt file ' + \ '(default: %(default)r).', type = str, action = valid_file, default = None) argsp.add_argument('-b', '--board', help='name of the board (default: %(default)r).', type=str, default='list') argsp.add_argument('--convert-kernel', help = 'convert a kernel to a bootoader image ' + \ '(default: %(default)r).', action = 'store_true', default = False) argsp.add_argument( '--build', help='set the build directory (default: %(default)r).', type=str, default='ribuild') argsp.add_argument( '--no-clean', help='do not clean when finished (default: %(default)r).', action='store_false', default=True) argsp.add_argument('-o', '--output', help='image output file name', type=str, action=valid_file_if_exists, required=True) argsp.add_argument( 'paths', help='files or paths, the number and type sets the mode.', nargs='+', action=valid_paths) argopts = argsp.parse_args(args[1:]) load_log(argopts.log) log.notice('RTEMS Tools - Boot Image, %s' % (version.string())) log.output(log.info(args)) log.tracing = argopts.trace if argopts.net_boot_dhcp or \ argopts.net_boot_ip is not None: if argopts.convert_kernel: raise error.general( 'net boot options not valid with kernel convert.') if argopts.custom_uenv is not None: raise error.general( 'cannot set custom uenv and net boot options.') host.load() log.output('Platform: %s' % (host.name)) if argopts.board == 'list': loader = bootloader(command_path) boards = loader.list_boards() log.notice(' Board list: bootloaders (%d)' % (len(boards))) for bl in sorted(boards): log.notice(' %s: %d' % (bl, len(boards[bl]))) for b in boards[bl]: log.notice(' ' + b) raise error.exit() loader = uboot_bootloader(command_path, argopts.build, argopts.convert_kernel, argopts.paths, argopts.board) loader.check_mandatory_configs() if loader.convert_kernel: if argopts.kernel is not None: raise error.general( 'kernel convert does not use the kernel option.') if len(argopts.paths) != 1: raise error.general('kernel convert take a single path.') argopts.kernel = argopts.paths[0] else: loader.clean = argopts.no_clean loader['build'] = argopts.build loader['board'] = argopts.board loader['output'] = argopts.output loader['image_size'] = argopts.image_size loader['fs_format'] = argopts.fs_format loader['fs_size'] = argopts.fs_size loader['fs_align'] = argopts.fs_align loader['kernel'] = argopts.kernel loader['fdt'] = argopts.fdt loader['files'] = ','.join(argopts.file) loader['net_dhcp'] = argopts.net_boot_dhcp loader['net_ip'] = argopts.net_boot_ip loader['net_server_ip'] = argopts.net_boot_server loader['net_exe'] = argopts.net_boot_file loader['net_fdt'] = argopts.net_boot_fdt loader['uenv_txt'] = argopts.custom_uenv loader.log() if not loader.convert_kernel: if loader['fs_size'] == 'auto': loader['fs_size'] = \ str(_si_size(loader['image_size']) - _si_size(loader['fs_align'])) elif _si_size(loader['image_size']) < \ _si_size(loader['fs_align']) + _si_size(loader['fs_size']): raise error.general( 'filesystem partition size larger than image size.') if host.name not in builders: err = 'no builder; platform not supported: %s' % (host.name) raise error.general(err) builder = builders[host.name](loader) if not loader.check_exes() or not builder.check_exes(): raise error.general('command(s) not found; please fix.') builder.build() except error.general as gerr: notice = str(gerr) ec = 1 except error.internal as ierr: notice = str(ierr) ec = 1 except error.exit as eerr: pass except KeyboardInterrupt: notice = 'abort: user terminated' ec = 1 except: raise notice = 'abort: unknown error' ec = 1 if builder is not None: del builder if notice is not None: log.stderr(notice) sys.exit(ec)