blob: 76e97926f587fc6641da1bb2dce6338553bbf4fb [file] [log] [blame]
Mike Frysingerf1ba7ad2022-09-12 05:42:57 -04001# Copyright 2013 The ChromiumOS Authors
Simon Glass02741682013-05-26 07:07:58 -07002# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5"""crosfw - Chrome OS Firmware build/flash script.
6
7Builds a firmware image for any board and writes it to the board. The image
8can be pure upstream or include Chrome OS components (-V). Some device
9tree parameters can be provided, including silent console (-C) and secure
10boot (-S). Use -i for a faster incremental build. The image is written to
11the board by default using USB/em100 (or sdcard with -x). Use -b to specify
12the board to build. Options can be added to ~/.crosfwrc - see the script for
13details.
14
15It can also flash SPI by writing a 'magic flasher' U-Boot with a payload
16to the board.
17
Simon Glass02741682013-05-26 07:07:58 -070018The script is normally run from within the U-Boot directory which is
19.../src/third_party/u-boot/files
20
21Example 1: Build upstream image for coreboot and write to a 'link':
22
23 crosfw -b link
24
25Example 2: Build verified boot image (V) for daisy/snow and boot in secure
26 mode (S) so that breaking in on boot is not possible.
27
28 crosfw -b daisy -VS
29 crosfw -b daisy -VSC (no console output)
30
31Example 3: Build a magic flasher (F) with full verified boot for peach_pit,
32 but with console enabled, write to SD card (x)
33
34 crosfw -b peach_pit -VSFx
35
36This sript does not use an ebuild. It does a similar thing to the
37chromeos-u-boot ebuild, and runs cros_bundle_firmware to produce various
38types of image, a little like the chromeos-bootimage ebuild.
39
40The purpose of this script is to make it easier and faster to perform
41common firmware build tasks without changing boards, manually updating
42device tree files or lots of USE flags and complexity in the ebuilds.
43
44This script has been tested with snow, link and peach_pit. It builds for
45peach_pit by default. Note that it will also build any upstream ARM
46board - e.g. "-b snapper9260" will build an image for that board.
47
48Mostly you can use the script inside and outside the chroot. The main
49limitation is that dut-control doesn't really work outside the chroot,
50so writing the image to the board over USB is not possible, nor can the
51board be automatically reset on x86 platforms.
52
53For an incremental build (faster), run with -i
54
55To get faster clean builds, install ccache, and create ~/.crosfwrc with
56this line:
57
Simon Glass6ddc7f12013-07-18 15:22:41 -060058 USE_CCACHE = True
Simon Glass02741682013-05-26 07:07:58 -070059
60(make sure ~/.ccache is not on NFS, or set CCACHE_DIR)
61
62Other options are the default board to build, and verbosity (0-4), e.g.:
63
Simon Glass6ddc7f12013-07-18 15:22:41 -060064 DEFAULT_BOARD = 'daisy'
65 VERBOSE = 1
Simon Glass02741682013-05-26 07:07:58 -070066
67It is possible to use multiple servo boards, each on its own port. Add
68these lines to your ~/.crosfwrc to set the servo port to use for each
69board:
70
71 SERVO_PORT['link'] = 8888
72 SERVO_PORT['daisy'] = 9999
73 SERVO_PORT['peach_pit'] = 7777
74
Simon Glassb89ae892013-07-18 15:23:35 -060075All builds appear in the <outdir>/<board> subdirectory and images are written
76to <outdir>/<uboard>/out, where <uboard> is the U-Boot name for the board (in
77the U-Boot boards.cfg file)
78
79The value for <outdir> defaults to /tmp/crosfw but can be configured in your
80~/.crosfwrc file, e.g.:"
81
82 OUT_DIR = '/tmp/u-boot'
Simon Glass02741682013-05-26 07:07:58 -070083
84For the -a option here are some useful options:
85
86--add-blob cros-splash /dev/null
87--gbb-flags -force-dev-switch-on
88--add-node-enable /spi@131b0000/cros-ecp@0 1
89--verify --full-erase
90--bootcmd "cros_test sha"
91--gbb-flags -force-dev-switch-on
Mike Frysinger0246c1f2021-12-14 01:17:17 -050092--bmpblk ~/chromiumos/src/third_party/u-boot/bmp.bin
Simon Glass02741682013-05-26 07:07:58 -070093
94For example: -a "--gbb-flags -force-dev-switch-on"
95
96Note the standard bmpblk is at:
Mike Frysinger0246c1f2021-12-14 01:17:17 -050097 ~/chromiumos/src/third_party/chromiumos-overlay/sys-boot/
98 chromeos-bootimage/files/bmpblk.bin
Simon Glass02741682013-05-26 07:07:58 -070099"""
100
101import glob
Chris McDonald59650c32021-07-20 15:29:28 -0600102import logging
Simon Glass02741682013-05-26 07:07:58 -0700103import multiprocessing
104import os
105import re
Mike Frysinger66d32cd2019-12-17 14:55:29 -0500106import subprocess
Simon Glass02741682013-05-26 07:07:58 -0700107import sys
108
Simon Glass02741682013-05-26 07:07:58 -0700109from chromite.lib import commandline
Chris McDonald59650c32021-07-20 15:29:28 -0600110from chromite.lib import constants
Simon Glass02741682013-05-26 07:07:58 -0700111from chromite.lib import cros_build_lib
112from chromite.lib import osutils
113from chromite.lib import parallel
114
115
116arch = None
117board = None
118compiler = None
119default_board = None
120family = None
121in_chroot = True
122
Alex Klein1699fab2022-09-08 08:46:06 -0600123logging.basicConfig(format="%(message)s")
124kwargs = {
125 "print_cmd": False,
126 "check": False,
127 "debug_level": logging.getLogger().getEffectiveLevel(),
128}
Simon Glass02741682013-05-26 07:07:58 -0700129
Alex Klein1699fab2022-09-08 08:46:06 -0600130outdir = ""
Simon Glass02741682013-05-26 07:07:58 -0700131
Alex Klein1699fab2022-09-08 08:46:06 -0600132# If you have multiple boards connected on different servo ports, put lines
Simon Glass02741682013-05-26 07:07:58 -0700133# like 'SERVO_PORT{"peach_pit"} = 7777' in your ~/.crosfwrc
134SERVO_PORT = {}
135
136smdk = None
Alex Klein1699fab2022-09-08 08:46:06 -0600137src_root = os.path.join(constants.SOURCE_ROOT, "src")
Simon Glass02741682013-05-26 07:07:58 -0700138in_chroot = cros_build_lib.IsInsideChroot()
139
Alex Klein1699fab2022-09-08 08:46:06 -0600140uboard = ""
Simon Glass02741682013-05-26 07:07:58 -0700141
Alex Klein1699fab2022-09-08 08:46:06 -0600142default_board = "peach_pit"
Simon Glass02741682013-05-26 07:07:58 -0700143use_ccache = False
144vendor = None
145verbose = False
146
147# Special cases for the U-Boot board config, the SOCs and default device tree
148# since the naming is not always consistent.
149# x86 has a lot of boards, but to U-Boot they are all the same
150UBOARDS = {
Alex Klein1699fab2022-09-08 08:46:06 -0600151 "daisy": "smdk5250",
152 "peach": "smdk5420",
Simon Glass02741682013-05-26 07:07:58 -0700153}
Alex Klein1699fab2022-09-08 08:46:06 -0600154for b in [
155 "alex",
156 "butterfly",
157 "emeraldlake2",
158 "link",
159 "lumpy",
160 "parrot",
161 "stout",
162 "stumpy",
163]:
164 UBOARDS[b] = "coreboot-x86"
165 UBOARDS["chromeos_%s" % b] = "chromeos_coreboot"
Simon Glass02741682013-05-26 07:07:58 -0700166
167SOCS = {
Alex Klein1699fab2022-09-08 08:46:06 -0600168 "coreboot-x86": "",
169 "chromeos_coreboot": "",
170 "daisy": "exynos5250-",
171 "peach": "exynos5420-",
Simon Glass02741682013-05-26 07:07:58 -0700172}
173
174DEFAULT_DTS = {
Alex Klein1699fab2022-09-08 08:46:06 -0600175 "daisy": "snow",
176 "daisy_spring": "spring",
177 "peach_pit": "peach-pit",
Simon Glass02741682013-05-26 07:07:58 -0700178}
179
Alex Klein1699fab2022-09-08 08:46:06 -0600180OUT_DIR = "/tmp/crosfw"
Simon Glassb89ae892013-07-18 15:23:35 -0600181
Alex Klein1699fab2022-09-08 08:46:06 -0600182rc_file = os.path.expanduser("~/.crosfwrc")
Simon Glass02741682013-05-26 07:07:58 -0700183if os.path.exists(rc_file):
Alex Klein1699fab2022-09-08 08:46:06 -0600184 with open(rc_file) as fp:
185 # pylint: disable=exec-used
186 exec(compile(fp.read(), rc_file, "exec"))
Simon Glass02741682013-05-26 07:07:58 -0700187
188
189def Log(msg):
Alex Klein1699fab2022-09-08 08:46:06 -0600190 """Print out a message if we are in verbose mode.
Simon Glass02741682013-05-26 07:07:58 -0700191
Alex Klein1699fab2022-09-08 08:46:06 -0600192 Args:
193 msg: Message to print
194 """
195 if verbose:
196 logging.info(msg)
Simon Glass02741682013-05-26 07:07:58 -0700197
198
199def Dumper(flag, infile, outfile):
Alex Klein1699fab2022-09-08 08:46:06 -0600200 """Run objdump on an input file.
Simon Glass02741682013-05-26 07:07:58 -0700201
Alex Klein1699fab2022-09-08 08:46:06 -0600202 Args:
203 flag: Flag to pass objdump (e.g. '-d').
204 infile: Input file to process.
205 outfile: Output file to write to.
206 """
207 result = cros_build_lib.run(
208 [CompilerTool("objdump"), flag, infile], stdout=outfile, **kwargs
209 )
210 if result.returncode:
211 sys.exit()
Simon Glass02741682013-05-26 07:07:58 -0700212
213
214def CompilerTool(tool):
Alex Klein1699fab2022-09-08 08:46:06 -0600215 """Returns the cross-compiler tool filename.
Simon Glass02741682013-05-26 07:07:58 -0700216
Alex Klein1699fab2022-09-08 08:46:06 -0600217 Args:
218 tool: Tool name to return, e.g. 'size'.
Simon Glass02741682013-05-26 07:07:58 -0700219
Alex Klein1699fab2022-09-08 08:46:06 -0600220 Returns:
221 Filename of requested tool.
222 """
223 return "%s%s" % (compiler, tool)
Simon Glass02741682013-05-26 07:07:58 -0700224
225
226def ParseCmdline(argv):
Alex Klein1699fab2022-09-08 08:46:06 -0600227 """Parse all command line options.
Simon Glass02741682013-05-26 07:07:58 -0700228
Alex Klein1699fab2022-09-08 08:46:06 -0600229 Args:
230 argv: Arguments to parse.
Simon Glass02741682013-05-26 07:07:58 -0700231
Alex Klein1699fab2022-09-08 08:46:06 -0600232 Returns:
233 The parsed options object
234 """
235 parser = commandline.ArgumentParser(description=__doc__)
236 parser.add_argument(
Alex Klein1699fab2022-09-08 08:46:06 -0600237 "-b",
238 "--board",
239 type=str,
240 default=default_board,
241 help="Select board to build (daisy/peach_pit/link)",
242 )
243 parser.add_argument(
244 "-B",
245 "--build",
246 action="store_false",
247 default=True,
248 help="Don't build U-Boot, just configure device tree",
249 )
250 parser.add_argument(
Alex Klein1699fab2022-09-08 08:46:06 -0600251 "-d",
252 "--dt",
253 default="seaboard",
254 help="Select name of device tree file to use",
255 )
256 parser.add_argument(
Alex Klein1699fab2022-09-08 08:46:06 -0600257 "-i",
258 "--incremental",
259 action="store_true",
260 default=False,
261 help="Don't reconfigure and clean",
262 )
263 parser.add_argument(
Alex Klein1699fab2022-09-08 08:46:06 -0600264 "-O",
265 "--objdump",
266 action="store_true",
267 default=False,
268 help="Write disassembly output",
269 )
270 parser.add_argument(
Alex Klein1699fab2022-09-08 08:46:06 -0600271 "-t",
272 "--trace",
273 action="store_true",
274 default=False,
275 help="Enable trace support",
276 )
277 parser.add_argument(
278 "-V",
279 "--verified",
280 action="store_true",
281 default=False,
282 help="Include Chrome OS verified boot components",
283 )
284 parser.add_argument(
Alex Klein1699fab2022-09-08 08:46:06 -0600285 "-z",
286 "--size",
287 action="store_true",
288 default=False,
289 help="Display U-Boot image size",
290 )
291 parser.add_argument(
292 "target", nargs="?", default="all", help="The target to work on"
293 )
294 return parser.parse_args(argv)
Simon Glass02741682013-05-26 07:07:58 -0700295
296
Simon Glassc1a323a2016-08-04 20:29:51 -0600297def FindCompiler(gcc, cros_prefix):
Alex Klein1699fab2022-09-08 08:46:06 -0600298 """Look up the compiler for an architecture.
Simon Glassc1a323a2016-08-04 20:29:51 -0600299
Alex Klein1699fab2022-09-08 08:46:06 -0600300 Args:
301 gcc: GCC architecture, either 'arm' or 'aarch64'
302 cros_prefix: Full Chromium OS toolchain prefix
303 """
304 if in_chroot:
305 # Use the Chromium OS toolchain.
306 prefix = cros_prefix
307 else:
308 prefix = glob.glob("/opt/linaro/gcc-linaro-%s-linux-*/bin/*gcc" % gcc)
309 if not prefix:
310 cros_build_lib.Die(
311 """Please install an %s toolchain for your machine.
Simon Glassc1a323a2016-08-04 20:29:51 -0600312Install a Linaro toolchain from:
313https://launchpad.net/linaro-toolchain-binaries
Alex Klein1699fab2022-09-08 08:46:06 -0600314or see cros/commands/cros_chrome_sdk.py."""
315 % gcc
316 )
317 prefix = re.sub("gcc$", "", prefix[0])
318 return prefix
Simon Glassc1a323a2016-08-04 20:29:51 -0600319
320
Simon Glass02741682013-05-26 07:07:58 -0700321def SetupBuild(options):
Alex Klein1699fab2022-09-08 08:46:06 -0600322 """Set up parameters needed for the build.
Simon Glass02741682013-05-26 07:07:58 -0700323
Alex Klein1699fab2022-09-08 08:46:06 -0600324 This checks the current environment and options and sets up various things
325 needed for the build, including 'base' which holds the base flags for
326 passing to the U-Boot Makefile.
Simon Glass02741682013-05-26 07:07:58 -0700327
Alex Klein1699fab2022-09-08 08:46:06 -0600328 Args:
329 options: Command line options
Simon Glass02741682013-05-26 07:07:58 -0700330
Alex Klein1699fab2022-09-08 08:46:06 -0600331 Returns:
332 Base flags to use for U-Boot, as a list.
333 """
334 # pylint: disable=global-statement
335 global arch, board, compiler, family, outdir, smdk, uboard, vendor, verbose
Simon Glass02741682013-05-26 07:07:58 -0700336
Alex Klein1699fab2022-09-08 08:46:06 -0600337 if not verbose:
338 verbose = options.verbose != 0
Simon Glass02741682013-05-26 07:07:58 -0700339
Alex Klein1699fab2022-09-08 08:46:06 -0600340 logging.getLogger().setLevel(options.verbose)
Simon Glass02741682013-05-26 07:07:58 -0700341
Alex Klein1699fab2022-09-08 08:46:06 -0600342 Log("Building for %s" % options.board)
Simon Glass02741682013-05-26 07:07:58 -0700343
Alex Klein1699fab2022-09-08 08:46:06 -0600344 # Separate out board_variant string: "peach_pit" becomes "peach", "pit".
345 # But don't mess up upstream boards which use _ in their name.
346 parts = options.board.split("_")
347 if parts[0] in ["daisy", "peach"]:
348 board = parts[0]
Simon Glass02741682013-05-26 07:07:58 -0700349 else:
Alex Klein1699fab2022-09-08 08:46:06 -0600350 board = options.board
Simon Glass02741682013-05-26 07:07:58 -0700351
Alex Klein1699fab2022-09-08 08:46:06 -0600352 # To allow this to be run from 'cros_sdk'
353 if in_chroot:
354 os.chdir(os.path.join(src_root, "third_party", "u-boot", "files"))
Simon Glass02741682013-05-26 07:07:58 -0700355
Alex Klein1699fab2022-09-08 08:46:06 -0600356 base_board = board
Simon Glass02741682013-05-26 07:07:58 -0700357
Alex Klein1699fab2022-09-08 08:46:06 -0600358 if options.verified:
359 base_board = "chromeos_%s" % base_board
Simon Glass02741682013-05-26 07:07:58 -0700360
Alex Klein1699fab2022-09-08 08:46:06 -0600361 uboard = UBOARDS.get(base_board, base_board)
362 Log("U-Boot board is %s" % uboard)
Simon Glass02741682013-05-26 07:07:58 -0700363
Alex Klein1699fab2022-09-08 08:46:06 -0600364 # Pull out some information from the U-Boot boards config file
365 family = None
366 (PRE_KBUILD, PRE_KCONFIG, KCONFIG) = range(3)
367 if os.path.exists("MAINTAINERS"):
368 board_format = PRE_KBUILD
369 else:
370 board_format = PRE_KCONFIG
371 with open("boards.cfg") as f:
372 for line in f:
373 if "genboardscfg" in line:
374 board_format = KCONFIG
375 if uboard in line:
376 if line[0] == "#":
377 continue
378 fields = line.split()
379 if not fields:
380 continue
Simon Glassa44a1f92023-02-09 16:31:34 -0700381 target = fields[6]
382 # Make sure this is the right target.
383 if target != uboard:
384 continue
Alex Klein1699fab2022-09-08 08:46:06 -0600385 arch = fields[1]
386 fields += [None, None, None]
387 if board_format == PRE_KBUILD:
388 smdk = fields[3]
389 vendor = fields[4]
390 family = fields[5]
Alex Klein1699fab2022-09-08 08:46:06 -0600391 elif board_format in (PRE_KCONFIG, KCONFIG):
392 smdk = fields[5]
393 vendor = fields[4]
394 family = fields[3]
395 target = fields[0]
Alex Klein1699fab2022-09-08 08:46:06 -0600396 if not arch:
397 cros_build_lib.Die(
398 "Selected board '%s' not found in boards.cfg." % board
399 )
Simon Glass02741682013-05-26 07:07:58 -0700400
Alex Klein1699fab2022-09-08 08:46:06 -0600401 vboot = os.path.join("build", board, "usr")
Simon Glassa44a1f92023-02-09 16:31:34 -0700402 if in_chroot:
403 if arch == "x86":
404 compiler = "i686-cros-linux-gnu-"
405 elif arch == "arm":
406 compiler = FindCompiler(arch, "armv7a-cros-linux-gnueabihf-")
407 elif arch == "aarch64":
408 compiler = FindCompiler(arch, "aarch64-cros-linux-gnu-")
Alex Klein1699fab2022-09-08 08:46:06 -0600409 elif arch == "sandbox":
410 compiler = ""
411 else:
Simon Glassa44a1f92023-02-09 16:31:34 -0700412 result = cros_build_lib.run(
413 ["buildman", "-A", "--boards", options.board],
414 capture_output=True,
415 encoding="utf-8",
416 **kwargs,
417 )
418 compiler = result.stdout.strip()
419 if not compiler:
420 cros_build_lib.Die("Selected arch '%s' not supported.", arch)
Simon Glass02741682013-05-26 07:07:58 -0700421
Alex Klein1699fab2022-09-08 08:46:06 -0600422 if not options.build:
423 options.incremental = True
Simon Glass02741682013-05-26 07:07:58 -0700424
Alex Klein1699fab2022-09-08 08:46:06 -0600425 cpus = multiprocessing.cpu_count()
Simon Glass02741682013-05-26 07:07:58 -0700426
Alex Klein1699fab2022-09-08 08:46:06 -0600427 outdir = os.path.join(OUT_DIR, uboard)
428 base = [
429 "make",
430 "-j%d" % cpus,
431 "O=%s" % outdir,
432 "ARCH=%s" % arch,
433 "CROSS_COMPILE=%s" % compiler,
434 "--no-print-directory",
435 "HOSTSTRIP=true",
436 "DEV_TREE_SRC=%s-%s" % (family, options.dt),
437 "QEMU_ARCH=",
438 ]
Simon Glass02741682013-05-26 07:07:58 -0700439
Alex Klein1699fab2022-09-08 08:46:06 -0600440 if options.verbose < 2:
441 base.append("-s")
442 elif options.verbose > 2:
443 base.append("V=1")
Simon Glass02741682013-05-26 07:07:58 -0700444
Alex Klein1699fab2022-09-08 08:46:06 -0600445 if options.verified:
446 base += [
447 "VBOOT=%s" % vboot,
448 "MAKEFLAGS_VBOOT=DEBUG=1",
449 "QUIET=1",
450 "CFLAGS_EXTRA_VBOOT=-DUNROLL_LOOPS",
451 "VBOOT_SOURCE=%s/platform/vboot_reference" % src_root,
452 ]
453 base.append("VBOOT_DEBUG=1")
454
Alex Klein1699fab2022-09-08 08:46:06 -0600455 base.append("BUILD_ROM=1")
456 if options.trace:
457 base.append("FTRACE=1")
Alex Klein1699fab2022-09-08 08:46:06 -0600458
459 if options.incremental:
Alex Klein1699fab2022-09-08 08:46:06 -0600460 config_mk = "%s/include/autoconf.mk" % outdir
461 if not os.path.exists(config_mk):
462 logging.warning("No build found for %s - dropping -i", board)
463 options.incremental = False
464
465 config_mk = "include/autoconf.mk"
466 if os.path.exists(config_mk):
467 logging.warning("Warning: '%s' exists, try 'make distclean'", config_mk)
468
Alex Klein1699fab2022-09-08 08:46:06 -0600469 return base
Simon Glass02741682013-05-26 07:07:58 -0700470
471
472def RunBuild(options, base, target, queue):
Alex Klein1699fab2022-09-08 08:46:06 -0600473 """Run the U-Boot build.
Simon Glass02741682013-05-26 07:07:58 -0700474
Alex Klein1699fab2022-09-08 08:46:06 -0600475 Args:
476 options: Command line options.
477 base: Base U-Boot flags.
478 target: Target to build.
479 queue: A parallel queue to add jobs to.
480 """
481 Log("U-Boot build flags: %s" % " ".join(base))
Simon Glass02741682013-05-26 07:07:58 -0700482
Alex Klein1699fab2022-09-08 08:46:06 -0600483 # Reconfigure U-Boot.
484 if not options.incremental:
485 # Ignore any error from this, some older U-Boots fail on this.
486 cros_build_lib.run(base + ["distclean"], **kwargs)
487 if os.path.exists("tools/genboardscfg.py"):
488 mtarget = "defconfig"
489 else:
490 mtarget = "config"
491 cmd = base + ["%s_%s" % (uboard, mtarget)]
492 result = cros_build_lib.run(
493 cmd, stdout=True, stderr=subprocess.STDOUT, **kwargs
494 )
495 if result.returncode:
496 print("cmd: '%s', output: '%s'" % (result.cmdstr, result.stdout))
497 sys.exit(result.returncode)
Simon Glass02741682013-05-26 07:07:58 -0700498
Alex Klein1699fab2022-09-08 08:46:06 -0600499 # Do the actual build.
500 if options.build:
501 result = cros_build_lib.run(
502 base + [target], stdout=True, stderr=subprocess.STDOUT, **kwargs
503 )
504 if result.returncode:
505 # The build failed, so output the results to stderr.
506 print(
507 "cmd: '%s', output: '%s'" % (result.cmdstr, result.stdout),
508 file=sys.stderr,
509 )
510 sys.exit(result.returncode)
Simon Glass02741682013-05-26 07:07:58 -0700511
Alex Klein1699fab2022-09-08 08:46:06 -0600512 files = ["%s/u-boot" % outdir]
513 spl = glob.glob("%s/spl/u-boot-spl" % outdir)
514 if spl:
515 files += spl
516 if options.size:
517 result = cros_build_lib.run([CompilerTool("size")] + files, **kwargs)
518 if result.returncode:
519 sys.exit()
Simon Glass02741682013-05-26 07:07:58 -0700520
Alex Klein1699fab2022-09-08 08:46:06 -0600521 # Create disassembly files .dis and .Dis (full dump)
522 for f in files:
523 base = os.path.splitext(f)[0]
524 if options.objdump:
525 queue.put(("-d", f, base + ".dis"))
526 queue.put(("-D", f, base + ".Dis"))
527 else:
528 # Remove old files which otherwise might be confusing
529 osutils.SafeUnlink(base + ".dis")
530 osutils.SafeUnlink(base + ".Dis")
Simon Glass02741682013-05-26 07:07:58 -0700531
Alex Klein1699fab2022-09-08 08:46:06 -0600532 Log("Output directory %s" % outdir)
Simon Glass02741682013-05-26 07:07:58 -0700533
534
Simon Glass02741682013-05-26 07:07:58 -0700535def main(argv):
Simon Glasse6201d72023-02-09 16:42:22 -0700536 """Main function for script to build firmware.
Simon Glass02741682013-05-26 07:07:58 -0700537
Alex Klein1699fab2022-09-08 08:46:06 -0600538 Args:
539 argv: Program arguments.
540 """
541 options = ParseCmdline(argv)
542 base = SetupBuild(options)
Simon Glass02741682013-05-26 07:07:58 -0700543
Alex Klein1699fab2022-09-08 08:46:06 -0600544 with parallel.BackgroundTaskRunner(Dumper) as queue:
545 RunBuild(options, base, options.target, queue)
Simon Glass02741682013-05-26 07:07:58 -0700546
Alex Klein1699fab2022-09-08 08:46:06 -0600547 if options.objdump:
548 Log("Writing diasssembly files")