1ce2b1ec6SManish Pandey#!/usr/bin/python3 204e7f808SJ-Alves# Copyright (c) 2020-2024, Arm Limited. All rights reserved. 3ce2b1ec6SManish Pandey# 4ce2b1ec6SManish Pandey# SPDX-License-Identifier: BSD-3-Clause 5ce2b1ec6SManish Pandey 6ce2b1ec6SManish Pandey""" 7ce2b1ec6SManish PandeyThis script is invoked by Make system and generates secure partition makefile. 8ce2b1ec6SManish PandeyIt expects platform provided secure partition layout file which contains list 9ce2b1ec6SManish Pandeyof Secure Partition Images and Partition manifests(PM). 10ce2b1ec6SManish PandeyLayout file can exist outside of TF-A tree and the paths of Image and PM files 11ce2b1ec6SManish Pandeymust be relative to it. 12ce2b1ec6SManish Pandey 13ce2b1ec6SManish PandeyThis script parses the layout file and generates a make file which updates 1407c44475SManish PandeyFDT_SOURCES, FIP_ARGS, CRT_ARGS and SPTOOL_ARGS which are used in later build 1507c44475SManish Pandeysteps. 165ac60ea1SImre KisIf the SP entry in the layout file has a "uuid" field the scripts gets the UUID 175ac60ea1SImre Kisfrom there, otherwise it parses the associated partition manifest and extracts 185ac60ea1SImre Kisthe UUID from there. 19ce2b1ec6SManish Pandey 20ce2b1ec6SManish Pandeyparam1: Generated mk file "sp_gen.mk" 21ce2b1ec6SManish Pandeyparam2: "SP_LAYOUT_FILE", json file containing platform provided information 22ce2b1ec6SManish Pandeyparam3: plat out directory 231e7528ecSRuari Phippsparam4: CoT parameter 2420629b31SKarl Meakinparam5: Generated dts file "sp_list_fragment.dts" 25ce2b1ec6SManish Pandey 26ce2b1ec6SManish PandeyGenerated "sp_gen.mk" file contains triplet of following information for each 27ce2b1ec6SManish PandeySecure Partition entry 28ce2b1ec6SManish Pandey FDT_SOURCES += sp1.dts 29ce2b1ec6SManish Pandey SPTOOL_ARGS += -i sp1.bin:sp1.dtb -o sp1.pkg 30ce2b1ec6SManish Pandey FIP_ARGS += --blob uuid=XXXXX-XXX...,file=sp1.pkg 3107c44475SManish Pandey CRT_ARGS += --sp-pkg1 sp1.pkg 32ce2b1ec6SManish Pandey 3393273613SBen HorganIt populates the number of SP in the defined macro 'NUM_SP' 3493273613SBen Horgan $(eval $(call add_define_val,NUM_SP,{len(sp_layout.keys())})) 3593273613SBen Horgan 36ce2b1ec6SManish PandeyA typical SP_LAYOUT_FILE file will look like 37ce2b1ec6SManish Pandey{ 38ce2b1ec6SManish Pandey "SP1" : { 39ce2b1ec6SManish Pandey "image": "sp1.bin", 40ce2b1ec6SManish Pandey "pm": "test/sp1.dts" 41ce2b1ec6SManish Pandey }, 42ce2b1ec6SManish Pandey 43ce2b1ec6SManish Pandey "SP2" : { 44ce2b1ec6SManish Pandey "image": "sp2.bin", 455ac60ea1SImre Kis "pm": "test/sp2.dts", 465ac60ea1SImre Kis "uuid": "1b1820fe-48f7-4175-8999-d51da00b7c9f" 47ce2b1ec6SManish Pandey } 48ce2b1ec6SManish Pandey 49ce2b1ec6SManish Pandey ... 50ce2b1ec6SManish Pandey} 51ce2b1ec6SManish Pandey 52ce2b1ec6SManish Pandey""" 53ce2b1ec6SManish Pandeyimport json 54ce2b1ec6SManish Pandeyimport os 55ce2b1ec6SManish Pandeyimport re 56ce2b1ec6SManish Pandeyimport sys 57ce2b1ec6SManish Pandeyimport uuid 58*2d317e80SJ-Alvesimport fdt 59a96a07bfSJ-Alvesfrom spactions import SpSetupActions 60*2d317e80SJ-Alvesimport hob 61*2d317e80SJ-Alvesimport struct 62*2d317e80SJ-Alvesfrom hob import HobList 63ce2b1ec6SManish Pandey 641e7528ecSRuari PhippsMAX_SP = 8 65a96a07bfSJ-AlvesUUID_LEN = 4 66*2d317e80SJ-AlvesHOB_OFFSET_DEFAULT=0x2000 67ce2b1ec6SManish Pandey 68a96a07bfSJ-Alves# Some helper functions to access args propagated to the action functions in 69a96a07bfSJ-Alves# SpSetupActions framework. 70a96a07bfSJ-Alvesdef check_sp_mk_gen(args :dict): 71a96a07bfSJ-Alves if "sp_gen_mk" not in args.keys(): 72a96a07bfSJ-Alves raise Exception(f"Path to file sp_gen.mk needs to be in 'args'.") 731e7528ecSRuari Phipps 74a96a07bfSJ-Alvesdef check_out_dir(args :dict): 75a96a07bfSJ-Alves if "out_dir" not in args.keys() or not os.path.isdir(args["out_dir"]): 76a96a07bfSJ-Alves raise Exception("Define output folder with \'out_dir\' key.") 771e7528ecSRuari Phipps 78a96a07bfSJ-Alvesdef check_sp_layout_dir(args :dict): 79a96a07bfSJ-Alves if "sp_layout_dir" not in args.keys() or not os.path.isdir(args["sp_layout_dir"]): 80a96a07bfSJ-Alves raise Exception("Define output folder with \'sp_layout_dir\' key.") 81a96a07bfSJ-Alves 82a96a07bfSJ-Alvesdef write_to_sp_mk_gen(content, args :dict): 83a96a07bfSJ-Alves check_sp_mk_gen(args) 84a96a07bfSJ-Alves with open(args["sp_gen_mk"], "a") as f: 85a96a07bfSJ-Alves f.write(f"{content}\n") 86a96a07bfSJ-Alves 87a96a07bfSJ-Alvesdef get_sp_manifest_full_path(sp_node, args :dict): 88a96a07bfSJ-Alves check_sp_layout_dir(args) 89a96a07bfSJ-Alves return os.path.join(args["sp_layout_dir"], get_file_from_layout(sp_node["pm"])) 90a96a07bfSJ-Alves 91a96a07bfSJ-Alvesdef get_sp_img_full_path(sp_node, args :dict): 92a96a07bfSJ-Alves check_sp_layout_dir(args) 93a96a07bfSJ-Alves return os.path.join(args["sp_layout_dir"], get_file_from_layout(sp_node["image"])) 94a96a07bfSJ-Alves 950fe374efSJ-Alvesdef get_size(sp_node): 960fe374efSJ-Alves if not "size" in sp_node: 970fe374efSJ-Alves print("WARNING: default image size 0x100000") 980fe374efSJ-Alves return 0x100000 990fe374efSJ-Alves 1000fe374efSJ-Alves # Try if it was a decimal value. 1010fe374efSJ-Alves try: 1020fe374efSJ-Alves return int(sp_node["size"]) 1030fe374efSJ-Alves except ValueError: 1040fe374efSJ-Alves print("WARNING: trying to parse base 16 size") 1050fe374efSJ-Alves # Try if it is of base 16 1060fe374efSJ-Alves return int(sp_node["size"], 16) 1070fe374efSJ-Alves 108a96a07bfSJ-Alvesdef get_sp_pkg(sp, args :dict): 109a96a07bfSJ-Alves check_out_dir(args) 110a96a07bfSJ-Alves return os.path.join(args["out_dir"], f"{sp}.pkg") 111a96a07bfSJ-Alves 112a96a07bfSJ-Alvesdef is_line_in_sp_gen(line, args :dict): 113a96a07bfSJ-Alves with open(args["sp_gen_mk"], "r") as f: 114a96a07bfSJ-Alves sppkg_rule = [l for l in f if line in l] 1151a28f290SJ-Alves return len(sppkg_rule) != 0 116a96a07bfSJ-Alves 117a96a07bfSJ-Alvesdef get_file_from_layout(node): 118a96a07bfSJ-Alves ''' Helper to fetch a file path from sp_layout.json. ''' 119a96a07bfSJ-Alves if type(node) is dict and "file" in node.keys(): 120a96a07bfSJ-Alves return node["file"] 121a96a07bfSJ-Alves return node 122a96a07bfSJ-Alves 123a96a07bfSJ-Alvesdef get_offset_from_layout(node): 124a96a07bfSJ-Alves ''' Helper to fetch an offset from sp_layout.json. ''' 125a96a07bfSJ-Alves if type(node) is dict and "offset" in node.keys(): 126a96a07bfSJ-Alves return int(node["offset"], 0) 127a96a07bfSJ-Alves return None 128a96a07bfSJ-Alves 129a96a07bfSJ-Alvesdef get_image_offset(node): 130a96a07bfSJ-Alves ''' Helper to fetch image offset from sp_layout.json ''' 131a96a07bfSJ-Alves return get_offset_from_layout(node["image"]) 132a96a07bfSJ-Alves 133a96a07bfSJ-Alvesdef get_pm_offset(node): 134a96a07bfSJ-Alves ''' Helper to fetch pm offset from sp_layout.json ''' 135a96a07bfSJ-Alves return get_offset_from_layout(node["pm"]) 136a96a07bfSJ-Alves 13720629b31SKarl Meakindef get_uuid(sp_layout, sp, args :dict): 13820629b31SKarl Meakin ''' Helper to fetch uuid from pm file listed in sp_layout.json''' 13920629b31SKarl Meakin if "uuid" in sp_layout[sp]: 14020629b31SKarl Meakin # Extract the UUID from the JSON file if the SP entry has a 'uuid' field 14120629b31SKarl Meakin uuid_std = uuid.UUID(sp_layout[sp]['uuid']) 14220629b31SKarl Meakin else: 14320629b31SKarl Meakin with open(get_sp_manifest_full_path(sp_layout[sp], args), "r") as pm_f: 14420629b31SKarl Meakin uuid_lines = [l for l in pm_f if 'uuid' in l] 14520629b31SKarl Meakin assert(len(uuid_lines) == 1) 14620629b31SKarl Meakin # The uuid field in SP manifest is the little endian representation 14720629b31SKarl Meakin # mapped to arguments as described in SMCCC section 5.3. 14820629b31SKarl Meakin # Convert each unsigned integer value to a big endian representation 14920629b31SKarl Meakin # required by fiptool. 15020629b31SKarl Meakin uuid_parsed = re.findall("0x([0-9a-f]+)", uuid_lines[0]) 15120629b31SKarl Meakin y = list(map(bytearray.fromhex, uuid_parsed)) 15220629b31SKarl Meakin z = [int.from_bytes(i, byteorder='little', signed=False) for i in y] 15320629b31SKarl Meakin uuid_std = uuid.UUID(f'{z[0]:08x}{z[1]:08x}{z[2]:08x}{z[3]:08x}') 15420629b31SKarl Meakin return uuid_std 15520629b31SKarl Meakin 15620629b31SKarl Meakindef get_load_address(sp_layout, sp, args :dict): 15720629b31SKarl Meakin ''' Helper to fetch load-address from pm file listed in sp_layout.json''' 15820629b31SKarl Meakin with open(get_sp_manifest_full_path(sp_layout[sp], args), "r") as pm_f: 15920629b31SKarl Meakin load_address_lines = [l for l in pm_f if 'load-address' in l] 16004e7f808SJ-Alves 1616a3225e2SJ-Alves if len(load_address_lines) != 1: 16204e7f808SJ-Alves return None 16304e7f808SJ-Alves 16420629b31SKarl Meakin load_address_parsed = re.search("(0x[0-9a-f]+)", load_address_lines[0]) 16520629b31SKarl Meakin return load_address_parsed.group(0) 16620629b31SKarl Meakin 167a96a07bfSJ-Alves@SpSetupActions.sp_action(global_action=True) 168a96a07bfSJ-Alvesdef check_max_sps(sp_layout, _, args :dict): 169a96a07bfSJ-Alves ''' Check validate the maximum number of SPs is respected. ''' 170a96a07bfSJ-Alves if len(sp_layout.keys()) > MAX_SP: 171a96a07bfSJ-Alves raise Exception(f"Too many SPs in SP layout file. Max: {MAX_SP}") 172a96a07bfSJ-Alves return args 173a96a07bfSJ-Alves 17493273613SBen Horgan@SpSetupActions.sp_action(global_action=True) 17593273613SBen Horgandef count_sps(sp_layout, _, args :dict): 17693273613SBen Horgan ''' Count number of SP and put in NUM_SP ''' 17793273613SBen Horgan write_to_sp_mk_gen(f"$(eval $(call add_define_val,NUM_SP,{len(sp_layout.keys())}))", args) 17893273613SBen Horgan return args 17993273613SBen Horgan 180a96a07bfSJ-Alves@SpSetupActions.sp_action 181a96a07bfSJ-Alvesdef gen_fdt_sources(sp_layout, sp, args :dict): 182a96a07bfSJ-Alves ''' Generate FDT_SOURCES values for a given SP. ''' 183a96a07bfSJ-Alves manifest_path = get_sp_manifest_full_path(sp_layout[sp], args) 184a96a07bfSJ-Alves write_to_sp_mk_gen(f"FDT_SOURCES += {manifest_path}", args) 185a96a07bfSJ-Alves return args 186a96a07bfSJ-Alves 187*2d317e80SJ-Alves@SpSetupActions.sp_action(exec_order=1) 188*2d317e80SJ-Alvesdef generate_hob_list(sp_layout, sp, args: dict): 189*2d317e80SJ-Alves ''' 190*2d317e80SJ-Alves Generates a HOB file for the partition, if it requested it in its FF-A 191*2d317e80SJ-Alves manifest. 192*2d317e80SJ-Alves ''' 193*2d317e80SJ-Alves with open(get_sp_manifest_full_path(sp_layout[sp], args), "r") as f: 194*2d317e80SJ-Alves sp_fdt = fdt.parse_dts(f.read()) 195*2d317e80SJ-Alves 196*2d317e80SJ-Alves if sp_fdt.exist_property('hob_list', '/boot-info'): 197*2d317e80SJ-Alves sp_hob_name = os.path.basename(sp + ".hob.bin") 198*2d317e80SJ-Alves sp_hob_name = os.path.join(args["out_dir"], f"{sp_hob_name}") 199*2d317e80SJ-Alves 200*2d317e80SJ-Alves # Add to the args so it can be consumed by the TL pkg function. 201*2d317e80SJ-Alves sp_layout[sp]["hob_path"] = sp_hob_name 202*2d317e80SJ-Alves hob_list = hob.generate_hob_from_fdt_node(sp_fdt, HOB_OFFSET_DEFAULT) 203*2d317e80SJ-Alves with open(sp_hob_name, "wb") as h: 204*2d317e80SJ-Alves for block in hob_list.get_list(): 205*2d317e80SJ-Alves h.write(block.pack()) 206*2d317e80SJ-Alves 207*2d317e80SJ-Alves return args 208*2d317e80SJ-Alves 2090fe374efSJ-Alvesdef generate_sp_pkg(sp_node, pkg, sp_img, sp_dtb): 2100fe374efSJ-Alves ''' Generates the rule in case SP is to be generated in an SP Pkg. ''' 2110fe374efSJ-Alves pm_offset = get_pm_offset(sp_node) 2120fe374efSJ-Alves sptool_args = f" --pm-offset {pm_offset}" if pm_offset is not None else "" 2130fe374efSJ-Alves image_offset = get_image_offset(sp_node) 2140fe374efSJ-Alves sptool_args += f" --img-offset {image_offset}" if image_offset is not None else "" 2150fe374efSJ-Alves sptool_args += f" -o {pkg}" 2160fe374efSJ-Alves return f''' 2170fe374efSJ-Alves{pkg}: {sp_dtb} {sp_img} 2180fe374efSJ-Alves\t$(Q)echo Generating {pkg} 2190fe374efSJ-Alves\t$(Q)$(PYTHON) $(SPTOOL) -i {sp_img}:{sp_dtb} {sptool_args} 2200fe374efSJ-Alves''' 2210fe374efSJ-Alves 2220fe374efSJ-Alvesdef generate_tl_pkg(sp_node, pkg, sp_img, sp_dtb, hob_path = None): 2230fe374efSJ-Alves ''' Generate make rules for a Transfer List type package. ''' 2240fe374efSJ-Alves # TE Type for the FF-A manifest. 2250fe374efSJ-Alves TE_FFA_MANIFEST = 0x106 2260fe374efSJ-Alves # TE Type for the SP binary. 2270fe374efSJ-Alves TE_SP_BINARY = 0x103 2280fe374efSJ-Alves # TE Type for the HOB List. 2290fe374efSJ-Alves TE_HOB_LIST = 0x3 2300fe374efSJ-Alves tlc_add_hob = f"\t$(Q)poetry run tlc add --entry {TE_HOB_LIST} {hob_path} {pkg}" if hob_path is not None else "" 2310fe374efSJ-Alves return f''' 2320fe374efSJ-Alves{pkg}: {sp_dtb} {sp_img} 2330fe374efSJ-Alves\t$(Q)echo Generating {pkg} 2340fe374efSJ-Alves\t$(Q)$(TLCTOOL) create --size {get_size(sp_node)} --entry {TE_FFA_MANIFEST} {sp_dtb} {pkg} --align 12 2350fe374efSJ-Alves\t$(Q)$(TLCTOOL) add --entry {TE_SP_BINARY} {sp_img} {pkg} 2360fe374efSJ-Alves''' 2370fe374efSJ-Alves 238a96a07bfSJ-Alves@SpSetupActions.sp_action 2390fe374efSJ-Alvesdef gen_partition_pkg(sp_layout, sp, args :dict): 240822c7279SJ-Alves ''' Generate Sp Pkgs rules. ''' 2410fe374efSJ-Alves pkg = get_sp_pkg(sp, args) 2420fe374efSJ-Alves 243822c7279SJ-Alves sp_dtb_name = os.path.basename(get_file_from_layout(sp_layout[sp]["pm"]))[:-1] + "b" 244a96a07bfSJ-Alves sp_dtb = os.path.join(args["out_dir"], f"fdts/{sp_dtb_name}") 2454daeaf34SJens Wiklander sp_img = get_sp_img_full_path(sp_layout[sp], args) 246822c7279SJ-Alves 247822c7279SJ-Alves # Do not generate rule if already there. 2480fe374efSJ-Alves if is_line_in_sp_gen(f'{pkg}:', args): 249822c7279SJ-Alves return args 250822c7279SJ-Alves 2510fe374efSJ-Alves # This should include all packages of all kinds. 2520fe374efSJ-Alves write_to_sp_mk_gen(f"SP_PKGS += {pkg}\n", args) 2530fe374efSJ-Alves package_type = sp_layout[sp]["package"] if "package" in sp_layout[sp] else "sp_pkg" 2540fe374efSJ-Alves 2550fe374efSJ-Alves if package_type == "sp_pkg": 2560fe374efSJ-Alves partition_pkg_rule = generate_sp_pkg(sp_layout[sp], pkg, sp_img, sp_dtb) 2570fe374efSJ-Alves elif package_type == "tl_pkg": 2580fe374efSJ-Alves partition_pkg_rule = generate_tl_pkg(sp_layout[sp], pkg, sp_img, sp_dtb) 2590fe374efSJ-Alves else: 2600fe374efSJ-Alves raise ValueError(f"Specified invalid pkg type {package_type}") 2610fe374efSJ-Alves 2620fe374efSJ-Alves write_to_sp_mk_gen(partition_pkg_rule, args) 263a96a07bfSJ-Alves return args 264a96a07bfSJ-Alves 265a96a07bfSJ-Alves@SpSetupActions.sp_action(global_action=True, exec_order=1) 266a96a07bfSJ-Alvesdef check_dualroot(sp_layout, _, args :dict): 267a96a07bfSJ-Alves ''' Validate the amount of SPs from SiP and Platform owners. ''' 268a96a07bfSJ-Alves if not args.get("dualroot"): 269a96a07bfSJ-Alves return args 270a96a07bfSJ-Alves args["split"] = int(MAX_SP / 2) 271a96a07bfSJ-Alves owners = [sp_layout[sp].get("owner") for sp in sp_layout] 272a96a07bfSJ-Alves args["plat_max_count"] = owners.count("Plat") 2730fe374efSJ-Alves 274a96a07bfSJ-Alves # If it is owned by the platform owner, it is assigned to the SiP. 275a96a07bfSJ-Alves args["sip_max_count"] = len(sp_layout.keys()) - args["plat_max_count"] 276a96a07bfSJ-Alves if args["sip_max_count"] > args["split"] or args["sip_max_count"] > args["split"]: 277a96a07bfSJ-Alves print(f"WARN: SiP Secure Partitions should not be more than {args['split']}") 278a96a07bfSJ-Alves # Counters for gen_crt_args. 279a96a07bfSJ-Alves args["sip_count"] = 1 280a96a07bfSJ-Alves args["plat_count"] = 1 281a96a07bfSJ-Alves return args 282a96a07bfSJ-Alves 283a96a07bfSJ-Alves@SpSetupActions.sp_action 284a96a07bfSJ-Alvesdef gen_crt_args(sp_layout, sp, args :dict): 285a96a07bfSJ-Alves ''' Append CRT_ARGS. ''' 286a96a07bfSJ-Alves # If "dualroot" is configured, 'sp_pkg_idx' depends on whether the SP is owned 287a96a07bfSJ-Alves # by the "SiP" or the "Plat". 288a96a07bfSJ-Alves if args.get("dualroot"): 289a96a07bfSJ-Alves # If the owner is not specified as "Plat", default to "SiP". 290a96a07bfSJ-Alves if sp_layout[sp].get("owner") == "Plat": 291a96a07bfSJ-Alves if args["plat_count"] > args["plat_max_count"]: 292a96a07bfSJ-Alves raise ValueError("plat_count can't surpass plat_max_count in args.") 293a96a07bfSJ-Alves sp_pkg_idx = args["plat_count"] + args["split"] 294a96a07bfSJ-Alves args["plat_count"] += 1 2951e7528ecSRuari Phipps else: 296a96a07bfSJ-Alves if args["sip_count"] > args["sip_max_count"]: 297a96a07bfSJ-Alves raise ValueError("sip_count can't surpass sip_max_count in args.") 298a96a07bfSJ-Alves sp_pkg_idx = args["sip_count"] 299a96a07bfSJ-Alves args["sip_count"] += 1 300a96a07bfSJ-Alves else: 301a96a07bfSJ-Alves sp_pkg_idx = [k for k in sp_layout.keys()].index(sp) + 1 302a96a07bfSJ-Alves write_to_sp_mk_gen(f"CRT_ARGS += --sp-pkg{sp_pkg_idx} {get_sp_pkg(sp, args)}\n", args) 303a96a07bfSJ-Alves return args 3041e7528ecSRuari Phipps 305a96a07bfSJ-Alves@SpSetupActions.sp_action 306a96a07bfSJ-Alvesdef gen_fiptool_args(sp_layout, sp, args :dict): 307a96a07bfSJ-Alves ''' Generate arguments for the FIP Tool. ''' 30820629b31SKarl Meakin uuid_std = get_uuid(sp_layout, sp, args) 309a96a07bfSJ-Alves write_to_sp_mk_gen(f"FIP_ARGS += --blob uuid={str(uuid_std)},file={get_sp_pkg(sp, args)}\n", args) 310a96a07bfSJ-Alves return args 311ce2b1ec6SManish Pandey 31220629b31SKarl Meakin@SpSetupActions.sp_action 31320629b31SKarl Meakindef gen_fconf_fragment(sp_layout, sp, args: dict): 31420629b31SKarl Meakin ''' Generate the fconf fragment file''' 31520629b31SKarl Meakin with open(args["fconf_fragment"], "a") as f: 31620629b31SKarl Meakin uuid = get_uuid(sp_layout, sp, args) 31720629b31SKarl Meakin owner = "Plat" if sp_layout[sp].get("owner") == "Plat" else "SiP" 31820629b31SKarl Meakin 31920629b31SKarl Meakin if "physical-load-address" in sp_layout[sp].keys(): 32020629b31SKarl Meakin load_address = sp_layout[sp]["physical-load-address"] 32120629b31SKarl Meakin else: 32220629b31SKarl Meakin load_address = get_load_address(sp_layout, sp, args) 32320629b31SKarl Meakin 32404e7f808SJ-Alves if load_address is not None: 32520629b31SKarl Meakin f.write( 32620629b31SKarl Meakinf'''\ 32720629b31SKarl Meakin{sp} {{ 32820629b31SKarl Meakin uuid = "{uuid}"; 32920629b31SKarl Meakin load-address = <{load_address}>; 33020629b31SKarl Meakin owner = "{owner}"; 33120629b31SKarl Meakin}}; 33220629b31SKarl Meakin 33320629b31SKarl Meakin''') 33404e7f808SJ-Alves else: 33504e7f808SJ-Alves print("Warning: No load-address was found in the SP manifest.") 33604e7f808SJ-Alves 33720629b31SKarl Meakin return args 33820629b31SKarl Meakin 339a96a07bfSJ-Alvesdef init_sp_actions(sys): 340a96a07bfSJ-Alves # Initialize arguments for the SP actions framework 341a96a07bfSJ-Alves args = {} 342a96a07bfSJ-Alves args["sp_gen_mk"] = os.path.abspath(sys.argv[1]) 34320629b31SKarl Meakin sp_layout_file = os.path.abspath(sys.argv[2]) 344a96a07bfSJ-Alves args["sp_layout_dir"] = os.path.dirname(sp_layout_file) 345a96a07bfSJ-Alves args["out_dir"] = os.path.abspath(sys.argv[3]) 346a96a07bfSJ-Alves args["dualroot"] = sys.argv[4] == "dualroot" 34720629b31SKarl Meakin args["fconf_fragment"] = os.path.abspath(sys.argv[5]) 34820629b31SKarl Meakin 34920629b31SKarl Meakin 35020629b31SKarl Meakin with open(sp_layout_file) as json_file: 35120629b31SKarl Meakin sp_layout = json.load(json_file) 352a96a07bfSJ-Alves #Clear content of file "sp_gen.mk". 353a96a07bfSJ-Alves with open(args["sp_gen_mk"], "w"): 354a96a07bfSJ-Alves None 35520629b31SKarl Meakin #Clear content of file "fconf_fragment". 35620629b31SKarl Meakin with open(args["fconf_fragment"], "w"): 35720629b31SKarl Meakin None 35820629b31SKarl Meakin 359a96a07bfSJ-Alves return args, sp_layout 36007c44475SManish Pandey 361a96a07bfSJ-Alvesif __name__ == "__main__": 362a96a07bfSJ-Alves args, sp_layout = init_sp_actions(sys) 363a96a07bfSJ-Alves SpSetupActions.run_actions(sp_layout, args) 364