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 */
127128static 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,17 @@ static void execute_main_sram_test(void) {
256285}
257286
258287static void check_sram_data (scramble_test_frame * mem_frame ) {
288+ // Decide whether to perform ECC error count checks after memory is scrambled.
289+ bool check_ecc_errors = expect_ecc_errors ();
290+
291+ // If we expect ECC errors from copying our pattern buffers then we have to
292+ // disable the fatal alert associated with bus integrity checks. This is a
293+ // fatal alert so we cannot "expect" it.
294+ if (check_ecc_errors ) {
295+ CHECK_STATUS_OK (
296+ ottf_alerts_ignore_alert (kTopEarlgreyAlertIdRvCoreIbexFatalHwErr ));
297+ }
298+
259299 LOG_INFO ("Checking addr 0x%x" , mem_frame -> pattern );
260300 uint32_t tmp_buffer [kTestBufferSizeWords ];
261301 memcpy (tmp_buffer , (const uint8_t * )mem_frame -> pattern , sizeof (tmp_buffer ));
@@ -265,29 +305,6 @@ static void check_sram_data(scramble_test_frame *mem_frame) {
265305 CHECK_ARRAYS_NE ((uint32_t * )tmp_buffer , kRamTestPattern2 ,
266306 kTestBufferSizeWords );
267307
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-
291308 if (check_ecc_errors ) {
292309 LOG_INFO ("Checking ECC error count of %d" ,
293310 reference_frame -> ecc_error_counter );
0 commit comments