Skip to content

Commit 3cba0f6

Browse files
committed
[test] Ignore bus integrity alert for scrambled SRAM test
When we expect ECC errors we have to ignore the fatal bus integrity alerts from Ibex otherwise the chip will repeatedly be interrupted. Signed-off-by: James Wainwright <[email protected]>
1 parent 1a1b939 commit 3cba0f6

File tree

2 files changed

+46
-23
lines changed

2 files changed

+46
-23
lines changed

sw/device/tests/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7386,6 +7386,7 @@ opentitan_test(
73867386
"//sw/device/lib/testing:flash_ctrl_testutils",
73877387
"//sw/device/lib/testing:rstmgr_testutils",
73887388
"//sw/device/lib/testing:sram_ctrl_testutils",
7389+
"//sw/device/lib/testing/test_framework:ottf_alerts",
73897390
"//sw/device/lib/testing/test_framework:ottf_main",
73907391
],
73917392
)

sw/device/tests/sram_ctrl_scrambled_access_test.c

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "sw/device/lib/testing/rstmgr_testutils.h"
1717
#include "sw/device/lib/testing/sram_ctrl_testutils.h"
1818
#include "sw/device/lib/testing/test_framework/check.h"
19+
#include "sw/device/lib/testing/test_framework/ottf_alerts.h"
1920
#include "sw/device/lib/testing/test_framework/ottf_main.h"
2021

2122
#include "hw/top_earlgrey/sw/autogen/top_earlgrey.h"
@@ -126,6 +127,26 @@ static const uint32_t kRamTestPattern2[kTestBufferSizeWords] = {
126127
*/
127128
static const uint8_t kBackdoorExpectedBytes[kTestBufferSizeBytes];
128129

130+
// This is not done on CW305/CW310 FPGAs because interrupts for ECC errors are
131+
// only triggered when the SecureIbex parameter is enabled. This parameter is
132+
// disabled for these boards due to resource constraints. On CW340 and the other
133+
// targets, this parameter is enabled.
134+
static bool expect_ecc_errors(void) {
135+
switch (kDeviceType) {
136+
case kDeviceFpgaCw305:
137+
case kDeviceFpgaCw310:
138+
return false;
139+
case kDeviceFpgaCw340:
140+
case kDeviceSilicon:
141+
case kDeviceSimDV:
142+
case kDeviceSimVerilator:
143+
return true;
144+
default:
145+
CHECK(false, "Device type not handled: %d", kDeviceType);
146+
return false;
147+
}
148+
}
149+
129150
/**
130151
* Performs scrambling, saves the test relevant data and resets the system.
131152
*
@@ -148,6 +169,14 @@ static noreturn void main_sram_scramble(void) {
148169
copy_len += sizeof(reference_frame->backdoor);
149170
}
150171

172+
// If we expect ECC errors from copying our pattern buffers then we have to
173+
// disable the fatal alert associated with bus integrity checks. This is a
174+
// fatal alert so we cannot "expect" it.
175+
if (expect_ecc_errors()) {
176+
CHECK_STATUS_OK(
177+
ottf_alerts_ignore_alert(kTopEarlgreyAlertIdRvCoreIbexFatalHwErr));
178+
}
179+
151180
asm volatile(
152181
// Save the tests frames addresses before the scrambling.
153182
"lw a2, 0(%[mainFrame]) \n"
@@ -256,6 +285,22 @@ static void execute_main_sram_test(void) {
256285
}
257286

258287
static void check_sram_data(scramble_test_frame *mem_frame) {
288+
// Decide whether to perform ECC error count checks after memory is scrambled.
289+
//
290+
// This is not done on CW305/CW310 FPGAs because interrupts for ECC errors are
291+
// only triggered when the SecureIbex parameter is enabled. This parameter is
292+
// disabled for these boards due to resource constraints. On CW340 and the
293+
// other targets, this parameter is enabled.
294+
bool check_ecc_errors = expect_ecc_errors();
295+
296+
// If we expect ECC errors from copying our pattern buffers then we have to
297+
// disable the fatal alert associated with bus integrity checks. This is a
298+
// fatal alert so we cannot "expect" it.
299+
if (check_ecc_errors) {
300+
CHECK_STATUS_OK(
301+
ottf_alerts_ignore_alert(kTopEarlgreyAlertIdRvCoreIbexFatalHwErr));
302+
}
303+
259304
LOG_INFO("Checking addr 0x%x", mem_frame->pattern);
260305
uint32_t tmp_buffer[kTestBufferSizeWords];
261306
memcpy(tmp_buffer, (const uint8_t *)mem_frame->pattern, sizeof(tmp_buffer));
@@ -265,29 +310,6 @@ static void check_sram_data(scramble_test_frame *mem_frame) {
265310
CHECK_ARRAYS_NE((uint32_t *)tmp_buffer, kRamTestPattern2,
266311
kTestBufferSizeWords);
267312

268-
// Decide whether to perform ECC error count checks after memory is scrambled.
269-
//
270-
// This is not done on CW305/CW310 FPGAs because interrupts for ECC errors are
271-
// only triggered when the SecureIbex parameter is enabled. This parameter is
272-
// disabled for these boards due to resource constraints. On CW340 and the
273-
// other targets, this parameter is enabled.
274-
bool check_ecc_errors = false;
275-
switch (kDeviceType) {
276-
case kDeviceFpgaCw305:
277-
case kDeviceFpgaCw310:
278-
check_ecc_errors = false;
279-
break;
280-
case kDeviceFpgaCw340:
281-
case kDeviceSilicon:
282-
case kDeviceSimDV:
283-
case kDeviceSimVerilator:
284-
check_ecc_errors = true;
285-
break;
286-
default:
287-
CHECK(false, "Device type not handled: %d", kDeviceType);
288-
return;
289-
}
290-
291313
if (check_ecc_errors) {
292314
LOG_INFO("Checking ECC error count of %d",
293315
reference_frame->ecc_error_counter);

0 commit comments

Comments
 (0)