forked from lowRISC/opentitan
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[chip-test] Add
volatile_raw_unlock
test
This commit adds a new test chip_sw_lc_ctrl_volatile_raw_unlock which exercises the VOLATILE_RAW_UNLOCK functionality in the lc_ctrl. The test enables ROM execution via rv_dm after entering test_unlocked0, and then does a second volatile unlock operation to verify CPU execution. Signed-off-by: Miguel Osorio <[email protected]>
- Loading branch information
Showing
8 changed files
with
197 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
hw/top_earlgrey/dv/env/seq_lib/chip_sw_lc_volatile_raw_unlock_vseq.sv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright lowRISC contributors. | ||
// Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
class chip_sw_lc_volatile_raw_unlock_vseq extends chip_sw_base_vseq; | ||
`uvm_object_utils(chip_sw_lc_volatile_raw_unlock_vseq) | ||
|
||
`uvm_object_new | ||
|
||
virtual task pre_start(); | ||
cfg.chip_vif.tap_straps_if.drive(JtagTapLc); | ||
super.pre_start(); | ||
endtask | ||
|
||
// reset jtag interface | ||
virtual task reset_jtag_tap(); | ||
cfg.m_jtag_riscv_agent_cfg.in_reset = 1; | ||
#1000ns; | ||
cfg.m_jtag_riscv_agent_cfg.in_reset = 0; | ||
endtask | ||
|
||
virtual task body(); | ||
bit [TokenWidthBit-1:0] otp_exit_token_bits, otp_unlock_token_bits, otp_rma_token_bits; | ||
bit [7:0] selected_dest_state[]; | ||
|
||
jtag_riscv_dm_activation_seq jtag_dm_activation_seq = | ||
jtag_riscv_dm_activation_seq::type_id::create("jtag_dm_activation_seq"); | ||
|
||
super.body(); | ||
|
||
wait_lc_ready(1); | ||
|
||
// VOLATILE_RAW_UNLOCK does not require a reset after completion. | ||
// Applying a reset will move the device back to RAW state in this case. | ||
jtag_lc_state_volatile_raw_unlock(JtagTapRvDm); | ||
reset_jtag_tap(); | ||
|
||
// In RAW state the ROM should halt as RomExecEn is not set yet. | ||
`DV_WAIT(cfg.sw_test_status_vif.sw_test_status == SwTestStatusInBootRomHalt) | ||
|
||
// Use the frontend interface to configure the RomExecEn OTP value. A | ||
// reset is required to have otp_ctrl sample the new OTP value. | ||
`uvm_info(`gfn, "Configuring RomExecEng", UVM_LOW) | ||
jtag_dm_activation_seq.start(p_sequencer.jtag_sequencer_h); | ||
`uvm_info(`gfn, $sformatf("rv_dm_activated: %0d", cfg.m_jtag_riscv_agent_cfg.rv_dm_activated), | ||
UVM_LOW) | ||
cfg.m_jtag_riscv_agent_cfg.is_rv_dm = 1; | ||
jtag_otp_program32(otp_ctrl_reg_pkg::CreatorSwCfgRomExecEnOffset, 1); | ||
|
||
cfg.chip_vif.tap_straps_if.drive(JtagTapLc); | ||
cfg.m_jtag_riscv_agent_cfg.is_rv_dm = 0; | ||
apply_reset(); | ||
|
||
// Second VOLATILE_RAW_UNLOCK does not change the TAP interface to rv_dm | ||
// so that we can check the completion status through that interface. | ||
// After this, the rest of the test should proceed. | ||
jtag_lc_state_volatile_raw_unlock(JtagTapLc); | ||
|
||
endtask | ||
endclass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright lowRISC contributors. | ||
// Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include <assert.h> | ||
#include <stdbool.h> | ||
|
||
#include "sw/device/lib/base/bitfield.h" | ||
#include "sw/device/lib/base/memory.h" | ||
#include "sw/device/lib/base/mmio.h" | ||
#include "sw/device/lib/dif/dif_lc_ctrl.h" | ||
#include "sw/device/lib/runtime/log.h" | ||
#include "sw/device/lib/testing/lc_ctrl_testutils.h" | ||
#include "sw/device/lib/testing/test_framework/check.h" | ||
#include "sw/device/lib/testing/test_framework/ottf_main.h" | ||
|
||
#include "hw/top_earlgrey/sw/autogen/top_earlgrey.h" | ||
|
||
static dif_lc_ctrl_t lc_ctrl; | ||
|
||
OTTF_DEFINE_TEST_CONFIG(); | ||
|
||
bool test_main(void) { | ||
CHECK_DIF_OK(dif_lc_ctrl_init( | ||
mmio_region_from_addr(TOP_EARLGREY_LC_CTRL_BASE_ADDR), &lc_ctrl)); | ||
|
||
dif_lc_ctrl_state_t state; | ||
CHECK_DIF_OK(dif_lc_ctrl_get_state(&lc_ctrl, &state)); | ||
CHECK(state == kDifLcCtrlStateTestUnlocked0); | ||
return true; | ||
} |