scripts: extract_dts_includes.py: Correct LOAD_OFFSET

This patch fixes a bug with the computation of the FLASH_LOAD_OFFSET
option that is derived as part of the DTS parsing.  Offset should be
the relative offset from the base of flash.  If the flash base address
and selected partition are the same, the offset should be 0.

JIRA: ZEP-2260

Signed-off-by: Andy Gross <andy.gross@linaro.org>
This commit is contained in:
Andy Gross 2017-06-09 11:38:56 -05:00 committed by Kumar Gala
commit fa4a39322e

View file

@ -603,6 +603,16 @@ def generate_include_file(defs, args):
sys.stdout.write("#endif\n") sys.stdout.write("#endif\n")
def lookup_defs(defs, node, key):
if node not in defs:
return None
if key in defs[node]['aliases']:
key = defs[node]['aliases'][key]
return defs[node].get(key, None)
def parse_arguments(): def parse_arguments():
parser = argparse.ArgumentParser(description = __doc__, parser = argparse.ArgumentParser(description = __doc__,
@ -698,10 +708,30 @@ def main():
if 'zephyr,sram' in chosen: if 'zephyr,sram' in chosen:
extract_reg_prop(chosen['zephyr,sram'], None, defs, "CONFIG_SRAM", 1024, None) extract_reg_prop(chosen['zephyr,sram'], None, defs, "CONFIG_SRAM", 1024, None)
if 'zephyr,code-partition' in chosen: # only compute the load offset if a code partition exists and it is not the
extract_reg_prop(chosen['zephyr,code-partition'], None, defs, "CONFIG_FLASH_LOAD", 1, "OFFSET") # same as the flash base address
load_defs = {}
if 'zephyr,code-partition' in chosen and \
'zephyr,flash' in chosen and \
reduced[chosen['zephyr,flash']] is not \
reduced[chosen['zephyr,code-partition']]:
flash_base = lookup_defs(defs, chosen['zephyr,flash'],
'CONFIG_FLASH_BASE_ADDRESS')
part_defs = {}
extract_reg_prop(chosen['zephyr,code-partition'], None, part_defs,
"PARTITION", 1, 'offset')
part_base = lookup_defs(part_defs, chosen['zephyr,code-partition'],
'PARTITION_OFFSET')
load_defs['CONFIG_FLASH_LOAD_OFFSET'] = \
hex(int(part_base, 16) - int(flash_base, 16))
load_defs['CONFIG_FLASH_LOAD_SIZE'] = \
lookup_defs(part_defs, chosen['zephyr,code-partition'],
'PARTITION_SIZE')
else: else:
extract_reg_prop(chosen['zephyr,flash'], None, defs, "CONFIG_FLASH_LOAD", 1, "OFFSET") load_defs['CONFIG_FLASH_LOAD_OFFSET'] = 0
load_defs['CONFIG_FLASH_LOAD_SIZE'] = 0
insert_defs(chosen['zephyr,flash'], defs, load_defs, {})
# generate include file # generate include file
if args.keyvalue: if args.keyvalue: