1 # SPDX-License-Identifier: GPL-2.0
2 # Copyright (c) 2015 Stephen Warren
3 # Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
6 Logic to interact with the sandbox port of U-Boot, running as a sub-process.
10 from u_boot_spawn import Spawn
11 from u_boot_console_base import ConsoleBase
13 class ConsoleSandbox(ConsoleBase):
14 """Represents a connection to a sandbox U-Boot console, executed as a sub-
17 def __init__(self, log, config):
18 """Initialize a U-Boot console connection.
21 log: A multiplexed_log.Logfile instance.
22 config: A "configuration" object as defined in conftest.py.
28 super(ConsoleSandbox, self).__init__(log, config, max_fifo_fill=1024)
29 self.sandbox_flags = []
33 """Connect to a fresh U-Boot instance.
35 A new sandbox process is created, so that U-Boot begins running from
42 A u_boot_spawn.Spawn object that is attached to U-Boot.
45 bcfg = self.config.buildconfig
46 config_spl = bcfg.get('config_spl', 'n') == 'y'
47 config_vpl = bcfg.get('config_vpl', 'n') == 'y'
49 # Run TPL first, which runs VPL
50 fname = '/tpl/u-boot-tpl'
52 fname = '/spl/u-boot-spl' if config_spl else '/u-boot'
55 if self.config.gdbserver:
56 cmd += ['gdbserver', self.config.gdbserver]
57 cmd += [self.config.build_dir + fname, '-v']
59 cmd += ['-d', self.config.dtb]
60 cmd += self.sandbox_flags
61 return Spawn(cmd, cwd=self.config.source_dir)
63 def restart_uboot_with_flags(self, flags, expect_reset=False, use_dtb=True):
64 """Run U-Boot with the given command-line flags
67 flags: List of flags to pass, each a string
68 expect_reset: Boolean indication whether this boot is expected
69 to be reset while the 1st boot process after main boot before
70 prompt. False by default.
71 use_dtb: True to use a device tree file, False to run without one
74 A u_boot_spawn.Spawn object that is attached to U-Boot.
78 self.sandbox_flags = flags
79 self.use_dtb = use_dtb
80 return self.restart_uboot(expect_reset)
82 self.sandbox_flags = []
86 """Send a specific Unix signal to the sandbox process.
89 sig: The Unix signal to send to the process.
95 self.log.action('kill %d' % sig)
98 def validate_exited(self):
99 """Determine whether the sandbox process has exited.
101 If required, this function waits a reasonable time for the process to
108 Boolean indicating whether the process has exited.
114 ret = not p.isalive()