Skip to content

Commit e319dd0

Browse files
timothytrippelpamaury
authored andcommitted
[bazel] enable building VMEM image for multislot bins
The personalization binary is combined with the transport image into a multislot binary payload that is bootstrapped during personalization. This updates `opentitan_binary_assemble` rule to build VMEM files for opentitantool-assembled multislot image so they can be loaded in DV to bringup ATE flows for manufacturing. This fixes #25977. Signed-off-by: Tim Trippel <[email protected]> (cherry picked from commit 12742d2)
1 parent e76ba7a commit e319dd0

File tree

2 files changed

+64
-5
lines changed
  • rules/opentitan
  • sw/device/silicon_creator/manuf/tests

2 files changed

+64
-5
lines changed

rules/opentitan/cc.bzl

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ load(
99
_OPENTITAN_PLATFORM = "OPENTITAN_PLATFORM",
1010
_opentitan_transition = "opentitan_transition",
1111
)
12-
load("@lowrisc_opentitan//rules:signing.bzl", "sign_binary")
13-
load("@lowrisc_opentitan//rules/opentitan:exec_env.bzl", "ExecEnvInfo")
1412
load(
1513
"@lowrisc_opentitan//rules/opentitan:transform.bzl",
14+
"convert_to_vmem",
1615
"obj_disassemble",
1716
"obj_transform",
1817
)
18+
load("@lowrisc_opentitan//rules:signing.bzl", "sign_binary")
19+
load("@lowrisc_opentitan//rules/opentitan:exec_env.bzl", "ExecEnvInfo")
1920
load("@lowrisc_opentitan//rules/opentitan:util.bzl", "get_fallback", "get_override")
2021
load("@rules_cc//cc:find_cc_toolchain.bzl", "find_cc_toolchain")
2122
load("//rules/opentitan:toolchain.bzl", "LOCALTOOLS_TOOLCHAIN")
@@ -599,9 +600,25 @@ def _opentitan_binary_assemble_impl(ctx):
599600
spec = " ".join(spec)
600601
spec = recursive_format(spec, action_param)
601602
spec = spec.split(" ")
602-
img = assemble_for_test(ctx, name, spec, input_bins, tc.tools.opentitantool)
603-
result.append(exec_env_provider(default = img, kind = "flash"))
604-
assembled_bins.append(img)
603+
604+
# Generate the multislot bin.
605+
bin = assemble_for_test(ctx, name, spec, input_bins, tc.tools.opentitantool)
606+
607+
# Generate unscrambled VMEM files.
608+
#
609+
# Multi-slot binaries are currently only used for bootstrap operations,
610+
# i.e., non-backdoor loaded sim environments and FPGA/silicon
611+
# environments. Therefore we only need unscrambled VMEM files.
612+
vmem = convert_to_vmem(
613+
ctx,
614+
name = name,
615+
src = bin,
616+
word_size = 64,
617+
)
618+
619+
result.append(exec_env_provider(default = bin, kind = "flash", vmem = vmem))
620+
assembled_bins.append(bin)
621+
assembled_bins.append(vmem)
605622
ot_bin_env_info[exec_env_provider] = env
606623
result.append(OpenTitanBinaryInfo(exec_env = ot_bin_env_info))
607624
return result + [DefaultInfo(files = depset(assembled_bins))]

sw/device/silicon_creator/manuf/tests/BUILD

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
load("//rules:const.bzl", "CONST", "get_lc_items")
66
load("//rules:lc.bzl", "lc_raw_unlock_token")
77
load("//rules/opentitan:keyutils.bzl", "ECDSA_SPX_KEY_STRUCTS")
8+
load("//rules/opentitan:cc.bzl", "opentitan_binary_assemble")
89
load(
910
"//rules:otp.bzl",
1011
"OTP_SIGVERIFY_FAKE_KEYS",
@@ -19,6 +20,10 @@ load(
1920
"silicon_params",
2021
"spx_key_for_lc_state",
2122
)
23+
load(
24+
"//sw/device/silicon_creator/rom/e2e:defs.bzl",
25+
"SLOTS",
26+
)
2227

2328
package(default_visibility = ["//visibility:public"])
2429

@@ -508,3 +513,40 @@ opentitan_test(
508513
"//sw/device/silicon_creator/lib/sigverify:spx_verify",
509514
],
510515
)
516+
517+
[
518+
opentitan_binary(
519+
name = "empty_test_{}".format(slot),
520+
testonly = True,
521+
srcs = ["empty_functest.c"],
522+
exec_env = {
523+
"//hw/top_earlgrey:sim_dv": None,
524+
"//hw/top_earlgrey:silicon_creator": None,
525+
},
526+
linker_script = "//sw/device/lib/testing/test_framework:ottf_ld_silicon_creator_slot_{}".format(slot),
527+
deps = [
528+
"//sw/device/lib/runtime:log",
529+
"//sw/device/lib/testing/test_framework:ottf_main",
530+
],
531+
)
532+
for slot in SLOTS.keys()
533+
]
534+
535+
opentitan_binary_assemble(
536+
name = "multislot_empty_test",
537+
testonly = True,
538+
bins = {
539+
":empty_test_a": SLOTS["a"],
540+
":empty_test_b": SLOTS["b"],
541+
},
542+
exec_env = [
543+
"//hw/top_earlgrey:sim_dv",
544+
"//hw/top_earlgrey:silicon_creator",
545+
],
546+
)
547+
548+
# The below alias is needed to run the multislot_empty_test in DV.
549+
alias(
550+
name = "multislot_empty_test_sim_dv",
551+
actual = "multislot_empty_test",
552+
)

0 commit comments

Comments
 (0)