コード例 #1
0
def append_platform(parser, plt_name, plt_config_path):

    plt_config = js.import_config_from_file(plt_config_path, paths = gapyJsonPath, find=True, interpret=True)
    runner_module = plt_config.get_str('runner_module')

    if runner_module is not None:
        try:
            runner = import_runner(runner_module)

            runner.appendArgs(parser, None)
        except:
            raise
コード例 #2
0
    def get_config(self):
        """Generates and return the system configuration.

        The whole hierarchy of components, bindings and properties are converted to a dictionnary
        representing the system, which can be serialized to a JSON file.

        Returns
        -------
        dict
            The resulting configuration
        """
        if not self.build_done:
            self.__build()

        config = {}

        for json_config_file in self.json_config_files:
            config = self.__merge_properties(
                config,
                js.import_config_from_file(json_config_file,
                                           find=True,
                                           interpret=True,
                                           gen=True).get_dict())

        for component_name, component in self.components.items():
            component_config = {component_name: component.get_config()}
            config = self.__merge_properties(config, component_config)

        #config = self.merge_options(config, self.comp_options, self.properties)

        config = self.__merge_properties(config, self.properties,
                                         self.comp_options)

        if len(self.bindings) != 0:
            if config.get('bindings') is None:
                config['bindings'] = []
            for binding in self.bindings:
                master_name = 'self' if binding[0] == self else binding[0].name
                slave_name = 'self' if binding[2] == self else binding[2].name
                config['bindings'].append([
                    '%s->%s' % (master_name, binding[1]),
                    '%s->%s' % (slave_name, binding[3])
                ])

        if len(self.components.values()) != 0:
            config = self.__merge_properties(
                config, {'components': list(self.components.keys())})

        if len(self.master_ports) != 0 or len(self.slave_ports) != 0:
            config = self.__merge_properties(
                config, {'ports': self.master_ports + self.slave_ports})

        return config
コード例 #3
0
ファイル: jtag.py プロジェクト: iis-eth-zurich/hemera
 def __init__(self, config_path, cable_option=None):
     self.config = js.import_config_from_file(config_path)
     path = os.path.join(os.environ.get('PULP_SDK_HOME'), 'install', 'ws',
                         'lib', 'libdebugbridge.so')
     self.module = ctypes.CDLL(path)
     self.module.bridge_new.argtypes = [ctypes.c_char_p, ctypes.c_char_p]
     self.module.jtag_write.argtypes = [
         ctypes.c_void_p, ctypes.c_int, ctypes.c_int, ctypes.c_char_p
     ]
     #self.module.jtag_shift.argtypes = [ctypes.c_void_p, ctypes.c_int, ctypes.POINTER(ctypes.c_char_p), ctypes.POINTER(ctypes.c_char_p)]
     with open(config_path, 'r') as config:
         self.instance = self.module.bridge_new(
             config.read().encode('utf-8'), cable_option.encode('utf-8'))
コード例 #4
0
def get_configs(config_str=None):
  result = []

  for config in shlex.split(config_str.replace(';', ' ')):

    if config.find('@') != -1:
      config_name, config = config.split('@')

    if config.find('config_file') != -1:
      key, file = config.split('=')
      config_tree = js.import_config_from_file(file, interpret=True)
      result.append(config_tree)

  return result
コード例 #5
0
def importConfig(parser):
    argsCli = sys.argv[1:]
    if '-h' in argsCli:
        argsCli.remove('-h')
    parser.parse_known_args(argsCli)
    args, _ = parser.parse_known_args(argsCli)
    if args.target is not None:
        jsonPath = os.path.join(targetsDir, args.target + '.json')
        ini_configs = args.ini_configs

        if os.environ.get('GAPY_CONFIGS_INI') is not None:
            ini_configs += os.environ.get('GAPY_CONFIGS_INI').split()

        return js.import_config_from_file(jsonPath, find = True, interpret = True, paths = gapyJsonPath, ini_configs=ini_configs, config_items=args.config_items)
    else:
        return None
コード例 #6
0
def importConfig(parser):
    argsCli = sys.argv[1:]
    if '-h' in argsCli:
        argsCli.remove('-h')
    parser.parse_known_args(argsCli)
    args, _ = parser.parse_known_args(argsCli)

    if args.py_target is not None:
        class_name, module_name = args.py_target.split('@')

        module = importlib.import_module(module_name)

        if not callable(getattr(module, class_name, None)):
            raise RuntimeError(
                'Unable to find target class (method: %s, filepath: %s)' %
                (class_name, module_name))

        runner = Runner(None,
                        'top',
                        options=args.config_items,
                        target_class=getattr(module, class_name, None))

        return (js.import_config(runner.get_config()), runner)

    elif args.target is not None:
        jsonPath = os.path.join(targetsDir, args.target + '.json')
        ini_configs = args.ini_configs

        if os.environ.get('GAPY_CONFIGS_INI') is not None:
            ini_configs += os.environ.get('GAPY_CONFIGS_INI').split()

        return (js.import_config_from_file(jsonPath,
                                           find=True,
                                           interpret=True,
                                           paths=gapyJsonPath,
                                           ini_configs=ini_configs,
                                           config_items=args.config_items),
                None)
    else:
        return (None, None)
コード例 #7
0
def import_json_file(regmap, config_path):

    config = js.import_config_from_file(config_path, find=True)
    import_json(regmap, config)
コード例 #8
0
ファイル: plp_runner.py プロジェクト: Vaktor777/runner
    def run(self):
        self.config.addOption("--help",
                              dest="showHelp",
                              action="store_true",
                              help="show this help message and exit")

        self.config.addOption(
            "--platform",
            dest="platform",
            default=None,
            choices=list(self.platforms.keys()),
            help="specify the platform. Default: %(default)s.")

        self.config.addOption(
            "--prop",
            dest="props",
            action="append",
            help="specify a property to be given to the platform",
            metavar="PATH")

        self.config.addOption(
            "--dir",
            dest="dir",
            default=os.getcwd(),
            help=
            "specify the test directory containing the binaries and from which the execution must be launched.",
            metavar="PATH")

        self.config.addOption(
            "--launcher",
            dest="launcher",
            default=os.path.join(os.environ['PULP_SDK_HOME'], 'bin',
                                 'launcher'),
            help="specify the launcher command to be executed",
            metavar="CMD")

        self.config.addOption("--commands",
                              dest="showCommands",
                              action="store_true",
                              default=False,
                              help="show the available commands.")

        self.parser.add_argument('command',
                                 metavar='commands',
                                 type=str,
                                 nargs='*',
                                 help='a command to be executed')

        self.parser.add_argument("--chip",
                                 dest="chip",
                                 default=None,
                                 help="Specify target chip")

        self.config.addOption(
            "--dev",
            dest="dev",
            action="store_true",
            default=False,
            help="activate development mode (more advanced options)")

        self.config.addOption("--no-warnings",
                              dest="warnings",
                              action="store_false",
                              default=True,
                              help='deactivate warnings')

        self.config.addOption("--config",
                              dest="config",
                              default=None,
                              help='specify the system configuration')

        self.config.addOption("--reentrant",
                              dest="reentrant",
                              action="store_true",
                              help='This script was called was pulp-run')

        self.config.addOption("--config-file",
                              dest="configFile",
                              default=None,
                              help='specify the system configuration file')

        self.config.addOption("--config-opt",
                              dest="configOpt",
                              default=[],
                              action="append",
                              help='specify configuration option')

        if self.config.getOption('dev'):
            self.config.addOption("--py-stack",
                                  dest="pyStack",
                                  action="store_true",
                                  default=False,
                                  help="activate Python tracestack")

        props = self.config.getOption('props')
        if props != None:
            for rawProp in props:
                prop = rawProp.split(':')
                self.config.setProperty(propertyName=prop[1],
                                        value=prop[2],
                                        path=prop[0])

        testPath = os.path.abspath(self.config.getOption('dir'))
        try:
            os.makedirs(testPath)
        except:
            pass
        os.chdir(testPath)

        systemConfig = self.config.getOption('config')
        if systemConfig != None:
            self.system_tree = plptree.get_configs_from_env(
                self.config.args.configDef, systemConfig)
        else:
            self.system_tree = plptree.get_configs_from_file(
                self.config.getOption('configFile'))[0]

        self.pyStack = self.system_tree.get_bool('runner/py-stack')

        # First get the json configuration
        config_path = self.config.getOption('configFile')
        chip = self.config.getOption('chip')

        if chip is not None:
            config_path = os.path.join(
                os.path.dirname(os.path.dirname(sys.argv[0])), 'configs',
                'systems', '%s.json' % chip)
        elif config_path is None:
            raise Exception('A chip or a config file must be specified')

        config = js.import_config_from_file(config_path)

        platform = self.config.getOption('platform')
        if platform is not None:
            config.set('platform', platform)

        self.system_tree = plptree.get_config_tree_from_dict(config.get_dict())

        platform_name = config.get('**/platform').get()

        if platform_name == 'gvsoc' and self.system_tree.get('pulp_chip') in [
                'pulp', 'pulpissimo', 'oprecompkw', 'oprecompkw_sfloat',
                'oprecompkw_sfloat_sa', 'multino', 'oprecompkw_sa', 'bigpulp',
                'bigpulp-z-7045', 'wolfe'
        ]:
            platform_name = 'vp'

        try:

            module = imp.load_source('module', self.platforms[platform_name])

            platform = module.Runner(self.config, config)

            for module in self.modules:
                platform.addParser(module(self.config, self.system_tree))

            retval = platform.handleCommands()
            return retval
        except Exception as e:
            if self.pyStack:
                raise
            else:
                print(e)
                return -1
コード例 #9
0
def get_config(file,
               name="",
               config_name=None,
               ini_configs=[],
               ini_configs_dict={},
               config_opts=[],
               properties=[],
               interpret=False,
               **kwargs):

    template_properties = []
    config_properties = config_opts

    for prop in properties:
        if prop.find('config/') == 0:
            config_properties.append(prop.split('config/')[1])
        else:
            template_properties.append(prop)

    if file is not None and file.find('@') != -1:
        name, file = file.split('@')

    if file is not None and file.find('config_file') != -1:
        dummy, file = file.split('=', 1)

    opts = []

    if file.find(':'):
        opts = file.split(':')[1:]
        file = file.split(':')[0]

    config = js.import_config_from_file(file, find=True, interpret=interpret)

    for ini_config in ini_configs:
        parser = configparser.SafeConfigParser(
            ini_configs_dict, dict_type=collections.OrderedDict)
        parser.optionxform = str
        paths = parser.read(ini_config)
        if len(paths) == 0:
            raise Exception("Didn't manage to open file: %s" % (ini_config))

        user_config = collections.OrderedDict()
        for section in parser.sections():
            for item in parser.items(section):
                path = ('%s.%s' % (section, item[0])).split('.')
                config.set_from_list(path, item[1])

        for prop in template_properties:
            for key, value in prop.split('='):
                config.user_set(key, value)

        config = js.import_config(config.get_dict(), interpret=interpret)

    result = create_config(name,
                           config,
                           interpret=interpret,
                           config_name=config_name,
                           **kwargs)

    for config_opt in config_opts + opts:
        key, value = config_opt.split('=', 1)
        result.user_set(key, value)

    return result