From 15ab77c2034e243f2a49b6908428779a800052df Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 9 Nov 2019 09:39:01 +0100 Subject: [PATCH 01/10] sandbox: add missing compatible property in device tree In the device tree UEFI unit test the compatible property of the device is read. Provide the missing property. Signed-off-by: Heinrich Schuchardt --- arch/sandbox/dts/sandbox.dts | 1 + arch/sandbox/dts/sandbox64.dts | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts index f1637c80f6..4dd82f6a32 100644 --- a/arch/sandbox/dts/sandbox.dts +++ b/arch/sandbox/dts/sandbox.dts @@ -6,6 +6,7 @@ #address-cells = <1>; #size-cells = <1>; model = "sandbox"; + compatible = "sandbox"; aliases { i2c0 = &i2c_0; diff --git a/arch/sandbox/dts/sandbox64.dts b/arch/sandbox/dts/sandbox64.dts index 37a5539ff4..5c95cee9d7 100644 --- a/arch/sandbox/dts/sandbox64.dts +++ b/arch/sandbox/dts/sandbox64.dts @@ -6,6 +6,7 @@ #address-cells = <2>; #size-cells = <2>; model = "sandbox"; + compatible = "sandbox"; aliases { i2c0 = &i2c_0; From 5e5c785e34a18a12faedc93829e2a88ef22ade2a Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 9 Nov 2019 10:59:02 +0100 Subject: [PATCH 02/10] serial: sandbox: support Unicode Due to a conversion error the sandbox does not accept byte values 0x80-0xff from the keyboard. The UEFI extended text input unit test requires Unicode support. Use unsigned char for the serial buffer. Signed-off-by: Heinrich Schuchardt Reviewed-by: Andy Shevchenko --- drivers/serial/sandbox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/serial/sandbox.c b/drivers/serial/sandbox.c index 2f7bc24887..1af5cc12f3 100644 --- a/drivers/serial/sandbox.c +++ b/drivers/serial/sandbox.c @@ -33,7 +33,7 @@ DECLARE_GLOBAL_DATA_PTR; * serial_buf_write == serial_buf_read -> empty buffer * (serial_buf_write + 1) % 16 == serial_buf_read -> full buffer */ -static char serial_buf[16]; +static unsigned char serial_buf[16]; static unsigned int serial_buf_write; static unsigned int serial_buf_read; From 4251fbc6fb19cc7406ea450145d307d4b2ec19e9 Mon Sep 17 00:00:00 2001 From: Cristian Ciocaltea Date: Sun, 24 Nov 2019 22:30:26 +0200 Subject: [PATCH 03/10] buildman: Improve [make-flags] section parser to allow quoted strings The parser responsible for the '[make-flags]' section in the '.buildman' settings file is currently not able to handle quoted strings, as given in the sample bellow: [make-flags] qemu_arm=HOSTCC="cc -isystem /add/include" HOSTLDFLAGS="-L/add/lib" This patch replaces the simple string splitter based on the delimiter with a regex tokenizer that preserves spaces inside double quoted strings. Signed-off-by: Cristian Ciocaltea --- tools/buildman/toolchain.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/buildman/toolchain.py b/tools/buildman/toolchain.py index cc26e2ede5..086a4d47cd 100644 --- a/tools/buildman/toolchain.py +++ b/tools/buildman/toolchain.py @@ -435,9 +435,10 @@ class Toolchains: self._make_flags['target'] = board.target arg_str = self.ResolveReferences(self._make_flags, self._make_flags.get(board.target, '')) - args = arg_str.split(' ') + args = re.findall("(?:\".*?\"|\S)+", arg_str) i = 0 while i < len(args): + args[i] = args[i].replace('"', '') if not args[i]: del args[i] else: From cb105794848a372d79ce2c8f6350f1eb5d7a60f1 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 Dec 2019 19:34:18 -0700 Subject: [PATCH 04/10] test.py: Make search for autoconf.mk more permissive Buildman doesn't store this file in the same directory as a normal build. Update the conftest code to handle both cases. Change-Id: I1fd0e56054d7dc77394a7589336aa0991bd0133d Signed-off-by: Simon Glass --- test/py/conftest.py | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/test/py/conftest.py b/test/py/conftest.py index bffee6b8a3..472dd0545d 100644 --- a/test/py/conftest.py +++ b/test/py/conftest.py @@ -83,6 +83,26 @@ def pytest_configure(config): Returns: Nothing. """ + def parse_config(conf_file): + """Parse a config file, loading it into the ubconfig container + + Args: + conf_file: Filename to load (within build_dir) + + Raises + Exception if the file does not exist + """ + dot_config = build_dir + '/' + conf_file + if not os.path.exists(dot_config): + raise Exception(conf_file + ' does not exist; ' + + 'try passing --build option?') + + with open(dot_config, 'rt') as f: + ini_str = '[root]\n' + f.read() + ini_sio = io.StringIO(ini_str) + parser = configparser.RawConfigParser() + parser.read_file(ini_sio) + ubconfig.buildconfig.update(parser.items('root')) global log global console @@ -157,18 +177,13 @@ def pytest_configure(config): ubconfig.buildconfig = dict() - for conf_file in ('.config', 'include/autoconf.mk'): - dot_config = build_dir + '/' + conf_file - if not os.path.exists(dot_config): - raise Exception(conf_file + ' does not exist; ' + - 'try passing --build option?') - - with open(dot_config, 'rt') as f: - ini_str = '[root]\n' + f.read() - ini_sio = io.StringIO(ini_str) - parser = configparser.RawConfigParser() - parser.read_file(ini_sio) - ubconfig.buildconfig.update(parser.items('root')) + # buildman -k puts autoconf.mk in the rootdir, so handle this as well + # as the standard U-Boot build which leaves it in include/autoconf.mk + parse_config('.config') + if os.path.exists(build_dir + '/' + 'autoconf.mk'): + parse_config('autoconf.mk') + else: + parse_config('include/autoconf.mk') ubconfig.test_py_dir = test_py_dir ubconfig.source_dir = source_dir From 69bbdd112bd3d2d6650cb2d81cd583400cef49c7 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 5 Dec 2019 15:59:11 -0700 Subject: [PATCH 05/10] genboardcfg: Support a quiet mode We don't really need buildman to print this every time it runs. Add a flag to run quietly, that buildman can use. Signed-off-by: Simon Glass --- tools/genboardscfg.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/genboardscfg.py b/tools/genboardscfg.py index 4ff0bffaef..24df13e500 100755 --- a/tools/genboardscfg.py +++ b/tools/genboardscfg.py @@ -403,18 +403,20 @@ def format_and_output(params_list, output): with open(output, 'w', encoding="utf-8") as f: f.write(COMMENT_BLOCK + '\n'.join(output_lines) + '\n') -def gen_boards_cfg(output, jobs=1, force=False): +def gen_boards_cfg(output, jobs=1, force=False, quiet=False): """Generate a board database file. Arguments: output: The name of the output file jobs: The number of jobs to run simultaneously force: Force to generate the output even if it is new + quiet: True to avoid printing a message if nothing needs doing """ check_top_directory() if not force and output_is_new(output): - print("%s is up to date. Nothing to do." % output) + if not quiet: + print("%s is up to date. Nothing to do." % output) sys.exit(0) params_list = scan_defconfigs(jobs) @@ -435,9 +437,11 @@ def main(): help='the number of jobs to run simultaneously') parser.add_option('-o', '--output', default=OUTPUT_FILE, help='output file [default=%s]' % OUTPUT_FILE) + parser.add_option('-q', '--quiet', action="store_true", help='run silently') (options, args) = parser.parse_args() - gen_boards_cfg(options.output, jobs=options.jobs, force=options.force) + gen_boards_cfg(options.output, jobs=options.jobs, force=options.force, + quiet=options.quiet) if __name__ == '__main__': main() From 6a3fc91ea7fdf3f6e35c92eb02c9c73fb9f42d04 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 5 Dec 2019 15:59:12 -0700 Subject: [PATCH 06/10] buildman: Ask genboardscfg to be quiet Now that this tool has a 'quiet' flag, use it. Signed-off-by: Simon Glass --- tools/buildman/control.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/buildman/control.py b/tools/buildman/control.py index c55a65d0c3..3b41d7b26a 100644 --- a/tools/buildman/control.py +++ b/tools/buildman/control.py @@ -205,7 +205,7 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None, os.makedirs(options.output_dir) board_file = os.path.join(options.output_dir, 'boards.cfg') genboardscfg = os.path.join(options.git, 'tools/genboardscfg.py') - status = subprocess.call([genboardscfg, '-o', board_file]) + status = subprocess.call([genboardscfg, '-q', '-o', board_file]) if status != 0: sys.exit("Failed to generate boards.cfg") From 7c66ead45267122c48bc854d1d5bd0d9a99bf943 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 5 Dec 2019 15:59:13 -0700 Subject: [PATCH 07/10] buildman: Figure out boards before commits At present buildman looks at toolchains, then commits and then boards. Move the board processing up above the commit processing, since it relates to the toolchain code. This will make it easier to check the toolchains needed for a board without processing commits first. Signed-off-by: Simon Glass --- tools/buildman/control.py | 61 +++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/tools/buildman/control.py b/tools/buildman/control.py index 3b41d7b26a..a9c5022e48 100644 --- a/tools/buildman/control.py +++ b/tools/buildman/control.py @@ -170,6 +170,36 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None, print() return 0 + # Work out what subset of the boards we are building + if not boards: + if not os.path.exists(options.output_dir): + os.makedirs(options.output_dir) + board_file = os.path.join(options.output_dir, 'boards.cfg') + genboardscfg = os.path.join(options.git, 'tools/genboardscfg.py') + status = subprocess.call([genboardscfg, '-q', '-o', board_file]) + if status != 0: + sys.exit("Failed to generate boards.cfg") + + boards = board.Boards() + boards.ReadBoards(board_file) + + exclude = [] + if options.exclude: + for arg in options.exclude: + exclude += arg.split(',') + + if options.boards: + requested_boards = [] + for b in options.boards: + requested_boards += b.split(',') + else: + requested_boards = None + why_selected, board_warnings = boards.SelectBoards(args, exclude, + requested_boards) + selected = boards.GetSelected() + if not len(selected): + sys.exit(col.Color(col.RED, 'No matching boards found')) + # Work out how many commits to build. We want to build everything on the # branch. We also build the upstream commit as a control so we can see # problems introduced by the first commit on the branch. @@ -199,37 +229,6 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None, "set branch's upstream or use -c flag" % options.branch) sys.exit(col.Color(col.RED, str)) - # Work out what subset of the boards we are building - if not boards: - if not os.path.exists(options.output_dir): - os.makedirs(options.output_dir) - board_file = os.path.join(options.output_dir, 'boards.cfg') - genboardscfg = os.path.join(options.git, 'tools/genboardscfg.py') - status = subprocess.call([genboardscfg, '-q', '-o', board_file]) - if status != 0: - sys.exit("Failed to generate boards.cfg") - - boards = board.Boards() - boards.ReadBoards(board_file) - - exclude = [] - if options.exclude: - for arg in options.exclude: - exclude += arg.split(',') - - - if options.boards: - requested_boards = [] - for b in options.boards: - requested_boards += b.split(',') - else: - requested_boards = None - why_selected, board_warnings = boards.SelectBoards(args, exclude, - requested_boards) - selected = boards.GetSelected() - if not len(selected): - sys.exit(col.Color(col.RED, 'No matching boards found')) - # Read the metadata from the commits. First look at the upstream commit, # then the ones in the branch. We would like to do something like # upstream/master~..branch but that isn't possible if upstream/master is From 57cb9d52397c9051d7b3d27bd107cce04a16846f Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 5 Dec 2019 15:59:14 -0700 Subject: [PATCH 08/10] buildman: Add options to get the arch and toolchain info Sometimes it is useful for external tools to use buildman to provide the toolchain information. Add an -a option which shows the value to use for the ARCH environment variable, and -A which does the same for CROSS_COMPILE Signed-off-by: Simon Glass --- tools/buildman/README | 3 +++ tools/buildman/cmdline.py | 4 ++++ tools/buildman/control.py | 35 +++++++++++++++++++++++++++++++++++ tools/buildman/test.py | 18 ++++++++++++++++++ tools/buildman/toolchain.py | 26 ++++++++++++++++++++++++++ 5 files changed, 86 insertions(+) diff --git a/tools/buildman/README b/tools/buildman/README index e36619216d..c1ac0d0f58 100644 --- a/tools/buildman/README +++ b/tools/buildman/README @@ -1061,6 +1061,9 @@ Other options Buildman has various other command line options. Try --help to see them. +To find out what architecture or toolchain prefix buildman will use for a build, +see the -a and -A options. + When doing builds, Buildman's return code will reflect the overall result: 0 (success) No errors or warnings found diff --git a/tools/buildman/cmdline.py b/tools/buildman/cmdline.py index 832a5145d2..b41209373d 100644 --- a/tools/buildman/cmdline.py +++ b/tools/buildman/cmdline.py @@ -13,6 +13,10 @@ def ParseArgs(): args: command lin arguments """ parser = OptionParser() + parser.add_option('-a', '--print-arch', action='store_true', + help='Print the architecture for a board (ARCH=)') + parser.add_option('-A', '--print-prefix', action='store_true', + help='Print the tool-chain prefix for a board (CROSS_COMPILE=)') parser.add_option('-b', '--branch', type='string', help='Branch name to build, or range of commits to build') parser.add_option('-B', '--bloat', dest='show_bloat', diff --git a/tools/buildman/control.py b/tools/buildman/control.py index a9c5022e48..969d866547 100644 --- a/tools/buildman/control.py +++ b/tools/buildman/control.py @@ -107,6 +107,34 @@ def CheckOutputDir(output_dir): break path = parent +def ShowToolchainInfo(boards, toolchains, print_arch, print_prefix): + """Show information about a the tool chain used by one or more boards + + The function checks that all boards use the same toolchain. + + Args: + boards: Boards object containing selected boards + toolchains: Toolchains object containing available toolchains + print_arch: True to print ARCH value + print_prefix: True to print CROSS_COMPILE value + + Return: + None on success, string error message otherwise + """ + boards = boards.GetSelectedDict() + tc_set = set() + for brd in boards.values(): + tc_set.add(toolchains.Select(brd.arch)) + if len(tc_set) != 1: + return 'Supplied boards must share one toolchain' + return False + tc = tc_set.pop() + if print_arch: + print(tc.GetEnvArgs(toolchain.VAR_ARCH)) + if print_prefix: + print(tc.GetEnvArgs(toolchain.VAR_CROSS_COMPILE)) + return None + def DoBuildman(options, args, toolchains=None, make_func=None, boards=None, clean_dir=False): """The main control code for buildman @@ -200,6 +228,13 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None, if not len(selected): sys.exit(col.Color(col.RED, 'No matching boards found')) + if options.print_arch or options.print_prefix: + err = ShowToolchainInfo(boards, toolchains, options.print_arch, + options.print_prefix) + if err: + sys.exit(col.Color(col.RED, err)) + return 0 + # Work out how many commits to build. We want to build everything on the # branch. We also build the upstream commit as a control so we can see # problems introduced by the first commit on the branch. diff --git a/tools/buildman/test.py b/tools/buildman/test.py index b4e28d6867..acd862b3b0 100644 --- a/tools/buildman/test.py +++ b/tools/buildman/test.py @@ -451,6 +451,24 @@ class TestBuild(unittest.TestCase): 'crosstool/files/bin/x86_64/.*/' 'x86_64-gcc-.*-nolibc_arm-.*linux-gnueabi.tar.xz') + def testGetEnvArgs(self): + """Test the GetEnvArgs() function""" + tc = self.toolchains.Select('arm') + self.assertEqual('arm-linux-', + tc.GetEnvArgs(toolchain.VAR_CROSS_COMPILE)) + self.assertEqual('', tc.GetEnvArgs(toolchain.VAR_PATH)) + self.assertEqual('arm', + tc.GetEnvArgs(toolchain.VAR_ARCH)) + self.assertEqual('', tc.GetEnvArgs(toolchain.VAR_MAKE_ARGS)) + + self.toolchains.Add('/path/to/x86_64-linux-gcc', test=False) + tc = self.toolchains.Select('x86') + self.assertEqual('/path/to', + tc.GetEnvArgs(toolchain.VAR_PATH)) + tc.override_toolchain = 'clang' + self.assertEqual('HOSTCC=clang CC=clang', + tc.GetEnvArgs(toolchain.VAR_MAKE_ARGS)) + if __name__ == "__main__": unittest.main() diff --git a/tools/buildman/toolchain.py b/tools/buildman/toolchain.py index 086a4d47cd..4f39bfd0ce 100644 --- a/tools/buildman/toolchain.py +++ b/tools/buildman/toolchain.py @@ -18,6 +18,8 @@ import tools (PRIORITY_FULL_PREFIX, PRIORITY_PREFIX_GCC, PRIORITY_PREFIX_GCC_PATH, PRIORITY_CALC) = list(range(4)) +(VAR_CROSS_COMPILE, VAR_PATH, VAR_ARCH, VAR_MAKE_ARGS) = range(4) + # Simple class to collect links from a page class MyHTMLParser(HTMLParser): def __init__(self, arch): @@ -145,6 +147,30 @@ class Toolchain: return value + def GetEnvArgs(self, which): + """Get an environment variable/args value based on the the toolchain + + Args: + which: VAR_... value to get + + Returns: + Value of that environment variable or arguments + """ + wrapper = self.GetWrapper() + if which == VAR_CROSS_COMPILE: + return wrapper + os.path.join(self.path, self.cross) + elif which == VAR_PATH: + return self.path + elif which == VAR_ARCH: + return self.arch + elif which == VAR_MAKE_ARGS: + args = self.MakeArgs() + if args: + return ' '.join(args) + return '' + else: + raise ValueError('Unknown arg to GetEnvArgs (%d)' % which) + def MakeEnvironment(self, full_path): """Returns an environment for using the toolchain. From d08c38c32f64498946230059bd4ec1431c23476a Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 6 Dec 2019 15:31:31 -0500 Subject: [PATCH 09/10] buildman: Ignore blank lines during size checks Today when parsing the .sizes files we get a warning about an invalid line in the file as it's blank. Solve this by checking that we have a non-blank line prior to processing. Cc: Simon Glass Signed-off-by: Tom Rini Reviewed-by: Simon Glass --- tools/buildman/builder.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py index cfbe4c26b1..784c64122b 100644 --- a/tools/buildman/builder.py +++ b/tools/buildman/builder.py @@ -577,7 +577,8 @@ class Builder: sym = {} for line in fd.readlines(): try: - size, type, name = line[:-1].split() + if line.strip(): + size, type, name = line[:-1].split() except: Print("Invalid line in file '%s': '%s'" % (fname, line[:-1])) continue From b4f98b3b16ec513f7fa6b97ec49792a5e99ec165 Mon Sep 17 00:00:00 2001 From: Michael Auchter Date: Mon, 9 Dec 2019 20:27:31 +0000 Subject: [PATCH 10/10] cros_ec: use uint instead of uint8_t for cmd param Chromium EC commands can be up to 16-bits, so using a uint8_t here can cause truncation. Update to use a uint instead. It looks like this should likely have been done as a part of 9fea76f5d30264dc08ac591a7a89427b8441555b, but this function was skipped for some reason. Signed-off-by: Michael Auchter Cc: Simon Glass Reviewed-by: Simon Glass --- drivers/misc/cros_ec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c index 382f826286..fa9984f6bd 100644 --- a/drivers/misc/cros_ec.c +++ b/drivers/misc/cros_ec.c @@ -313,7 +313,7 @@ static int send_command(struct cros_ec_dev *dev, uint cmd, int cmd_version, * @param din_len Maximum size of response in bytes * @return number of bytes in response, or -ve on error */ -static int ec_command_inptr(struct udevice *dev, uint8_t cmd, +static int ec_command_inptr(struct udevice *dev, uint cmd, int cmd_version, const void *dout, int dout_len, uint8_t **dinp, int din_len) {