Skip to content

Commit

Permalink
[bazel] Remove *_jtag_params
Browse files Browse the repository at this point in the history
This commit removes all usage of *_jtag_params and convert them to use
of `needs_jtag` and `changes_otp` (if necessary).

Signed-off-by: Gary Guo <gary.guo@lowrisc.org>
  • Loading branch information
nbdd0121 authored and pamaury committed Feb 29, 2024
1 parent d809804 commit ec74233
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 175 deletions.
6 changes: 0 additions & 6 deletions rules/opentitan/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,14 @@ load(
)
load(
"@lowrisc_opentitan//rules/opentitan:fpga_cw310.bzl",
_cw310_jtag_params = "cw310_jtag_params",
_cw310_params = "cw310_params",
_fpga_cw305 = "fpga_cw305",
_fpga_cw310 = "fpga_cw310",
_fpga_cw340 = "fpga_cw340",
_hyper310_jtag_params = "hyper310_jtag_params",
)
load(
"@lowrisc_opentitan//rules/opentitan:silicon.bzl",
_silicon = "silicon",
_silicon_jtag_params = "silicon_jtag_params",
_silicon_params = "silicon_params",
)
load(
Expand Down Expand Up @@ -57,12 +54,9 @@ fpga_cw310 = _fpga_cw310
fpga_cw305 = _fpga_cw305
fpga_cw340 = _fpga_cw340
cw310_params = _cw310_params
cw310_jtag_params = _cw310_jtag_params
hyper310_jtag_params = _hyper310_jtag_params

silicon = _silicon
silicon_params = _silicon_params
silicon_jtag_params = _silicon_jtag_params

sim_verilator = _sim_verilator
verilator_params = _verilator_params
Expand Down
56 changes: 0 additions & 56 deletions rules/opentitan/fpga_cw310.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -255,59 +255,3 @@ def cw310_params(
data = data,
param = kwargs,
)

def cw310_jtag_params(**kwargs):
"""A macro to create CW310 parameters for OpenTitan JTAG tests.
This creates version of the CW310 parameter structure pre-initialized
with OpenOCD dependencies and test_cmd parameters.
Args:
tags: The test tags to apply to the test rule.
timeout: The timeout to apply to the test rule.
local: Whether to set the `local` flag on this test.
test_harness: Use an alternative test harness for this test.
binaries: Dict of binary labels to substitution parameter names.
rom: Use an alternate ROM for this test.
rom_ext: Use an alternate ROM_EXT for this test.
otp: Use an alternate OTP configuration for this test.
bitstream: Use an alternate bitstream for this test.
test_cmd: Use an alternate test_cmd for this test.
data: Additional files needed by this test.
kwargs: Additional key-value pairs to override in the test `param` dict.
Returns:
struct of test parameters.
"""
return cw310_params(
changes_otp = True,
needs_jtag = True,
**kwargs
)

def hyper310_jtag_params(**kwargs):
"""A macro to create Hyper310 parameters for OpenTitan JTAG tests.
This creates version of the Hyper310 parameter structure pre-initialized
with OpenOCD dependencies and test_cmd parameters.
Args:
tags: The test tags to apply to the test rule.
timeout: The timeout to apply to the test rule.
local: Whether to set the `local` flag on this test.
test_harness: Use an alternative test harness for this test.
binaries: Dict of binary labels to substitution parameter names.
rom: Use an alternate ROM for this test.
rom_ext: Use an alternate ROM_EXT for this test.
otp: Use an alternate OTP configuration for this test.
bitstream: Use an alternate bitstream for this test.
test_cmd: Use an alternate test_cmd for this test.
data: Additional files needed by this test.
kwargs: Additional key-value pairs to override in the test `param` dict.
Returns:
struct of test parameters.
"""
return cw310_params(
changes_otp = True,
needs_jtag = True,
**kwargs
)
26 changes: 2 additions & 24 deletions rules/opentitan/silicon.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def silicon_params(
test_harness: Use an alternative test harness for this test.
binaries: Dict of binary labels to substitution parameter names.
rom_ext: Use an alternate ROM_EXT for this test.
changes_otp: Whether this test may change the OTP.
needs_jtag: If this test requires JTAG access, set this to True.
test_cmd: Use an alternate test_cmd for this test.
data: Additional files needed by this test.
Expand All @@ -167,34 +168,11 @@ def silicon_params(
rom_ext = rom_ext,
otp = None,
bitstream = None,
changes_otp = None,
needs_jtag = needs_jtag,
test_cmd = ("""
{jtag_test_cmd}
""" if needs_jtag else "") + test_cmd,
data = data,
param = kwargs,
)

def silicon_jtag_params(**kwargs):
"""A macro to create Silicon parameters for OpenTitan JTAG tests.
This creates version of the Silicon parameter structure pre-initialized
with OpenOCD dependencies and test_cmd parameters.
Args:
tags: The test tags to apply to the test rule.
timeout: The timeout to apply to the test rule.
local: Whether to set the `local` flag on this test.
test_harness: Use an alternative test harness for this test.
binaries: Dict of binary labels to substitution parameter names.
rom_ext: Use an alternate ROM_EXT for this test.
test_cmd: Use an alternate test_cmd for this test.
data: Additional files needed by this test.
kwargs: Additional key-value pairs to override in the test `param` dict.
Returns:
struct of test parameters.
"""
return silicon_params(
needs_jtag = True,
**kwargs
)
5 changes: 3 additions & 2 deletions sw/device/silicon_creator/manuf/lib/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ load(
"//rules/opentitan:defs.bzl",
"OPENTITAN_CPU",
"cw310_params",
"hyper310_jtag_params",
"opentitan_test",
)
load(
Expand Down Expand Up @@ -263,8 +262,10 @@ cc_library(
opentitan_test(
name = "personalize_functest",
srcs = ["personalize_functest.c"],
cw310 = hyper310_jtag_params(
cw310 = cw310_params(
changes_otp = True,
data = ["//sw/device/silicon_creator/manuf/keys/fake:rma_unlock_token_export_key.sk_hsm.der"],
needs_jtag = True,
otp = "//hw/ip/otp_ctrl/data/earlgrey_a0_skus/sival_bringup:otp_img_dev_manuf_individualized",
tags = [
"broken", # https://github.com/lowRISC/opentitan/issues/19086
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ load("//rules:manifest.bzl", "manifest")
load("//rules:signing.bzl", "offline_presigning_artifacts", "offline_signature_attach")
load(
"//rules/opentitan:defs.bzl",
"cw310_jtag_params",
"hyper310_jtag_params",
"cw310_params",
"opentitan_binary",
"opentitan_test",
"silicon_jtag_params",
"silicon_params",
)
load(
"//sw/device/silicon_creator/manuf:provisioning_inputs.bzl",
Expand Down Expand Up @@ -114,8 +113,10 @@ _CP_PROVISIONING_CMD_ARGS = """

opentitan_test(
name = "cp_provision",
cw310 = hyper310_jtag_params(
cw310 = cw310_params(
binaries = {":sram_cp_provision": "sram_cp_provision"},
changes_otp = True,
needs_jtag = True,
otp = "//hw/ip/otp_ctrl/data/earlgrey_a0_skus/sival_bringup:otp_img_test_unlocked0_manuf_empty",
tags = ["manuf"],
test_cmd = _CP_PROVISIONING_CMD_ARGS,
Expand All @@ -125,22 +126,26 @@ opentitan_test(
"//hw/top_earlgrey:fpga_cw310_sival": None,
"//hw/top_earlgrey:silicon_creator": None,
},
silicon = silicon_jtag_params(
silicon = silicon_params(
binaries = {":sram_cp_provision": "sram_cp_provision"},
changes_otp = True,
interface = "hyper310",
needs_jtag = True,
test_cmd = _CP_PROVISIONING_CMD_ARGS,
test_harness = "//sw/host/tests/manuf/provisioning/cp",
),
)

opentitan_test(
name = "cp_provision_functest",
cw310 = cw310_jtag_params(
cw310 = cw310_params(
binaries = {
":sram_cp_provision": "sram_cp_provision",
":sram_cp_provision_functest": "sram_cp_provision_functest",
},
bitstream = "//hw/bitstream:rom_with_fake_keys_otp_raw",
changes_otp = True,
needs_jtag = True,
tags = ["manuf"],
test_cmd = """
--provisioning-sram-elf={sram_cp_provision}
Expand Down Expand Up @@ -301,9 +306,11 @@ _FT_PROVISIONING_CMD_ARGS = """

opentitan_test(
name = "ft_provision",
cw310 = hyper310_jtag_params(
cw310 = cw310_params(
binaries = _FT_PROVISIONING_BINARIES,
changes_otp = True,
data = FT_PERSONALIZE_KEYS,
needs_jtag = True,
otp = "//hw/ip/otp_ctrl/data/earlgrey_a0_skus/sival_bringup:otp_img_test_locked0_manuf_initialized",
tags = [
"lc_test_locked0",
Expand All @@ -316,10 +323,12 @@ opentitan_test(
"//hw/top_earlgrey:fpga_cw310_sival": None,
"//hw/top_earlgrey:silicon_creator": None,
},
silicon = silicon_jtag_params(
silicon = silicon_params(
binaries = _FT_PROVISIONING_BINARIES,
changes_otp = True,
data = FT_PERSONALIZE_KEYS,
interface = "hyper310",
needs_jtag = True,
test_cmd = _FT_PROVISIONING_CMD_ARGS,
test_harness = "//sw/host/tests/manuf/provisioning/ft",
),
Expand Down
41 changes: 29 additions & 12 deletions sw/device/silicon_creator/manuf/tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ load(
load("//rules:otp.bzl", "otp_image")
load(
"//rules/opentitan:defs.bzl",
"cw310_jtag_params",
"cw310_params",
"opentitan_binary",
"opentitan_test",
"rsa_key_for_lc_state",
"silicon_jtag_params",
"silicon_params",
)

package(default_visibility = ["//visibility:public"])
Expand Down Expand Up @@ -69,9 +69,11 @@ _MANUF_TEST_LOCKED_KEY = None
opentitan_test(
name = "manuf_scrap_functest_{}".format(lc_state.lower()),
srcs = ["empty_functest.c"],
cw310 = cw310_jtag_params(
cw310 = cw310_params(
bitstream = "//hw/bitstream:rom_with_fake_keys_otp_{}".format(lc_state.lower()),
changes_otp = True,
lc_state = lc_state, # will be expanded in test_cmd
needs_jtag = True,
tags = ["manuf"],
test_cmd = (
"" if (
Expand Down Expand Up @@ -108,8 +110,10 @@ lc_raw_unlock_token(
opentitan_test(
name = "manuf_cp_unlock_raw_functest",
srcs = ["//sw/device/silicon_creator/rom/e2e:empty_test.c"],
cw310 = cw310_jtag_params(
cw310 = cw310_params(
bitstream = "//hw/bitstream:rom_with_fake_keys_otp_raw",
changes_otp = True,
needs_jtag = True,
tags = ["manuf"],
test_harness = "//sw/host/tests/manuf/manuf_cp_unlock_raw",
),
Expand All @@ -128,8 +132,10 @@ opentitan_test(
opentitan_test(
name = "manuf_cp_volatile_unlock_raw_functest",
srcs = ["//sw/device/silicon_creator/rom/e2e:empty_test.c"],
cw310 = cw310_jtag_params(
cw310 = cw310_params(
bitstream = "//hw/bitstream:rom_with_fake_keys_otp_raw",
changes_otp = True,
needs_jtag = True,
tags = ["manuf"],
test_harness = "//sw/host/tests/manuf/manuf_cp_volatile_unlock_raw",
),
Expand Down Expand Up @@ -163,8 +169,10 @@ opentitan_test(
opentitan_test(
name = "manuf_cp_yield_test_functest_{}".format(lc_state.lower()),
srcs = ["//sw/device/silicon_creator/rom/e2e:empty_test.c"],
cw310 = cw310_jtag_params(
cw310 = cw310_params(
changes_otp = True,
lc_state = lc_state, # will be expanded in test_cmd
needs_jtag = True,
otp = ":otp_img_rom_exec_disabled_{}".format(lc_state.lower()),
tags = ["manuf"],
test_cmd = "--initial-lc-state={lc_state}",
Expand Down Expand Up @@ -210,7 +218,8 @@ cc_library(
opentitan_test(
name = "manuf_sram_program_crc_{}_functest".format(lc_state.lower()),
srcs = ["sram_empty_functest.c"],
cw310 = cw310_jtag_params(
cw310 = cw310_params(
needs_jtag = True,
otp = ":otp_img_rom_exec_disabled_{}".format(lc_state.lower()),
test_cmd = "--elf={firmware}",
test_harness = "//sw/host/tests/manuf/manuf_sram_program_crc_check",
Expand All @@ -221,8 +230,9 @@ cc_library(
},
kind = "ram",
linker_script = "//sw/device/silicon_creator/manuf/lib:sram_program_linker_script",
silicon = silicon_jtag_params(
silicon = silicon_params(
interface = "hyper310",
needs_jtag = True,
test_cmd = "--elf={firmware}",
test_harness = "//sw/host/tests/manuf/manuf_sram_program_crc_check",
),
Expand Down Expand Up @@ -291,10 +301,12 @@ opentitan_binary(
target_lc_state.lower(),
),
srcs = ["flash_device_info_flash_wr_functest.c"],
cw310 = cw310_jtag_params(
cw310 = cw310_params(
binaries = {
":sram_device_info_flash_wr_functest": "sram_program",
},
changes_otp = True,
needs_jtag = True,
otp = ":otp_img_rom_exec_disabled_{}".format(init_lc_state.lower()),
tags = ["manuf"],
target_lc_state = target_lc_state, # will be expanded in test_cmd
Expand Down Expand Up @@ -373,10 +385,11 @@ opentitan_binary(
opentitan_test(
name = "manuf_cp_ast_test_execution_{}_functest".format(lc_state.lower()),
srcs = ["idle_functest.c"],
cw310 = cw310_jtag_params(
cw310 = cw310_params(
binaries = {
":sram_exec_test": "sram_program",
},
needs_jtag = True,
otp = ":otp_img_rom_exec_disabled_{}".format(lc_state.lower()),
tags = ["manuf"],
test_cmd = """
Expand Down Expand Up @@ -409,7 +422,9 @@ test_suite(
opentitan_test(
name = "manuf_cp_test_lock_functest",
srcs = ["//sw/device/silicon_creator/rom/e2e:empty_test.c"],
cw310 = cw310_jtag_params(
cw310 = cw310_params(
changes_otp = True,
needs_jtag = True,
otp = ":otp_img_otp_ctrl_functest",
tags = ["manuf"],
test_harness = "//sw/host/tests/manuf/manuf_cp_test_lock",
Expand All @@ -435,7 +450,9 @@ otp_image(
opentitan_test(
name = "otp_ctrl_functest",
srcs = [":empty_functest.c"],
cw310 = cw310_jtag_params(
cw310 = cw310_params(
changes_otp = True,
needs_jtag = True,
otp = ":otp_img_otp_ctrl_functest",
tags = ["manuf"],
test_harness = "//sw/host/tests/manuf/otp_ctrl:otp_ctrl",
Expand Down
7 changes: 3 additions & 4 deletions sw/device/silicon_creator/rom/e2e/bootstrap/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

load(
"//rules/opentitan:defs.bzl",
"cw310_jtag_params",
"cw310_params",
"opentitan_test",
"rsa_key_for_lc_state",
Expand Down Expand Up @@ -72,10 +71,10 @@ otp_image(
opentitan_test(
name = "e2e_bootstrap_rma",
srcs = ["rom_e2e_bootstrap_rma_test.c"],
cw310 = cw310_jtag_params(
cw310 = cw310_params(
changes_otp = True,
needs_jtag = True,
otp = "otp_img_bootstrap_rma",
# We need to clear the bitstream between consecutive runs of this
# test since it modifies OTP state (i.e., the LC state).
test_cmd = """
--bootstrap="{firmware}"
""",
Expand Down
Loading

0 comments on commit ec74233

Please sign in to comment.