Skip to content

Commit 8e93c3f

Browse files
committed
[bazel] Make bootstrapping optional for QEMU
Signed-off-by: James Wainwright <[email protected]>
1 parent c83a4c5 commit 8e93c3f

File tree

2 files changed

+32
-23
lines changed

2 files changed

+32
-23
lines changed

hw/top_earlgrey/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ sim_qemu(
159159
slot_spec = EARLGREY_SLOTS,
160160
test_cmd = """
161161
--exec="transport init"
162-
--exec="bootstrap --clear-uart=true --reset-delay 1000ms {firmware}"
162+
{bootstrap_cmd}
163163
--exec="console --non-interactive --exit-success='{exit_success}' --exit-failure='{exit_failure}'"
164164
no-op
165165
""",

rules/opentitan/qemu.bzl

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def qemu_params(
7070
globals = {},
7171
traces = [],
7272
qemu_args = [],
73+
bootstrap = False,
7374
**kwargs):
7475
extra_params = {
7576
"icount": str(icount),
@@ -79,6 +80,7 @@ def qemu_params(
7980
"globals": json.encode(globals),
8081
# The same goes for this array of strings:
8182
"traces": json.encode(traces),
83+
"bootstrap": json.encode(bootstrap),
8284
}
8385

8486
return struct(
@@ -417,28 +419,35 @@ def _test_dispatch(ctx, exec_env, firmware):
417419
"otp": otp_image.short_path,
418420
}
419421

420-
# Generate the flash backend image for QEMU emulation
421-
# TODO: when bootstrapping is available, this should always create a blank
422-
# flash image and bootstrap the data. Ideally, relevant info pages would
423-
# be spliced in at this step, but that is not yet supported by either
424-
# flashgen or by Bazel.
425-
flash_image = gen_flash(
426-
ctx,
427-
flashgen = exec_env.flashgen,
428-
firmware_bin = image,
429-
# TODO: no support for convenience debug symbols from ELFs for now
430-
firmware_elf = None,
431-
# Do not sanity check ELFs, because we do not expect the binary to
432-
# match the ELF because of the added manifest extensions (e.g. SPX
433-
# signatures) present in the signed binary.
434-
check_elfs = False,
435-
)
436-
data_files += [flash_image]
437-
qemu_args += ["-drive", "if=mtd,id=eflash,bus=2,file=flash_img.bin,format=raw"]
438-
test_script_fmt |= {
439-
"flash": flash_image.short_path,
440-
"mutable_flash": "flash_img.bin",
441-
}
422+
# If real bootstrapping is requested then prepare the correct command, otherwise we need
423+
# to prepare a QEMU drive containing flash contents.
424+
if param["bootstrap"] and json.decode(param["bootstrap"]):
425+
test_script_fmt |= {"flash": ""}
426+
bootstrap_cmd = "bootstrap --clear-uart=true --reset-delay 1000ms {firmware}".format(**param)
427+
param["bootstrap_cmd"] = '--exec="{}"'.format(bootstrap_cmd)
428+
else:
429+
# Generate the flash backend image for QEMU emulation
430+
# TODO: when bootstrapping is available, this should always create a blank
431+
# flash image and bootstrap the data. Ideally, relevant info pages would
432+
# be spliced in at this step, but that is not yet supported by either
433+
# flashgen or by Bazel.
434+
flash_image = gen_flash(
435+
ctx,
436+
flashgen = exec_env.flashgen,
437+
firmware_bin = image,
438+
# TODO: no support for convenience debug symbols from ELFs for now
439+
firmware_elf = None,
440+
# Do not sanity check ELFs, because we do not expect the binary to
441+
# match the ELF because of the added manifest extensions (e.g. SPX
442+
# signatures) present in the signed binary.
443+
check_elfs = False,
444+
)
445+
data_files += [flash_image]
446+
qemu_args += ["-drive", "if=mtd,id=eflash,bus=2,file=flash_img.bin,format=raw"]
447+
test_script_fmt |= {
448+
"flash": flash_image.short_path,
449+
}
450+
param["bootstrap_cmd"] = '--exec="no-op" # SKIPPING BOOTSTRAP'
442451

443452
# Get the pre-test_cmd args.
444453
args = get_fallback(ctx, "attr.args", exec_env)

0 commit comments

Comments
 (0)