Skip to content

Commit de9b601

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

File tree

2 files changed

+30
-23
lines changed

2 files changed

+30
-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: 29 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,33 @@ 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+
# Ideally, relevant info pages would be spliced in at this step, but that is
425+
# not yet supported by either flashgen or by Bazel.
426+
if param["bootstrap"] and json.decode(param["bootstrap"]):
427+
test_script_fmt |= {"flash": ""}
428+
bootstrap_cmd = "bootstrap --clear-uart=true --reset-delay 1000ms {firmware}".format(**param)
429+
param["bootstrap_cmd"] = '--exec="{}"'.format(bootstrap_cmd)
430+
else:
431+
# Generate the flash backend image for QEMU emulation
432+
flash_image = gen_flash(
433+
ctx,
434+
flashgen = exec_env.flashgen,
435+
firmware_bin = image,
436+
# TODO: no support for convenience debug symbols from ELFs for now
437+
firmware_elf = None,
438+
# Do not sanity check ELFs, because we do not expect the binary to
439+
# match the ELF because of the added manifest extensions (e.g. SPX
440+
# signatures) present in the signed binary.
441+
check_elfs = False,
442+
)
443+
data_files += [flash_image]
444+
qemu_args += ["-drive", "if=mtd,id=eflash,bus=2,file=flash_img.bin,format=raw"]
445+
test_script_fmt |= {
446+
"flash": flash_image.short_path,
447+
}
448+
param["bootstrap_cmd"] = '--exec="no-op" # SKIPPING BOOTSTRAP'
442449

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

0 commit comments

Comments
 (0)