示例#1
0
def generate_defines():
    # Generates #defines (and .conf file values) from DTS

    # sorted() otherwise Python < 3.6 randomizes the order of the flash
    # partition table
    for node_path in sorted(reduced.keys()):
        generate_node_defines(node_path)

    if not defs:
        raise Exception("No information parsed from dts file.")

    for k, v in regs_config.items():
        if k in chosen:
            reg.extract(chosen[k], None, v, 1024)

    for k, v in name_config.items():
        if k in chosen:
            extract_string_prop(chosen[k], "label", v)

    node_path = chosen.get('zephyr,flash', 'dummy-flash')
    flash.extract(node_path, 'zephyr,flash', 'DT_FLASH')
    node_path = chosen.get('zephyr,code-partition', node_path)
    flash.extract(node_path, 'zephyr,code-partition', None)

    # Add DT_CHOSEN_<X> defines
    for c in sorted(chosen):
        insert_defs('chosen', {'DT_CHOSEN_' + str_to_label(c): '1'}, {})
示例#2
0
def generate_node_definitions(yaml_list):

    for k, v in reduced.items():
        node_compat = get_compat(k)
        if node_compat is not None and node_compat in yaml_list:
            extract_node_include_info(
                reduced, k, k, yaml_list, None)

    if defs == {}:
        raise Exception("No information parsed from dts file.")

    for k, v in regs_config.items():
        if k in chosen:
            reg.extract(chosen[k], None, None, v, 1024)

    for k, v in name_config.items():
        if k in chosen:
            extract_string_prop(chosen[k], None, "label", v)

    node_address = chosen.get('zephyr,flash', 'dummy-flash')
    flash.extract(node_address, yaml_list, 'zephyr,flash', 'FLASH')
    node_address = chosen.get('zephyr,code-partition', node_address)
    flash.extract(node_address, yaml_list, 'zephyr,code-partition', 'FLASH')

    return defs
def generate_defines():
    # Generates #defines (and .conf file values) from DTS
    
    logger.info('run to generate_defines ')
    # sorted() otherwise Python < 3.6 randomizes the order of the flash
    # partition table
    for node_path in sorted(reduced.keys()):
        generate_node_defines(node_path)

    if not defs:
        raise Exception("No information parsed from dts file.")

    for k, v in regs_config.items():
        if k in chosen:
            logger.debug("k "+ k )
            reg.extract(chosen[k], None, v, 1024)

    for k, v in name_config.items():
        if k in chosen:
            extract_string_prop(chosen[k], "label", v)

    flash.extract_flash()
    flash.extract_code_partition()

    # Add DT_CHOSEN_<X> defines
    for c in sorted(chosen):
        insert_defs('chosen', {'DT_CHOSEN_' + str_to_label(c): '1'}, {})
示例#4
0
def generate_prop_defines(node_path, prop):
    # Generates #defines (and .conf file values) from the prop
    # named 'prop' on the device tree node at 'node_path'

    binding = get_binding(node_path)
    if 'parent' in binding and 'bus' in binding['parent']:
        # If the binding specifies a parent for the node, then include the
        # parent in the #define's generated for the properties
        parent_path = get_parent_path(node_path)
        def_label = 'DT_' + node_label(parent_path) + '_' \
                          + node_label(node_path)
    else:
        def_label = 'DT_' + node_label(node_path)

    names = prop_names(reduced[node_path], prop)

    if prop == 'reg':
        reg.extract(node_path, names, def_label, 1)
    elif prop == 'interrupts' or prop == 'interrupts-extended':
        interrupts.extract(node_path, prop, names, def_label)
    elif prop == 'compatible':
        compatible.extract(node_path, prop, def_label)
    elif 'clocks' in prop:
        clocks.extract(node_path, prop, def_label)
    elif 'pwms' in prop or 'gpios' in prop:
        prop_values = reduced[node_path]['props'][prop]
        generic = prop[:-1]  # Drop the 's' from the prop

        extract_controller(node_path, prop, prop_values, 0, def_label, generic)
        extract_cells(node_path, prop, prop_values, names, 0, def_label,
                      generic)
    else:
        default.extract(node_path, prop, binding['properties'][prop]['type'],
                        def_label)
示例#5
0
def generate_defines():
    # Generates #defines (and .conf file values) from DTS

    # sorted() otherwise Python < 3.6 randomizes the order of the flash
    # partition table
    for node_path in sorted(reduced.keys()):
        generate_node_defines(node_path)

    if not defs:
        raise Exception("No information parsed from dts file.")

    for k, v in regs_config.items():
        if k in chosen:
            reg.extract(chosen[k], None, v, 1024)

    for k, v in name_config.items():
        if k in chosen:
            extract_string_prop(chosen[k], "label", v)

    flash.extract_flash()
    flash.extract_code_partition()
示例#6
0
def generate_defines():
    for node_path in reduced.keys():
        if get_compat(node_path) in get_binding_compats():
            generate_node_defines(node_path)

    if not defs:
        raise Exception("No information parsed from dts file.")

    for k, v in regs_config.items():
        if k in chosen:
            reg.extract(chosen[k], None, v, 1024)

    for k, v in name_config.items():
        if k in chosen:
            extract_string_prop(chosen[k], "label", v)

    node_address = chosen.get('zephyr,flash', 'dummy-flash')
    flash.extract(node_address, 'zephyr,flash', 'DT_FLASH')
    node_address = chosen.get('zephyr,code-partition', node_address)
    flash.extract(node_address, 'zephyr,code-partition', None)

    # Add DT_CHOSEN_<X> defines
    for c in sorted(chosen):
        insert_defs('chosen', {'DT_CHOSEN_' + str_to_label(c): '1'}, {})
示例#7
0
def extract_property(node_compat, yaml, node_address, prop, prop_val, names,
                     defs, label_override):

    if 'base_label' in yaml[node_compat]:
        def_label = yaml[node_compat].get('base_label')
    else:
        def_label = get_node_label(node_compat, node_address)

    if 'parent' in yaml[node_compat]:
        if 'bus' in yaml[node_compat]['parent']:
            # get parent label
            parent_address = ''
            for comp in node_address.split('/')[1:-1]:
                parent_address += '/' + comp

            #check parent has matching child bus value
            try:
                parent_yaml = \
                    yaml[reduced[parent_address]['props']['compatible']]
                parent_bus = parent_yaml['child']['bus']
            except (KeyError, TypeError) as e:
                raise Exception(
                    str(node_address) + " defines parent " +
                    str(parent_address) + " as bus master but " +
                    str(parent_address) + " not configured as bus master " +
                    "in yaml description")

            if parent_bus != yaml[node_compat]['parent']['bus']:
                bus_value = yaml[node_compat]['parent']['bus']
                raise Exception(
                    str(node_address) + " defines parent " +
                    str(parent_address) + " as " + bus_value +
                    " bus master but " + str(parent_address) +
                    " configured as " + str(parent_bus) + " bus master")

            # Generate alias definition if parent has any alias
            if parent_address in aliases:
                for i in aliases[parent_address]:
                    node_alias = i + '_' + def_label
                    aliases[node_address].append(node_alias)

            # Use parent label to generate label
            parent_label = get_node_label(
                find_parent_prop(node_address, 'compatible'), parent_address)
            def_label = parent_label + '_' + def_label

            # Generate bus-name define
            extract_single(node_address, yaml, 'parent-label', 'bus-name',
                           defs, def_label)

    if label_override is not None:
        def_label += '_' + label_override

    if prop == 'reg':
        if 'partition@' in node_address:
            # reg in partition is covered by flash handling
            flash.extract(node_address, yaml, prop, names, defs, def_label)
        else:
            reg.extract(node_address, yaml, prop, names, defs, def_label)
    elif prop == 'interrupts' or prop == 'interrupts-extended':
        interrupts.extract(node_address, yaml, prop, names, defs, def_label)
    elif 'pinctrl-' in prop:
        pinctrl.extract(node_address, yaml, prop, names, defs, def_label)
    elif 'clocks' in prop:
        clocks.extract(node_address, yaml, prop, names, defs, def_label)
    elif 'gpios' in prop:
        try:
            prop_values = list(reduced[node_address]['props'].get(prop))
        except:
            prop_values = reduced[node_address]['props'].get(prop)

        extract_controller(node_address, yaml, prop, prop_values, 0, defs,
                           def_label, 'gpio')
        extract_cells(node_address, yaml, prop, prop_values, names, 0, defs,
                      def_label, 'gpio')
    else:
        default.extract(node_address, yaml, prop, names, defs, def_label)
def extract_property(node_compat, node_address, prop, prop_val, names):

    node = reduced[node_address]
    yaml_node_compat = get_binding(node_address)
    if 'base_label' in yaml_node_compat:
        def_label = yaml_node_compat.get('base_label')
    else:
        def_label = get_node_label(node_address)

    if 'parent' in yaml_node_compat:
        if 'bus' in yaml_node_compat['parent']:
            # get parent label
            parent_address = get_parent_address(node_address)

            #check parent has matching child bus value
            try:
                parent_yaml = get_binding(parent_address)
                parent_bus = parent_yaml['child']['bus']
            except (KeyError, TypeError) as e:
                raise Exception(
                    str(node_address) + " defines parent " +
                    str(parent_address) + " as bus master but " +
                    str(parent_address) + " not configured as bus master " +
                    "in yaml description")

            if parent_bus != yaml_node_compat['parent']['bus']:
                bus_value = yaml_node_compat['parent']['bus']
                raise Exception(
                    str(node_address) + " defines parent " +
                    str(parent_address) + " as " + bus_value +
                    " bus master but " + str(parent_address) +
                    " configured as " + str(parent_bus) + " bus master")

            # Generate alias definition if parent has any alias
            if parent_address in aliases:
                for i in aliases[parent_address]:
                    # Build an alias name that respects device tree specs
                    node_name = node_compat + '-' + node_address.split('@')[-1]
                    node_strip = node_name.replace('@', '-').replace(',', '-')
                    node_alias = i + '-' + node_strip
                    if node_alias not in aliases[node_address]:
                        # Need to generate alias name for this node:
                        aliases[node_address].append(node_alias)

            # Use parent label to generate label
            parent_label = get_node_label(parent_address)
            def_label = parent_label + '_' + def_label

            # Generate bus-name define
            extract_single(node_address, 'parent-label', 'bus-name',
                           'DT_' + def_label)

    if 'base_label' not in yaml_node_compat:
        def_label = 'DT_' + def_label

    if prop == 'reg':
        reg.extract(node_address, names, def_label, 1)
    elif prop == 'interrupts' or prop == 'interrupts-extended':
        interrupts.extract(node_address, prop, names, def_label)
    elif prop == 'compatible':
        compatible.extract(node_address, prop, def_label)
    elif 'pinctrl-' in prop:
        pinctrl.extract(node_address, prop, def_label)
    elif 'clocks' in prop:
        clocks.extract(node_address, prop, def_label)
    elif 'pwms' in prop or 'gpios' in prop:
        # drop the 's' from the prop
        generic = prop[:-1]
        try:
            prop_values = list(reduced[node_address]['props'].get(prop))
        except:
            prop_values = reduced[node_address]['props'].get(prop)

        extract_controller(node_address, prop, prop_values, 0, def_label,
                           generic)
        extract_cells(node_address, prop, prop_values, names, 0, def_label,
                      generic)
    else:
        default.extract(node_address, prop, prop_val['type'], def_label)
示例#9
0
def extract_property(node_compat, yaml, node_address, prop, prop_val, names):

    node = reduced[node_address]
    label_override = None
    if yaml[node_compat].get('use-property-label', False):
        try:
            label_override = convert_string_to_label(node['props']['label'])
        except KeyError:
            pass

    if 'base_label' in yaml[node_compat]:
        def_label = yaml[node_compat].get('base_label')
    else:
        def_label = get_node_label(node_address)

    if 'parent' in yaml[node_compat]:
        if 'bus' in yaml[node_compat]['parent']:
            # get parent label
            parent_address = get_parent_address(node_address)

            #check parent has matching child bus value
            try:
                parent_yaml = \
                    yaml[reduced[parent_address]['props']['compatible']]
                parent_bus = parent_yaml['child']['bus']
            except (KeyError, TypeError) as e:
                raise Exception(
                    str(node_address) + " defines parent " +
                    str(parent_address) + " as bus master but " +
                    str(parent_address) + " not configured as bus master " +
                    "in yaml description")

            if parent_bus != yaml[node_compat]['parent']['bus']:
                bus_value = yaml[node_compat]['parent']['bus']
                raise Exception(
                    str(node_address) + " defines parent " +
                    str(parent_address) + " as " + bus_value +
                    " bus master but " + str(parent_address) +
                    " configured as " + str(parent_bus) + " bus master")

            # Generate alias definition if parent has any alias
            if parent_address in aliases:
                for i in aliases[parent_address]:
                    # Build an alias name that respects device tree specs
                    node_name = node_compat + '-' + node_address.split('@')[-1]
                    node_strip = node_name.replace('@', '-').replace(',', '-')
                    node_alias = i + '-' + node_strip
                    if node_alias not in aliases[node_address]:
                        # Need to generate alias name for this node:
                        aliases[node_address].append(node_alias)

            # Use parent label to generate label
            parent_label = get_node_label(parent_address)
            def_label = parent_label + '_' + def_label

            # Generate bus-name define
            extract_single(node_address, yaml, 'parent-label', 'bus-name',
                           def_label)

    if label_override is not None:
        def_label += '_' + label_override

    if prop == 'reg':
        if 'partition@' in node_address:
            # reg in partition is covered by flash handling
            flash.extract(node_address, yaml, prop, def_label)
        else:
            reg.extract(node_address, yaml, names, def_label, 1)
    elif prop == 'interrupts' or prop == 'interrupts-extended':
        interrupts.extract(node_address, yaml, prop, names, def_label)
    elif prop == 'compatible':
        compatible.extract(node_address, yaml, prop, def_label)
    elif 'pinctrl-' in prop:
        pinctrl.extract(node_address, yaml, prop, def_label)
    elif 'clocks' in prop:
        clocks.extract(node_address, yaml, prop, def_label)
    elif 'pwms' in prop or 'gpios' in prop:
        # drop the 's' from the prop
        generic = prop[:-1]
        try:
            prop_values = list(reduced[node_address]['props'].get(prop))
        except:
            prop_values = reduced[node_address]['props'].get(prop)

        # Newer versions of dtc might have the property look like
        # cs-gpios = <0x05 0x0d 0x00>, < 0x06 0x00 0x00>;
        # So we need to flatten the list in that case
        if isinstance(prop_values[0], list):
            prop_values = [item for sublist in prop_values for item in sublist]

        extract_controller(node_address, yaml, prop, prop_values, 0, def_label,
                           generic)
        extract_cells(node_address, yaml, prop, prop_values, names, 0,
                      def_label, generic)
    else:
        default.extract(node_address, yaml, prop, prop_val['type'], def_label)
示例#10
0
def extract_property(node_compat, node_address, prop, prop_val, names):
    node = reduced[node_address]
    yaml_node_compat = get_binding(node_address)
    def_label = get_node_label(node_address)

    if 'parent' in yaml_node_compat and 'bus' in yaml_node_compat['parent']:
        # Get parent label
        parent_address = get_parent_address(node_address)

        # Check that parent has matching child bus value
        try:
            parent_yaml = get_binding(parent_address)
            parent_bus = parent_yaml['child']['bus']
        except (KeyError, TypeError) as e:
            raise Exception("{0} defines parent {1} as bus master, but {1} is "
                            "not configured as bus master in binding".format(
                                node_address, parent_address))

        if parent_bus != yaml_node_compat['parent']['bus']:
            raise Exception("{0} defines parent {1} as {2} bus master, but "
                            "{1} is configured as {3} bus master".format(
                                node_address, parent_address,
                                yaml_node_compat['parent']['bus'], parent_bus))

        # Generate alias definition if parent has any alias
        if parent_address in aliases:
            for i in aliases[parent_address]:
                # Build an alias name that respects device tree specs
                node_name = node_compat + '-' + node_address.split('@')[-1]
                node_strip = node_name.replace('@', '-').replace(',', '-')
                node_alias = i + '-' + node_strip
                if node_alias not in aliases[node_address]:
                    # Need to generate alias name for this node:
                    aliases[node_address].append(node_alias)

        # Build the name from the parent node's label
        def_label = get_node_label(parent_address) + '_' + def_label

        # Generate *_BUS_NAME #define
        extract_bus_name(node_address, 'DT_' + def_label)

    def_label = 'DT_' + def_label

    if prop == 'reg':
        reg.extract(node_address, names, def_label, 1)
    elif prop == 'interrupts' or prop == 'interrupts-extended':
        interrupts.extract(node_address, prop, names, def_label)
    elif prop == 'compatible':
        compatible.extract(node_address, prop, def_label)
    elif 'pinctrl-' in prop:
        pinctrl.extract(node_address, prop, def_label)
    elif 'clocks' in prop:
        clocks.extract(node_address, prop, def_label)
    elif 'pwms' in prop or 'gpios' in prop:
        prop_values = reduced[node_address]['props'][prop]
        generic = prop[:-1]  # Drop the 's' from the prop

        extract_controller(node_address, prop, prop_values, 0, def_label,
                           generic)
        extract_cells(node_address, prop, prop_values, names, 0, def_label,
                      generic)
    else:
        default.extract(node_address, prop, prop_val['type'], def_label)