meta-arm.lists.yoctoproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/7] arm-bsp/fvp-base: tell FVP to exit on shutdown
@ 2021-09-27 12:55 Ross Burton
  2021-09-27 12:55 ` [PATCH 2/7] arm-bsp/fvp-base: enable user-mode networking in runfvp Ross Burton
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Ross Burton @ 2021-09-27 12:55 UTC (permalink / raw)
  To: meta-arm

Pass bp.ve_sysregs.exit_on_shutdown=1 so that the FVP exits if the
emulated machine shutsdown, which is typically the desired behaviour.

Change-Id: Id2f92df4af67ca5cadc645948eccf9c93af3f8f9
Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 meta-arm-bsp/conf/machine/fvp-base.conf | 1 +
 1 file changed, 1 insertion(+)

diff --git a/meta-arm-bsp/conf/machine/fvp-base.conf b/meta-arm-bsp/conf/machine/fvp-base.conf
index b74daf67..e43c6a01 100644
--- a/meta-arm-bsp/conf/machine/fvp-base.conf
+++ b/meta-arm-bsp/conf/machine/fvp-base.conf
@@ -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"
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/7] arm-bsp/fvp-base: enable user-mode networking in runfvp
  2021-09-27 12:55 [PATCH 1/7] arm-bsp/fvp-base: tell FVP to exit on shutdown Ross Burton
@ 2021-09-27 12:55 ` Ross Burton
  2021-09-27 12:55 ` [PATCH 3/7] arm/fvpboot: clean up fvpboot_vars Ross Burton
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Ross Burton @ 2021-09-27 12:55 UTC (permalink / raw)
  To: meta-arm

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.

Change-Id: I0b610df87c7dd2c8e3e213daaa967618babbdc7c
Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 meta-arm-bsp/conf/machine/fvp-base.conf | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/meta-arm-bsp/conf/machine/fvp-base.conf b/meta-arm-bsp/conf/machine/fvp-base.conf
index e43c6a01..06a8bd93 100644
--- a/meta-arm-bsp/conf/machine/fvp-base.conf
+++ b/meta-arm-bsp/conf/machine/fvp-base.conf
@@ -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"
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/7] arm/fvpboot: clean up fvpboot_vars
  2021-09-27 12:55 [PATCH 1/7] arm-bsp/fvp-base: tell FVP to exit on shutdown Ross Burton
  2021-09-27 12:55 ` [PATCH 2/7] arm-bsp/fvp-base: enable user-mode networking in runfvp Ross Burton
@ 2021-09-27 12:55 ` Ross Burton
  2021-09-27 12:55 ` [PATCH 4/7] runfvp: handle control-c cleanly Ross Burton
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Ross Burton @ 2021-09-27 12:55 UTC (permalink / raw)
  To: meta-arm

Change-Id: I43a04cd1b977fbf7d0050b2ab9e7509c0439dca5
Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 meta-arm/classes/fvpboot.bbclass | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/meta-arm/classes/fvpboot.bbclass b/meta-arm/classes/fvpboot.bbclass
index 18a9d686..de66d7ce 100644
--- a/meta-arm/classes/fvpboot.bbclass
+++ b/meta-arm/classes/fvpboot.bbclass
@@ -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)}"
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/7] runfvp: handle control-c cleanly
  2021-09-27 12:55 [PATCH 1/7] arm-bsp/fvp-base: tell FVP to exit on shutdown Ross Burton
  2021-09-27 12:55 ` [PATCH 2/7] arm-bsp/fvp-base: enable user-mode networking in runfvp Ross Burton
  2021-09-27 12:55 ` [PATCH 3/7] arm/fvpboot: clean up fvpboot_vars Ross Burton
@ 2021-09-27 12:55 ` Ross Burton
  2021-09-27 12:56 ` [PATCH 5/7] runfvp: refactor argument parsing Ross Burton
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Ross Burton @ 2021-09-27 12:55 UTC (permalink / raw)
  To: meta-arm

If the script receives control-c, don't display the stack trace.

Change-Id: Id0ebf9476ecd685302723fde6a36c2e899d0f3eb
Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 scripts/runfvp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/scripts/runfvp b/scripts/runfvp
index be047689..52d8f20b 100755
--- a/scripts/runfvp
+++ b/scripts/runfvp
@@ -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
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 5/7] runfvp: refactor argument parsing
  2021-09-27 12:55 [PATCH 1/7] arm-bsp/fvp-base: tell FVP to exit on shutdown Ross Burton
                   ` (2 preceding siblings ...)
  2021-09-27 12:55 ` [PATCH 4/7] runfvp: handle control-c cleanly Ross Burton
@ 2021-09-27 12:56 ` Ross Burton
  2021-09-27 12:56 ` [PATCH 6/7] runfvp: ensure the default terminal is usable Ross Burton
  2021-09-27 12:56 ` [PATCH 7/7] runfvp: exit cleanly if tinfoil cannot be imported Ross Burton
  5 siblings, 0 replies; 7+ messages in thread
From: Ross Burton @ 2021-09-27 12:56 UTC (permalink / raw)
  To: meta-arm

No behavioural changes, just cleanup.

Change-Id: I04d82512493a2f90e810198e520f672284cd3eb2
Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 scripts/runfvp | 41 ++++++++++++++++++++++++++++-------------
 1 file changed, 28 insertions(+), 13 deletions(-)

diff --git a/scripts/runfvp b/scripts/runfvp
index 52d8f20b..0b70c56b 100755
--- a/scripts/runfvp
+++ b/scripts/runfvp
@@ -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
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 6/7] runfvp: ensure the default terminal is usable
  2021-09-27 12:55 [PATCH 1/7] arm-bsp/fvp-base: tell FVP to exit on shutdown Ross Burton
                   ` (3 preceding siblings ...)
  2021-09-27 12:56 ` [PATCH 5/7] runfvp: refactor argument parsing Ross Burton
@ 2021-09-27 12:56 ` Ross Burton
  2021-09-27 12:56 ` [PATCH 7/7] runfvp: exit cleanly if tinfoil cannot be imported Ross Burton
  5 siblings, 0 replies; 7+ messages in thread
From: Ross Burton @ 2021-09-27 12:56 UTC (permalink / raw)
  To: meta-arm

Pick 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.

Change-Id: Ib3e7c32917725f404a171248549b6f9c0afe8158
Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 scripts/runfvp | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/scripts/runfvp b/scripts/runfvp
index 0b70c56b..e40bad0d 100755
--- a/scripts/runfvp
+++ b/scripts/runfvp
@@ -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 ]"
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 7/7] runfvp: exit cleanly if tinfoil cannot be imported
  2021-09-27 12:55 [PATCH 1/7] arm-bsp/fvp-base: tell FVP to exit on shutdown Ross Burton
                   ` (4 preceding siblings ...)
  2021-09-27 12:56 ` [PATCH 6/7] runfvp: ensure the default terminal is usable Ross Burton
@ 2021-09-27 12:56 ` Ross Burton
  5 siblings, 0 replies; 7+ messages in thread
From: Ross Burton @ 2021-09-27 12:56 UTC (permalink / raw)
  To: meta-arm

If bb.tinfoil cannot be imported, display a nice error instead of a
backtrace.

Change-Id: I20dab9dfdbd57c8e90c8321072bab4f70b8ace47
Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 scripts/runfvp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/scripts/runfvp b/scripts/runfvp
index e40bad0d..e9654268 100755
--- a/scripts/runfvp
+++ b/scripts/runfvp
@@ -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
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-09-27 12:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-27 12:55 [PATCH 1/7] arm-bsp/fvp-base: tell FVP to exit on shutdown Ross Burton
2021-09-27 12:55 ` [PATCH 2/7] arm-bsp/fvp-base: enable user-mode networking in runfvp Ross Burton
2021-09-27 12:55 ` [PATCH 3/7] arm/fvpboot: clean up fvpboot_vars Ross Burton
2021-09-27 12:55 ` [PATCH 4/7] runfvp: handle control-c cleanly Ross Burton
2021-09-27 12:56 ` [PATCH 5/7] runfvp: refactor argument parsing Ross Burton
2021-09-27 12:56 ` [PATCH 6/7] runfvp: ensure the default terminal is usable Ross Burton
2021-09-27 12:56 ` [PATCH 7/7] runfvp: exit cleanly if tinfoil cannot be imported Ross Burton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).