Skip to content

Commit 1a1b939

Browse files
pamauryluismarques
authored andcommitted
[rom,e2e] Add a test for the chip_info
The chip_info became broken without anyone realizing because it was untested. This test ensures that at least the chip info is filled and has the expected version. Signed-off-by: Amaury Pouly <[email protected]>
1 parent 148eca8 commit 1a1b939

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed

sw/device/silicon_creator/rom/data/rom_e2e_testplan.hjson

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,5 +1326,23 @@
13261326
si_stage: NA
13271327
tests: ["rom_e2e_self_hash"]
13281328
}
1329+
1330+
{
1331+
name: rom_e2e_chip_info
1332+
desc: '''Verify that ROM correctly embeds the chip information and stores it in the boot log
1333+
1334+
- Load a ROM_EXT image that will
1335+
- Print the content of the ROM's chip_info section.
1336+
- When running as the ROM_EXT, the ROM is still readable, the chip_info is located
1337+
at the end of the ROM.
1338+
- Print the content of the boot log's chip info.
1339+
- Verify that the two are identical.
1340+
- Verify that the chip_info's version is the expected one.
1341+
'''
1342+
tags: ["rom", "dv", "fpga", "silicon"]
1343+
stage: V3
1344+
si_stage: SV2
1345+
tests: []
1346+
}
13291347
]
13301348
}

sw/device/silicon_creator/rom/e2e/BUILD

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,3 +477,20 @@ opentitan_test(
477477
"//sw/device/silicon_creator/lib/drivers:rstmgr",
478478
],
479479
)
480+
481+
opentitan_test(
482+
name = "rom_e2e_chip_info",
483+
srcs = ["chip_info_test.c"],
484+
exec_env = {
485+
"//hw/top_earlgrey:fpga_cw310_rom_with_fake_keys": None,
486+
"//hw/top_earlgrey:fpga_cw310_test_rom": None,
487+
"//hw/top_earlgrey:fpga_cw340_rom_with_fake_keys": None,
488+
"//hw/top_earlgrey:fpga_cw340_test_rom": None,
489+
},
490+
deps = [
491+
"//sw/device/lib/testing:ret_sram_testutils",
492+
"//sw/device/lib/testing/test_framework:ottf_main",
493+
"//sw/device/silicon_creator/lib:build_info",
494+
"//sw/device/silicon_creator/lib/drivers:retention_sram",
495+
],
496+
)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright lowRISC contributors (OpenTitan project).
2+
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
#include <stdbool.h>
6+
7+
#include "sw/device/lib/testing/ret_sram_testutils.h"
8+
#include "sw/device/lib/testing/test_framework/ottf_main.h"
9+
#include "sw/device/silicon_creator/lib/build_info.h"
10+
#include "sw/device/silicon_creator/lib/drivers/retention_sram.h"
11+
12+
OTTF_DEFINE_TEST_CONFIG();
13+
14+
extern const char _chip_info_start[];
15+
16+
bool test_main(void) {
17+
build_info_t *build_info = (build_info_t *)&_chip_info_start;
18+
LOG_INFO("ROM Build Info");
19+
LOG_INFO(" Version: %x", build_info->version);
20+
LOG_INFO(" SCM lo: %x", build_info->scm_revision.scm_revision_low);
21+
LOG_INFO(" SCM hi: %x", build_info->scm_revision.scm_revision_high);
22+
23+
// Make sure that the version is valid.
24+
CHECK(build_info->version == kBuildInfoVersion1);
25+
26+
bool is_testrom = false;
27+
CHECK_STATUS_OK(ret_sram_testutils_is_testrom(&is_testrom));
28+
if (!is_testrom) {
29+
boot_log_t *boot_log = &retention_sram_get()->creator.boot_log;
30+
LOG_INFO("Boot Log Info");
31+
LOG_INFO(" SCM lo: %x", boot_log->chip_version.scm_revision_low);
32+
LOG_INFO(" SCM hi: %x", boot_log->chip_version.scm_revision_high);
33+
34+
// Make sure that the boot log correctly reflects the ROM build info.
35+
CHECK(build_info->scm_revision.scm_revision_low ==
36+
boot_log->chip_version.scm_revision_low);
37+
CHECK(build_info->scm_revision.scm_revision_high ==
38+
boot_log->chip_version.scm_revision_high);
39+
} else {
40+
LOG_INFO("Boot log info check skipped (test_rom detected).");
41+
}
42+
43+
return true;
44+
}

0 commit comments

Comments
 (0)