arm-bsp/fvp-base: tell FVP to exit on shutdown
PATCH 1/7 arm-bsp/fvp-base: tell FVP to exit on shutdown
Pass bp.ve_sysregs.exit_on_shutdown=1 so that the FVP exits if the emulated machine shutsdown, which is typically the desired behaviour.
--- meta-arm-bsp/conf/machine/fvp-base.conf | 1 + 1 file changed, 1 insertion(+)
meta-arm-bsp/conf/machine/fvp-base.conf +1 -0
@@ -18,6 +18,7 @@ KERNEL_DEVICETREE = "arm/fvp-base-revc.dtb" FVP_PROVIDER ?= "fvp-base-a-aem-native" FVP_EXE ?= "FVP_Base_RevC-2xAEMvA" +FVP_CONFIG[bp.ve_sysregs.exit_on_shutdown] ?= "1" FVP_CONFIG[cache_state_modelled] ?= "0" FVP_CONFIG[bp.secureflashloader.fname] ?= "${DEPLOY_DIR_IMAGE}/bl1-fvp.bin" FVP_CONFIG[bp.flashloader0.fname] ?= "${DEPLOY_DIR_IMAGE}/fip-fvp.bin"
Signature · 1 line
2.25.1
PATCH 2/7 arm-bsp/fvp-base: enable user-mode networking in runfvp
Enable user-mode networking with virtio out of the box. This way port forwarding can be configured easily without needing to setup host tap ports.
Moving forward this may be controlled more by runfvp with the machine configuration simply saying what configuration parameter to use (in this case, bp.virtio_net), but this is a good starting point to iterate from.
--- meta-arm-bsp/conf/machine/fvp-base.conf | 2 ++ 1 file changed, 2 insertions(+)
meta-arm-bsp/conf/machine/fvp-base.conf +2 -0
@@ -19,6 +19,8 @@ KERNEL_DEVICETREE = "arm/fvp-base-revc.dtb" FVP_PROVIDER ?= "fvp-base-a-aem-native" FVP_EXE ?= "FVP_Base_RevC-2xAEMvA" FVP_CONFIG[bp.ve_sysregs.exit_on_shutdown] ?= "1" +FVP_CONFIG[bp.virtio_net.enabled] ?= "1" +FVP_CONFIG[bp.virtio_net.hostbridge.userNetworking] ?= "1" FVP_CONFIG[cache_state_modelled] ?= "0" FVP_CONFIG[bp.secureflashloader.fname] ?= "${DEPLOY_DIR_IMAGE}/bl1-fvp.bin" FVP_CONFIG[bp.flashloader0.fname] ?= "${DEPLOY_DIR_IMAGE}/fip-fvp.bin"
Signature · 1 line
2.25.1
PATCH 3/7 arm/fvpboot: clean up fvpboot_vars
In reply to Ross Burton--- meta-arm/classes/fvpboot.bbclass | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
meta-arm/classes/fvpboot.bbclass +5 -4
@@ -74,7 +74,8 @@ python do_write_fvpboot_conf() { } def fvpboot_vars(d): - build_vars = ['DEPLOY_DIR_IMAGE', 'IMAGE_NAME', 'IMAGE_LINK_NAME', - 'COMPONENTS_DIR', 'BUILD_ARCH'] - return build_vars + [k for k in d.keys() if k.startswith('FVP_')] -do_write_fvpboot_conf[vardeps] += "${@' '.join(fvpboot_vars(d))}" + vars = ['DEPLOY_DIR_IMAGE', 'IMAGE_NAME', 'IMAGE_LINK_NAME', 'COMPONENTS_DIR', 'BUILD_ARCH'] + vars.extend((k for k in d.keys() if k.startswith('FVP_'))) + return " ".join(vars) + +do_write_fvpboot_conf[vardeps] += "${@fvpboot_vars(d)}"
Signature · 1 line
2.25.1
PATCH 4/7 runfvp: handle control-c cleanly
In reply to Ross BurtonIf the script receives control-c, don't display the stack trace.
--- scripts/runfvp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
scripts/runfvp +4 -1
@@ -164,4 +164,7 @@ def runfvp(args): sys.exit(subprocess.run(cli).returncode) if __name__ == "__main__": - runfvp(sys.argv) + try: + runfvp(sys.argv) + except KeyboardInterrupt: + pass
Signature · 1 line
2.25.1
PATCH 5/7 runfvp: refactor argument parsing
In reply to Ross BurtonNo behavioural changes, just cleanup.
--- scripts/runfvp | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-)
scripts/runfvp +28 -13
@@ -36,7 +36,7 @@ def get_image_directory(machine=None): return pathlib.Path(image_dir) -def runfvp(args): +def parse_args(arguments): import argparse parser = argparse.ArgumentParser(description="Run images in a FVP")
@@ -48,24 +48,28 @@ def runfvp(args): parser.usage = f"{parser.format_usage().strip()} -- [ arguments passed to FVP ]" # TODO option for telnet vs netcat - try: - i = sys.argv.index("--") - arguments = sys.argv[1:i] - fvp_args = sys.argv[i+1:] - except ValueError: - arguments = sys.argv[1:] + # If the arguments contains -- then everything after it should be passed to the FVP binary directly. + if "--" in arguments: + i = arguments.index("--") + fvp_args = arguments[i+1:] + arguments = arguments[:i] + else: fvp_args = [] args = parser.parse_args(args=arguments) logging.basicConfig(level=args.verbose and logging.DEBUG or logging.WARNING) - logger.debug(f"Parsed arguments are {vars(args)}") # If we're hooking up the console, don't start any terminals if args.console: args.terminals = "none" + logger.debug(f"Parsed arguments: {vars(args)}") + logger.debug(f"FVP arguments: {fvp_args}") + return args, fvp_args + +def find_config(args): if args.config and os.path.exists(args.config): - config_file = args.config + return args.config else: image_dir = get_image_directory(args.config) # All .fvpconf configuration files
@@ -77,8 +81,10 @@ def runfvp(args): sys.exit(1) # Sorted by modification time configs = sorted(configs, key=lambda p: p.stat().st_mtime) - config_file = configs[-1] + return configs[-1] + +def load_config(config_file): logger.debug(f"Loading {config_file}") with open(config_file) as f: config = json.load(f)
@@ -100,6 +106,9 @@ def runfvp(args): logger.error("Required value FVP_EXE not set in machine configuration") sys.exit(1) + return config + +def parse_config(args, config): cli = [] if config["fvp-bindir"]: cli.append(os.path.join(config["fvp-bindir"], config["exe"]))
@@ -128,10 +137,16 @@ def runfvp(args): cli.extend(config["args"]) - # Finally add the user's extra arguments - cli.extend(fvp_args) + return cli +def runfvp(cli_args): + args, fvp_args = parse_args(cli_args) + config_file = find_config(args) + config = load_config(config_file) + cli = parse_config(args, config) + cli.extend(fvp_args) logger.debug(f"Constructed FVP call: {cli}") + if args.console: expected_terminal = config["console"] if not expected_terminal:
@@ -165,6 +180,6 @@ def runfvp(args): if __name__ == "__main__": try: - runfvp(sys.argv) + runfvp(sys.argv[1:]) except KeyboardInterrupt: pass
Signature · 1 line
2.25.1
PATCH 6/7 runfvp: ensure the default terminal is usable
In reply to Ross BurtonPick a default terminal which will actually work, instead of defaulting to xterm even if xterm isn't installed.
Also show the default in the --help output.
--- scripts/runfvp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
scripts/runfvp +11 -1
@@ -19,6 +19,16 @@ terminal_map = { # TODO more terminals } +def get_default_terminal(): + import shutil + import shlex + + for terminal in "xterm",: + command = shlex.split(terminal_map[terminal])[0] + if shutil.which(command): + return terminal + return "none" + def get_image_directory(machine=None): """ Get the DEPLOY_DIR_IMAGE for the specified machine
@@ -42,7 +52,7 @@ def parse_args(arguments): parser = argparse.ArgumentParser(description="Run images in a FVP") parser.add_argument("config", nargs="?", help="Machine name or path to .fvpconf file") group = parser.add_mutually_exclusive_group() - group.add_argument("-t", "--terminals", choices=terminal_map.keys(), default="xterm", help="Automatically start terminals") + group.add_argument("-t", "--terminals", choices=terminal_map.keys(), default=get_default_terminal(), help="Automatically start terminals (default: %(default)s)") group.add_argument("-c", "--console", action="store_true", help="Attach the first uart to stdin/stdout") parser.add_argument("--verbose", action="store_true", help="Output verbose logging") parser.usage = f"{parser.format_usage().strip()} -- [ arguments passed to FVP ]"
Signature · 1 line
2.25.1
PATCH 7/7 runfvp: exit cleanly if tinfoil cannot be imported
In reply to Ross BurtonIf bb.tinfoil cannot be imported, display a nice error instead of a backtrace.
--- scripts/runfvp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
scripts/runfvp +5 -1
@@ -34,7 +34,11 @@ def get_image_directory(machine=None): Get the DEPLOY_DIR_IMAGE for the specified machine (or the configured machine if not set). """ - import bb.tinfoil + try: + import bb.tinfoil + except ImportError: + logger.error("Cannot connect to BitBake, did you oe-init-build-env?") + sys.exit(1) if machine: os.environ["MACHINE"] = machine
Signature · 1 line
2.25.1