# # Copyright (c) 2018 Bobby Noelte # # SPDX-License-Identifier: Apache-2.0 # from extract.globals import * from extract.directive import DTDirective from extract.default import default ## # @brief Manage flash directives. # class DTFlash(DTDirective): def __init__(self): self._area_id = 0 def extract_partition(self, node_path): self._add_partition_index_entries(node_path) self._add_partition_label_entries(node_path) def _add_partition_index_entries(self, node_path): # Adds DT_FLASH_AREA__... entries, to the '# DT_FLASH_AREA' # section prop_def = {} prop_alias = {} node = reduced[node_path] # Index-based partition ID area_id = self._area_id self._area_id += 1 # Extract a per partition dev name. Something like # # #define DT_FLASH_AREA_1_DEV "FLASH_CTRL" prop_def["DT_FLASH_AREA_{}_DEV".format(area_id)] = \ '"' + reduced[controller_path(node_path)]['props']['label'] + '"' partition_label = str_to_label(node['props']['label']) prop_def["DT_FLASH_AREA_{}_LABEL".format(area_id)] = partition_label deprecated_main.append("DT_FLASH_AREA_{}_LABEL".format(area_id)) prop_def["DT_FLASH_AREA_{}_ID".format(partition_label)] = area_id reg = node['props']['reg'] for i in range(len(reg)//2): prop_def["DT_FLASH_AREA_{}_OFFSET_{}".format(area_id, i)] = reg[2*i] prop_def["DT_FLASH_AREA_{}_SIZE_{}".format(area_id, i)] = reg[2*i + 1] # Number of flash areas defined prop_def["DT_FLASH_AREA_NUM"] = self._area_id # Alias sector 0 prop_alias[ "DT_FLASH_AREA_{}_OFFSET".format(area_id) ] = "DT_FLASH_AREA_{}_OFFSET_0".format(area_id) prop_alias[ "DT_FLASH_AREA_{}_SIZE".format(area_id) ] = "DT_FLASH_AREA_{}_SIZE_0".format(area_id) insert_defs("DT_FLASH_AREA", prop_def, prop_alias) def _add_partition_label_entries(self, node_path): # Adds DT_FLASH_AREA_