Skip to content

Commit 9a50583

Browse files
committed
[silicon_creator] Use linker symbol to access the chip_info
Some places were using a symbol provided by chip_info.h but this symbol might not be present in the binary. Instead, the expected way to access the symbol is to use the linker provided one which uses a fixed address. Signed-off-by: Amaury Pouly <[email protected]>
1 parent 59dd03e commit 9a50583

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

sw/device/silicon_creator/lib/chip_info.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,9 @@ enum {
5151
};
5252

5353
/**
54-
* Extern declaration for the `kChipInfo` instance placed at the end of ROM.
55-
*
56-
* The actual definition is in an auto-generated file.
54+
* The chip information is placed at the end of ROM and is accessible using
55+
* the following symbol.
5756
*/
58-
extern const chip_info_t kChipInfo;
57+
extern const char _chip_info_start[];
5958

6059
#endif // OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_CHIP_INFO_H_

sw/device/silicon_creator/lib/shutdown.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,11 @@ SHUTDOWN_FUNC(NO_MODIFIERS, shutdown_report_error(rom_error_t reason)) {
413413

414414
// Print the error message and the raw life cycle state as reported by the
415415
// hardware.
416+
const chip_info_t *rom_chip_info = (const chip_info_t *)_chip_info_start;
416417
shutdown_print(kShutdownLogPrefixBootFault, redacted_error);
417418
shutdown_print(kShutdownLogPrefixLifecycle, raw_state);
418419
shutdown_print(kShutdownLogPrefixVersion,
419-
kChipInfo.scm_revision.scm_revision_high);
420+
rom_chip_info->scm_revision.scm_revision_high);
420421
}
421422

422423
SHUTDOWN_FUNC(NO_MODIFIERS, shutdown_software_escalate(void)) {

sw/device/silicon_creator/rom/rom.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,10 @@ static rom_error_t rom_init(void) {
244244

245245
// Initialize boot_log
246246
boot_log_t *boot_log = &retention_sram_get()->creator.boot_log;
247+
const chip_info_t *rom_chip_info = (const chip_info_t *)_chip_info_start;
247248
memset(boot_log, 0, sizeof(*boot_log));
248249
boot_log->identifier = kBootLogIdentifier;
249-
boot_log->chip_version = kChipInfo.scm_revision;
250+
boot_log->chip_version = rom_chip_info->scm_revision;
250251
boot_log->retention_ram_initialized =
251252
reset_reasons & reset_mask ? kHardenedBoolTrue : kHardenedBoolFalse;
252253

0 commit comments

Comments
 (0)