1 # SPDX-License-Identifier: GPL-2.0
2 # Copyright (c) 2015 Stephen Warren
3 # Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
5 # Logic to interact with the sandbox port of U-Boot, running as a sub-process.
8 from u_boot_spawn import Spawn
9 from u_boot_console_base import ConsoleBase
11 class ConsoleSandbox(ConsoleBase):
12 """Represents a connection to a sandbox U-Boot console, executed as a sub-
15 def __init__(self, log, config):
16 """Initialize a U-Boot console connection.
19 log: A multiplexed_log.Logfile instance.
20 config: A "configuration" object as defined in conftest.py.
26 super(ConsoleSandbox, self).__init__(log, config, max_fifo_fill=1024)
27 self.sandbox_flags = []
30 """Connect to a fresh U-Boot instance.
32 A new sandbox process is created, so that U-Boot begins running from
39 A u_boot_spawn.Spawn object that is attached to U-Boot.
42 bcfg = self.config.buildconfig
43 config_spl = bcfg.get('config_spl', 'n') == 'y'
44 fname = '/spl/u-boot-spl' if config_spl else '/u-boot'
47 if self.config.gdbserver:
48 cmd += ['gdbserver', self.config.gdbserver]
50 self.config.build_dir + fname,
55 cmd += self.sandbox_flags
56 return Spawn(cmd, cwd=self.config.source_dir)
58 def restart_uboot_with_flags(self, flags):
59 """Run U-Boot with the given command-line flags
62 flags: List of flags to pass, each a string
65 A u_boot_spawn.Spawn object that is attached to U-Boot.
69 self.sandbox_flags = flags
70 return self.restart_uboot()
72 self.sandbox_flags = []
75 """Send a specific Unix signal to the sandbox process.
78 sig: The Unix signal to send to the process.
84 self.log.action('kill %d' % sig)
87 def validate_exited(self):
88 """Determine whether the sandbox process has exited.
90 If required, this function waits a reasonable time for the process to
97 Boolean indicating whether the process has exited.
103 ret = not p.isalive()