blob: 3159cd43db15e5465d44ddffeff0dc8b2bf8e9ff [file] [log] [blame]
Brad Bishopbec4ebc2022-08-03 09:55:16 -04001# Image class to write .fvpconf files for use with runfvp. If this is desired
2# then add fvpboot to IMAGE_CLASSES, and set the variables below in your machine
3# configuration as appropriate.
4
5# Name of recipe providing FVP executable. If unset then the executable must be installed on the host.
6FVP_PROVIDER ?= ""
7# Name of FVP executable to run
8FVP_EXE ?= ""
9# Flags for --parameter/-C
10FVP_CONFIG ?= ""
11# Flags for --data
12FVP_DATA ?= ""
13# Flags for --application
14FVP_APPLICATIONS ?= ""
15# Flags to name serial terminals. Flag name is the terminal id (such as
16# terminal_0), value is a human-readable name. If the name is not set
17# then runfvp will hide the terminal.
18FVP_TERMINALS ?= ""
19# What terminal should be considered the primary console
20FVP_CONSOLE ?= ""
21# Flags for console names, as they appear in the FVP output. Flag name is an
22# application-specific id for the console for use in test cases
23FVP_CONSOLES[default] ?= "${FVP_CONSOLE}"
24# Arbitrary extra arguments
25FVP_EXTRA_ARGS ?= ""
Patrick Williams8dd68482022-10-04 07:57:18 -050026# Bitbake variables to pass to the FVP environment
Andrew Geisslerea144b032023-01-27 16:03:57 -060027FVP_ENV_PASSTHROUGH ?= "FASTSIM_DISABLE_TA ARMLMD_LICENSE_FILE"
28FVP_ENV_PASSTHROUGH[vardeps] = "${FVP_ENV_PASSTHROUGH}"
Andrew Geissler517393d2023-01-13 08:55:19 -060029# Disable timing annotation by default
30FASTSIM_DISABLE_TA ?= "1"
Brad Bishopbec4ebc2022-08-03 09:55:16 -040031
32EXTRA_IMAGEDEPENDS += "${FVP_PROVIDER}"
33
Patrick Williams92b42cb2022-09-03 06:53:57 -050034IMAGE_CLASSES += "image-artifact-names"
Brad Bishopbec4ebc2022-08-03 09:55:16 -040035
36IMAGE_POSTPROCESS_COMMAND += "do_write_fvpboot_conf;"
37python do_write_fvpboot_conf() {
38 # Note that currently this JSON file is in development and the format may
39 # change at any point, so it should always be used with a matching runfvp.
40
41 import json, shlex
42
43 if not d.getVar("FVP_EXE"):
44 return
45
46 conffile = os.path.join(d.getVar("IMGDEPLOYDIR"), d.getVar("IMAGE_NAME") + ".fvpconf")
47 conffile_link = os.path.join(d.getVar("IMGDEPLOYDIR"), d.getVar("IMAGE_LINK_NAME") + ".fvpconf")
48
49 data = {}
50 provider = d.getVar("FVP_PROVIDER")
51 if provider:
52 data["provider"] = provider
53 data["fvp-bindir"] = os.path.join(d.getVar("COMPONENTS_DIR"),
54 d.getVar("BUILD_ARCH"),
55 provider,
56 "usr", "bin")
57
58 def getFlags(varname):
59 flags = d.getVarFlags(varname)
60 # For unexplained reasons, getVarFlags() returns None if there are no flags
61 if flags is None:
62 return {}
63 # For other reasons, you can't pass expand=True
64 return {key: d.expand(value) for key, value in flags.items()}
65
66 data["exe"] = d.getVar("FVP_EXE")
67 data["parameters"] = getFlags("FVP_CONFIG")
68 data["data"] = shlex.split(d.getVar("FVP_DATA") or "")
69 data["applications"] = getFlags("FVP_APPLICATIONS")
70 data["consoles"] = getFlags("FVP_CONSOLES")
71 data["terminals"] = getFlags("FVP_TERMINALS")
72 data["args"] = shlex.split(d.getVar("FVP_EXTRA_ARGS") or "")
73
Patrick Williams8dd68482022-10-04 07:57:18 -050074 data["env"] = {}
75 for var in d.getVar("FVP_ENV_PASSTHROUGH").split():
Andrew Geisslerea144b032023-01-27 16:03:57 -060076 if d.getVar(var) is not None:
77 data["env"][var] = d.getVar(var)
Patrick Williams8dd68482022-10-04 07:57:18 -050078
Brad Bishopbec4ebc2022-08-03 09:55:16 -040079 os.makedirs(os.path.dirname(conffile), exist_ok=True)
80 with open(conffile, "wt") as f:
81 json.dump(data, f)
82
83 if conffile_link != conffile:
84 if os.path.lexists(conffile_link):
85 os.remove(conffile_link)
86 os.symlink(os.path.basename(conffile), conffile_link)
87}
88
89def fvpboot_vars(d):
90 vars = ['DEPLOY_DIR_IMAGE', 'IMAGE_NAME', 'IMAGE_LINK_NAME', 'COMPONENTS_DIR', 'BUILD_ARCH']
91 vars.extend((k for k in d.keys() if k.startswith('FVP_')))
92 return " ".join(vars)
93
94do_write_fvpboot_conf[vardeps] += "${@fvpboot_vars(d)}"