[flash, dv] Fix RMA test backdoor symbol overwrite
Moved the function invocation to `cpu_init`
Signed-off-by: Weicai Yang <weicai@google.com>
diff --git a/hw/dv/sv/mem_bkdr_util/mem_bkdr_util__rom.sv b/hw/dv/sv/mem_bkdr_util/mem_bkdr_util__rom.sv
index e4c1e00..eab25b1 100644
--- a/hw/dv/sv/mem_bkdr_util/mem_bkdr_util__rom.sv
+++ b/hw/dv/sv/mem_bkdr_util/mem_bkdr_util__rom.sv
@@ -138,14 +138,11 @@
logic [SRAM_KEY_WIDTH-1:0] key,
logic [SRAM_BLOCK_WIDTH-1:0] nonce,
bit scramble_data = 1);
- uint32_t byte_idx;
bit [bus_params_pkg::BUS_AW-1:0] aligned_addr = (addr >> addr_lsb) << addr_lsb;
int byte_offset = addr % bytes_per_word;
bit [31:0] rw_data = 32'(rom_encrypt_read32(addr, key, nonce, scramble_data));
- byte_idx = addr - aligned_addr;
- rw_data[byte_idx * 8 +: 8] = data;
-
+ rw_data[byte_offset * 8 +: 8] = data;
rom_encrypt_write32_integ(aligned_addr, rw_data, key, nonce, scramble_data);
endfunction
diff --git a/hw/top_earlgrey/dv/env/seq_lib/chip_sw_flash_rma_unlocked_vseq.sv b/hw/top_earlgrey/dv/env/seq_lib/chip_sw_flash_rma_unlocked_vseq.sv
index a97bf38..feec4ec 100644
--- a/hw/top_earlgrey/dv/env/seq_lib/chip_sw_flash_rma_unlocked_vseq.sv
+++ b/hw/top_earlgrey/dv/env/seq_lib/chip_sw_flash_rma_unlocked_vseq.sv
@@ -26,27 +26,7 @@
bit [sram_scrambler_pkg::SRAM_BLOCK_WIDTH-1:0] sram_ret_nonce;
bit [sram_scrambler_pkg::SRAM_KEY_WIDTH-1:0] sram_ret_key;
- // TODO(lowRISC/opentitan:#11795): replace with SW symbol backdoor write
- // when this is fixed for ROM.
- // Currently a fixed unlock token which will match in software.
- bit [7:0] rma_unlock_token[TokenWidthByte] = '{
- 8'h00,
- 8'h01,
- 8'h02,
- 8'h03,
- 8'h04,
- 8'h05,
- 8'h06,
- 8'h07,
- 8'h08,
- 8'h09,
- 8'h0a,
- 8'h0b,
- 8'h0c,
- 8'h0d,
- 8'h0e,
- 8'h0f
- };
+ rand bit [7:0] rma_unlock_token[TokenWidthByte];
rand bit [7:0] creator_root_key0[KeyWidthByte];
rand bit [7:0] creator_root_key1[KeyWidthByte];
@@ -109,9 +89,10 @@
super.dut_init(reset_kind);
// Override the LC partition to Dev state.
cfg.mem_bkdr_util_h[Otp].otp_write_lc_partition_state(LcStDev);
- // TODO(lowRISC/opentitan:#11795): replace with SW symbol backdoor write
- // when this is fixed for ROM.
- // The following overwrite does not yet work.
+ endtask
+
+ virtual task cpu_init();
+ super.cpu_init();
sw_symbol_backdoor_overwrite("kLcRmaUnlockToken", rma_unlock_token, Rom, SwTypeRom);
endtask
diff --git a/sw/device/tests/sim_dv/flash_rma_unlocked_test.c b/sw/device/tests/sim_dv/flash_rma_unlocked_test.c
index a163299..a0f53e4 100644
--- a/sw/device/tests/sim_dv/flash_rma_unlocked_test.c
+++ b/sw/device/tests/sim_dv/flash_rma_unlocked_test.c
@@ -78,9 +78,6 @@
0x733bf534, 0xc4914b4b, 0x64487458, 0x9d0fa332}};
// RMA unlock token value for LC state transition.
-// TODO(lowRISC/opentitan:#11795): when the sw_symbol_backdoor_overwrite
-// is fixed for ROM, this can be overriden by the testbench as a SW variable.
-// Currently hardcoded to match the token written in the testbench.
static volatile const uint8_t kLcRmaUnlockToken[LC_TOKEN_SIZE] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,