blob: 0f9ddda4393633d5cbf8788063a511c6feb275d6 [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 "--build",
239 action="store_false",
240 default=True,
241 help="Don't build U-Boot, just configure device tree",
242 )
243 parser.add_argument(
Alex Klein1699fab2022-09-08 08:46:06 -0600244 "-d",
245 "--dt",
246 default="seaboard",
247 help="Select name of device tree file to use",
248 )
249 parser.add_argument(
Alex Klein1699fab2022-09-08 08:46:06 -0600250 "-i",
251 "--incremental",
252 action="store_true",
253 default=False,
254 help="Don't reconfigure and clean",
255 )
256 parser.add_argument(
Alex Klein1699fab2022-09-08 08:46:06 -0600257 "-O",
258 "--objdump",
259 action="store_true",
260 default=False,
261 help="Write disassembly output",
262 )
263 parser.add_argument(
Alex Klein1699fab2022-09-08 08:46:06 -0600264 "-t",
265 "--trace",
266 action="store_true",
267 default=False,
268 help="Enable trace support",
269 )
270 parser.add_argument(
Simon Glassa68488c2023-02-09 16:53:47 -0700271 "-T",
272 "--target",
273 nargs="?",
274 default="all",
275 help="Select target to build",
276 )
277 parser.add_argument(
Alex Klein1699fab2022-09-08 08:46:06 -0600278 "-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(
Simon Glassa68488c2023-02-09 16:53:47 -0700292 "board",
293 type=str,
294 default=default_board,
295 help="Select board to build (daisy/peach_pit/link)",
Alex Klein1699fab2022-09-08 08:46:06 -0600296 )
297 return parser.parse_args(argv)
Simon Glass02741682013-05-26 07:07:58 -0700298
299
Simon Glassc1a323a2016-08-04 20:29:51 -0600300def FindCompiler(gcc, cros_prefix):
Alex Klein1699fab2022-09-08 08:46:06 -0600301 """Look up the compiler for an architecture.
Simon Glassc1a323a2016-08-04 20:29:51 -0600302
Alex Klein1699fab2022-09-08 08:46:06 -0600303 Args:
304 gcc: GCC architecture, either 'arm' or 'aarch64'
305 cros_prefix: Full Chromium OS toolchain prefix
306 """
307 if in_chroot:
308 # Use the Chromium OS toolchain.
309 prefix = cros_prefix
310 else:
311 prefix = glob.glob("/opt/linaro/gcc-linaro-%s-linux-*/bin/*gcc" % gcc)
312 if not prefix:
313 cros_build_lib.Die(
314 """Please install an %s toolchain for your machine.
Simon Glassc1a323a2016-08-04 20:29:51 -0600315Install a Linaro toolchain from:
316https://launchpad.net/linaro-toolchain-binaries
Alex Klein1699fab2022-09-08 08:46:06 -0600317or see cros/commands/cros_chrome_sdk.py."""
318 % gcc
319 )
320 prefix = re.sub("gcc$", "", prefix[0])
321 return prefix
Simon Glassc1a323a2016-08-04 20:29:51 -0600322
323
Simon Glass02741682013-05-26 07:07:58 -0700324def SetupBuild(options):
Alex Klein1699fab2022-09-08 08:46:06 -0600325 """Set up parameters needed for the build.
Simon Glass02741682013-05-26 07:07:58 -0700326
Alex Klein1699fab2022-09-08 08:46:06 -0600327 This checks the current environment and options and sets up various things
328 needed for the build, including 'base' which holds the base flags for
329 passing to the U-Boot Makefile.
Simon Glass02741682013-05-26 07:07:58 -0700330
Alex Klein1699fab2022-09-08 08:46:06 -0600331 Args:
332 options: Command line options
Simon Glass02741682013-05-26 07:07:58 -0700333
Alex Klein1699fab2022-09-08 08:46:06 -0600334 Returns:
335 Base flags to use for U-Boot, as a list.
336 """
337 # pylint: disable=global-statement
338 global arch, board, compiler, family, outdir, smdk, uboard, vendor, verbose
Simon Glass02741682013-05-26 07:07:58 -0700339
Alex Klein1699fab2022-09-08 08:46:06 -0600340 if not verbose:
341 verbose = options.verbose != 0
Simon Glass02741682013-05-26 07:07:58 -0700342
Alex Klein1699fab2022-09-08 08:46:06 -0600343 logging.getLogger().setLevel(options.verbose)
Simon Glass02741682013-05-26 07:07:58 -0700344
Alex Klein1699fab2022-09-08 08:46:06 -0600345 Log("Building for %s" % options.board)
Simon Glass02741682013-05-26 07:07:58 -0700346
Alex Klein1699fab2022-09-08 08:46:06 -0600347 # Separate out board_variant string: "peach_pit" becomes "peach", "pit".
348 # But don't mess up upstream boards which use _ in their name.
349 parts = options.board.split("_")
350 if parts[0] in ["daisy", "peach"]:
351 board = parts[0]
Simon Glass02741682013-05-26 07:07:58 -0700352 else:
Alex Klein1699fab2022-09-08 08:46:06 -0600353 board = options.board
Simon Glass02741682013-05-26 07:07:58 -0700354
Alex Klein1699fab2022-09-08 08:46:06 -0600355 # To allow this to be run from 'cros_sdk'
356 if in_chroot:
357 os.chdir(os.path.join(src_root, "third_party", "u-boot", "files"))
Simon Glass02741682013-05-26 07:07:58 -0700358
Alex Klein1699fab2022-09-08 08:46:06 -0600359 base_board = board
Simon Glass02741682013-05-26 07:07:58 -0700360
Alex Klein1699fab2022-09-08 08:46:06 -0600361 if options.verified:
362 base_board = "chromeos_%s" % base_board
Simon Glass02741682013-05-26 07:07:58 -0700363
Alex Klein1699fab2022-09-08 08:46:06 -0600364 uboard = UBOARDS.get(base_board, base_board)
365 Log("U-Boot board is %s" % uboard)
Simon Glass02741682013-05-26 07:07:58 -0700366
Alex Klein1699fab2022-09-08 08:46:06 -0600367 # Pull out some information from the U-Boot boards config file
368 family = None
369 (PRE_KBUILD, PRE_KCONFIG, KCONFIG) = range(3)
370 if os.path.exists("MAINTAINERS"):
371 board_format = PRE_KBUILD
372 else:
373 board_format = PRE_KCONFIG
374 with open("boards.cfg") as f:
375 for line in f:
376 if "genboardscfg" in line:
377 board_format = KCONFIG
378 if uboard in line:
379 if line[0] == "#":
380 continue
381 fields = line.split()
382 if not fields:
383 continue
Simon Glassa44a1f92023-02-09 16:31:34 -0700384 target = fields[6]
385 # Make sure this is the right target.
386 if target != uboard:
387 continue
Alex Klein1699fab2022-09-08 08:46:06 -0600388 arch = fields[1]
389 fields += [None, None, None]
390 if board_format == PRE_KBUILD:
391 smdk = fields[3]
392 vendor = fields[4]
393 family = fields[5]
Alex Klein1699fab2022-09-08 08:46:06 -0600394 elif board_format in (PRE_KCONFIG, KCONFIG):
395 smdk = fields[5]
396 vendor = fields[4]
397 family = fields[3]
398 target = fields[0]
Alex Klein1699fab2022-09-08 08:46:06 -0600399 if not arch:
400 cros_build_lib.Die(
401 "Selected board '%s' not found in boards.cfg." % board
402 )
Simon Glass02741682013-05-26 07:07:58 -0700403
Alex Klein1699fab2022-09-08 08:46:06 -0600404 vboot = os.path.join("build", board, "usr")
Simon Glassa44a1f92023-02-09 16:31:34 -0700405 if in_chroot:
406 if arch == "x86":
407 compiler = "i686-cros-linux-gnu-"
408 elif arch == "arm":
409 compiler = FindCompiler(arch, "armv7a-cros-linux-gnueabihf-")
410 elif arch == "aarch64":
411 compiler = FindCompiler(arch, "aarch64-cros-linux-gnu-")
Alex Klein1699fab2022-09-08 08:46:06 -0600412 elif arch == "sandbox":
413 compiler = ""
414 else:
Simon Glassa44a1f92023-02-09 16:31:34 -0700415 result = cros_build_lib.run(
416 ["buildman", "-A", "--boards", options.board],
417 capture_output=True,
418 encoding="utf-8",
419 **kwargs,
420 )
421 compiler = result.stdout.strip()
422 if not compiler:
423 cros_build_lib.Die("Selected arch '%s' not supported.", arch)
Simon Glass02741682013-05-26 07:07:58 -0700424
Alex Klein1699fab2022-09-08 08:46:06 -0600425 if not options.build:
426 options.incremental = True
Simon Glass02741682013-05-26 07:07:58 -0700427
Alex Klein1699fab2022-09-08 08:46:06 -0600428 cpus = multiprocessing.cpu_count()
Simon Glass02741682013-05-26 07:07:58 -0700429
Alex Klein1699fab2022-09-08 08:46:06 -0600430 outdir = os.path.join(OUT_DIR, uboard)
431 base = [
432 "make",
433 "-j%d" % cpus,
434 "O=%s" % outdir,
435 "ARCH=%s" % arch,
436 "CROSS_COMPILE=%s" % compiler,
437 "--no-print-directory",
438 "HOSTSTRIP=true",
439 "DEV_TREE_SRC=%s-%s" % (family, options.dt),
440 "QEMU_ARCH=",
441 ]
Simon Glass02741682013-05-26 07:07:58 -0700442
Alex Klein1699fab2022-09-08 08:46:06 -0600443 if options.verbose < 2:
444 base.append("-s")
445 elif options.verbose > 2:
446 base.append("V=1")
Simon Glass02741682013-05-26 07:07:58 -0700447
Alex Klein1699fab2022-09-08 08:46:06 -0600448 if options.verified:
449 base += [
450 "VBOOT=%s" % vboot,
451 "MAKEFLAGS_VBOOT=DEBUG=1",
452 "QUIET=1",
453 "CFLAGS_EXTRA_VBOOT=-DUNROLL_LOOPS",
454 "VBOOT_SOURCE=%s/platform/vboot_reference" % src_root,
455 ]
456 base.append("VBOOT_DEBUG=1")
457
Alex Klein1699fab2022-09-08 08:46:06 -0600458 base.append("BUILD_ROM=1")
459 if options.trace:
460 base.append("FTRACE=1")
Alex Klein1699fab2022-09-08 08:46:06 -0600461
462 if options.incremental:
Alex Klein1699fab2022-09-08 08:46:06 -0600463 config_mk = "%s/include/autoconf.mk" % outdir
464 if not os.path.exists(config_mk):
465 logging.warning("No build found for %s - dropping -i", board)
466 options.incremental = False
467
468 config_mk = "include/autoconf.mk"
469 if os.path.exists(config_mk):
470 logging.warning("Warning: '%s' exists, try 'make distclean'", config_mk)
471
Alex Klein1699fab2022-09-08 08:46:06 -0600472 return base
Simon Glass02741682013-05-26 07:07:58 -0700473
474
475def RunBuild(options, base, target, queue):
Alex Klein1699fab2022-09-08 08:46:06 -0600476 """Run the U-Boot build.
Simon Glass02741682013-05-26 07:07:58 -0700477
Alex Klein1699fab2022-09-08 08:46:06 -0600478 Args:
479 options: Command line options.
480 base: Base U-Boot flags.
481 target: Target to build.
482 queue: A parallel queue to add jobs to.
483 """
484 Log("U-Boot build flags: %s" % " ".join(base))
Simon Glass02741682013-05-26 07:07:58 -0700485
Alex Klein1699fab2022-09-08 08:46:06 -0600486 # Reconfigure U-Boot.
487 if not options.incremental:
488 # Ignore any error from this, some older U-Boots fail on this.
489 cros_build_lib.run(base + ["distclean"], **kwargs)
490 if os.path.exists("tools/genboardscfg.py"):
491 mtarget = "defconfig"
492 else:
493 mtarget = "config"
494 cmd = base + ["%s_%s" % (uboard, mtarget)]
495 result = cros_build_lib.run(
496 cmd, stdout=True, stderr=subprocess.STDOUT, **kwargs
497 )
498 if result.returncode:
499 print("cmd: '%s', output: '%s'" % (result.cmdstr, result.stdout))
500 sys.exit(result.returncode)
Simon Glass02741682013-05-26 07:07:58 -0700501
Alex Klein1699fab2022-09-08 08:46:06 -0600502 # Do the actual build.
503 if options.build:
504 result = cros_build_lib.run(
505 base + [target], stdout=True, stderr=subprocess.STDOUT, **kwargs
506 )
507 if result.returncode:
508 # The build failed, so output the results to stderr.
509 print(
510 "cmd: '%s', output: '%s'" % (result.cmdstr, result.stdout),
511 file=sys.stderr,
512 )
513 sys.exit(result.returncode)
Simon Glass02741682013-05-26 07:07:58 -0700514
Alex Klein1699fab2022-09-08 08:46:06 -0600515 files = ["%s/u-boot" % outdir]
516 spl = glob.glob("%s/spl/u-boot-spl" % outdir)
517 if spl:
518 files += spl
519 if options.size:
520 result = cros_build_lib.run([CompilerTool("size")] + files, **kwargs)
521 if result.returncode:
522 sys.exit()
Simon Glass02741682013-05-26 07:07:58 -0700523
Alex Klein1699fab2022-09-08 08:46:06 -0600524 # Create disassembly files .dis and .Dis (full dump)
525 for f in files:
526 base = os.path.splitext(f)[0]
527 if options.objdump:
528 queue.put(("-d", f, base + ".dis"))
529 queue.put(("-D", f, base + ".Dis"))
530 else:
531 # Remove old files which otherwise might be confusing
532 osutils.SafeUnlink(base + ".dis")
533 osutils.SafeUnlink(base + ".Dis")
Simon Glass02741682013-05-26 07:07:58 -0700534
Alex Klein1699fab2022-09-08 08:46:06 -0600535 Log("Output directory %s" % outdir)
Simon Glass02741682013-05-26 07:07:58 -0700536
537
Simon Glass02741682013-05-26 07:07:58 -0700538def main(argv):
Simon Glasse6201d72023-02-09 16:42:22 -0700539 """Main function for script to build firmware.
Simon Glass02741682013-05-26 07:07:58 -0700540
Alex Klein1699fab2022-09-08 08:46:06 -0600541 Args:
542 argv: Program arguments.
543 """
544 options = ParseCmdline(argv)
545 base = SetupBuild(options)
Simon Glass02741682013-05-26 07:07:58 -0700546
Alex Klein1699fab2022-09-08 08:46:06 -0600547 with parallel.BackgroundTaskRunner(Dumper) as queue:
548 RunBuild(options, base, options.target, queue)
Simon Glass02741682013-05-26 07:07:58 -0700549
Alex Klein1699fab2022-09-08 08:46:06 -0600550 if options.objdump:
551 Log("Writing diasssembly files")