aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/buildman/README3
-rw-r--r--tools/buildman/builder.py3
-rw-r--r--tools/buildman/cmdline.py4
-rw-r--r--tools/buildman/control.py96
-rw-r--r--tools/buildman/test.py18
-rw-r--r--tools/buildman/toolchain.py29
-rw-r--r--tools/dumpimage.c15
-rw-r--r--tools/fit_image.c9
-rwxr-xr-xtools/genboardscfg.py10
-rwxr-xr-xtools/imx8m_image.sh28
10 files changed, 158 insertions, 57 deletions
diff --git a/tools/buildman/README b/tools/buildman/README
index e36619216d4..c1ac0d0f58d 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/builder.py b/tools/buildman/builder.py
index cfbe4c26b1a..784c64122ba 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
diff --git a/tools/buildman/cmdline.py b/tools/buildman/cmdline.py
index 832a5145d28..b41209373dd 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 c55a65d0c30..969d866547a 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
@@ -170,42 +198,13 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None,
print()
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.
- count = options.count
- has_range = options.branch and '..' in options.branch
- if count == -1:
- if not options.branch:
- count = 1
- else:
- if has_range:
- count, msg = gitutil.CountCommitsInRange(options.git_dir,
- options.branch)
- else:
- count, msg = gitutil.CountCommitsInBranch(options.git_dir,
- options.branch)
- if count is None:
- sys.exit(col.Color(col.RED, msg))
- elif count == 0:
- sys.exit(col.Color(col.RED, "Range '%s' has no commits" %
- options.branch))
- if msg:
- print(col.Color(col.YELLOW, msg))
- count += 1 # Build upstream commit also
-
- if not count:
- str = ("No commits found to process in branch '%s': "
- "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, '-o', board_file])
+ status = subprocess.call([genboardscfg, '-q', '-o', board_file])
if status != 0:
sys.exit("Failed to generate boards.cfg")
@@ -217,7 +216,6 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None,
for arg in options.exclude:
exclude += arg.split(',')
-
if options.boards:
requested_boards = []
for b in options.boards:
@@ -230,6 +228,42 @@ 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.
+ count = options.count
+ has_range = options.branch and '..' in options.branch
+ if count == -1:
+ if not options.branch:
+ count = 1
+ else:
+ if has_range:
+ count, msg = gitutil.CountCommitsInRange(options.git_dir,
+ options.branch)
+ else:
+ count, msg = gitutil.CountCommitsInBranch(options.git_dir,
+ options.branch)
+ if count is None:
+ sys.exit(col.Color(col.RED, msg))
+ elif count == 0:
+ sys.exit(col.Color(col.RED, "Range '%s' has no commits" %
+ options.branch))
+ if msg:
+ print(col.Color(col.YELLOW, msg))
+ count += 1 # Build upstream commit also
+
+ if not count:
+ str = ("No commits found to process in branch '%s': "
+ "set branch's upstream or use -c flag" % options.branch)
+ sys.exit(col.Color(col.RED, str))
+
# 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
diff --git a/tools/buildman/test.py b/tools/buildman/test.py
index b4e28d68676..acd862b3b0f 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 cc26e2ede57..4f39bfd0ce5 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.
@@ -435,9 +461,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:
diff --git a/tools/dumpimage.c b/tools/dumpimage.c
index ee3d41dda4d..e5481435a76 100644
--- a/tools/dumpimage.c
+++ b/tools/dumpimage.c
@@ -35,14 +35,23 @@ static int dumpimage_extract_subimage(struct image_type_params *tparams,
if (tparams->verify_header) {
retval = tparams->verify_header((unsigned char *)ptr,
sbuf->st_size, &params);
- if (retval != 0)
+ if (retval != 0) {
+ fprintf(stderr, "%s: failed to verify header of %s\n",
+ params.cmdname, tparams->name);
return -1;
+ }
+
/*
* Extract the file from the image
* if verify is successful
*/
if (tparams->extract_subimage) {
retval = tparams->extract_subimage(ptr, &params);
+ if (retval != 0) {
+ fprintf(stderr, "%s: extract_subimage failed for %s\n",
+ params.cmdname, tparams->name);
+ return -3;
+ }
} else {
fprintf(stderr,
"%s: extract_subimage undefined for %s\n",
@@ -95,7 +104,6 @@ int main(int argc, char **argv)
printf("dumpimage version %s\n", PLAIN_VERSION);
exit(EXIT_SUCCESS);
case 'h':
- usage();
default:
usage();
break;
@@ -175,6 +183,9 @@ int main(int argc, char **argv)
* image type. Returns the error code if not matched
*/
retval = dumpimage_extract_subimage(tparams, ptr, &sbuf);
+ if (retval)
+ fprintf(stderr, "%s: Can't extract subimage from %s\n",
+ params.cmdname, params.imagefile);
} else {
/*
* Print the image information for matched image type
diff --git a/tools/fit_image.c b/tools/fit_image.c
index 0201cc44d8f..114df5af305 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -741,9 +741,14 @@ static int fit_image_extract(
{
const void *file_data;
size_t file_size = 0;
+ int ret;
- /* get the "data" property of component at offset "image_noffset" */
- fit_image_get_data(fit, image_noffset, &file_data, &file_size);
+ /* get the data address and size of component at offset "image_noffset" */
+ ret = fit_image_get_data_and_size(fit, image_noffset, &file_data, &file_size);
+ if (ret) {
+ fprintf(stderr, "Could not get component information\n");
+ return ret;
+ }
/* save the "file_data" into the file specified by "file_name" */
return imagetool_save_subimage(file_name, (ulong) file_data, file_size);
diff --git a/tools/genboardscfg.py b/tools/genboardscfg.py
index 4ff0bffaefa..24df13e5008 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()
diff --git a/tools/imx8m_image.sh b/tools/imx8m_image.sh
index 603ba6e8f49..4959f9c8353 100755
--- a/tools/imx8m_image.sh
+++ b/tools/imx8m_image.sh
@@ -10,41 +10,35 @@ post_process=$2
blobs=`awk '/^SIGNED_HDMI/ {print $2} /^LOADER/ {print $2} /^SECOND_LOADER/ {print $2} /^DDR_FW/ {print $2}' $file`
for f in $blobs; do
- tmp=$srctree/$f
-
if [ $f = "spl/u-boot-spl-ddr.bin" ] || [ $f = "u-boot.itb" ]; then
continue
fi
if [ -f $f ]; then
continue
- fi
-
- if [ ! -f $tmp ]; then
+ else
echo "WARNING '$tmp' not found, resulting binary is not-functional" >&2
exit 1
fi
-
- sed -in "s;$f;$tmp;" $file
done
if [ $post_process = 1 ]; then
- if [ -f $srctree/lpddr4_pmu_train_1d_imem.bin ]; then
- objcopy -I binary -O binary --pad-to 0x8000 --gap-fill=0x0 $srctree/lpddr4_pmu_train_1d_imem.bin lpddr4_pmu_train_1d_imem_pad.bin
- objcopy -I binary -O binary --pad-to 0x4000 --gap-fill=0x0 $srctree/lpddr4_pmu_train_1d_dmem.bin lpddr4_pmu_train_1d_dmem_pad.bin
- objcopy -I binary -O binary --pad-to 0x8000 --gap-fill=0x0 $srctree/lpddr4_pmu_train_2d_imem.bin lpddr4_pmu_train_2d_imem_pad.bin
+ if [ -f lpddr4_pmu_train_1d_imem.bin ]; then
+ objcopy -I binary -O binary --pad-to 0x8000 --gap-fill=0x0 lpddr4_pmu_train_1d_imem.bin lpddr4_pmu_train_1d_imem_pad.bin
+ objcopy -I binary -O binary --pad-to 0x4000 --gap-fill=0x0 lpddr4_pmu_train_1d_dmem.bin lpddr4_pmu_train_1d_dmem_pad.bin
+ objcopy -I binary -O binary --pad-to 0x8000 --gap-fill=0x0 lpddr4_pmu_train_2d_imem.bin lpddr4_pmu_train_2d_imem_pad.bin
cat lpddr4_pmu_train_1d_imem_pad.bin lpddr4_pmu_train_1d_dmem_pad.bin > lpddr4_pmu_train_1d_fw.bin
- cat lpddr4_pmu_train_2d_imem_pad.bin $srctree/lpddr4_pmu_train_2d_dmem.bin > lpddr4_pmu_train_2d_fw.bin
+ cat lpddr4_pmu_train_2d_imem_pad.bin lpddr4_pmu_train_2d_dmem.bin > lpddr4_pmu_train_2d_fw.bin
dd if=spl/u-boot-spl.bin of=spl/u-boot-spl-pad.bin bs=4 conv=sync
cat spl/u-boot-spl-pad.bin lpddr4_pmu_train_1d_fw.bin lpddr4_pmu_train_2d_fw.bin > spl/u-boot-spl-ddr.bin
rm -f lpddr4_pmu_train_1d_fw.bin lpddr4_pmu_train_2d_fw.bin lpddr4_pmu_train_1d_imem_pad.bin lpddr4_pmu_train_1d_dmem_pad.bin lpddr4_pmu_train_2d_imem_pad.bin spl/u-boot-spl-pad.bin
fi
- if [ -f $srctree/ddr4_imem_1d.bin ]; then
- objcopy -I binary -O binary --pad-to 0x8000 --gap-fill=0x0 $srctree/ddr4_imem_1d.bin ddr4_imem_1d_pad.bin
- objcopy -I binary -O binary --pad-to 0x4000 --gap-fill=0x0 $srctree/ddr4_dmem_1d.bin ddr4_dmem_1d_pad.bin
- objcopy -I binary -O binary --pad-to 0x8000 --gap-fill=0x0 $srctree/ddr4_imem_2d.bin ddr4_imem_2d_pad.bin
+ if [ -f ddr4_imem_1d.bin ]; then
+ objcopy -I binary -O binary --pad-to 0x8000 --gap-fill=0x0 ddr4_imem_1d.bin ddr4_imem_1d_pad.bin
+ objcopy -I binary -O binary --pad-to 0x4000 --gap-fill=0x0 ddr4_dmem_1d.bin ddr4_dmem_1d_pad.bin
+ objcopy -I binary -O binary --pad-to 0x8000 --gap-fill=0x0 ddr4_imem_2d.bin ddr4_imem_2d_pad.bin
cat ddr4_imem_1d_pad.bin ddr4_dmem_1d_pad.bin > ddr4_1d_fw.bin
- cat ddr4_imem_2d_pad.bin $srctree/ddr4_dmem_2d.bin > ddr4_2d_fw.bin
+ cat ddr4_imem_2d_pad.bin ddr4_dmem_2d.bin > ddr4_2d_fw.bin
dd if=spl/u-boot-spl.bin of=spl/u-boot-spl-pad.bin bs=4 conv=sync
cat spl/u-boot-spl-pad.bin ddr4_1d_fw.bin ddr4_2d_fw.bin > spl/u-boot-spl-ddr.bin
rm -f ddr4_1d_fw.bin ddr4_2d_fw.bin ddr4_imem_1d_pad.bin ddr4_dmem_1d_pad.bin ddr4_imem_2d_pad.bin spl/u-boot-spl-pad.bin